Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
xiaoxiaole
Commits
dfb92bdc
Commit
dfb92bdc
authored
Oct 22, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
1b766b54
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
378 additions
and
86 deletions
+378
-86
MainScene.ts
egret/src/mainScene/MainScene.ts
+219
-74
Tool.ts
egret/src/something/Tool.ts
+55
-11
EleMaskAni.ts
egret/src/something/anis/EleMaskAni.ts
+51
-0
RectMask.ts
egret/src/something/class/RectMask.ts
+22
-0
RecoverName.ts
egret/src/something/enum/RecoverName.ts
+3
-0
FallAniData.ts
egret/src/something/interface/FallAniData.ts
+27
-0
PathData.ts
egret/src/something/interface/PathData.ts
+1
-1
No files found.
egret/src/mainScene/MainScene.ts
View file @
dfb92bdc
...
...
@@ -57,6 +57,8 @@ import { GameGuide } from './GameGuide';
import
{
AiControl
}
from
'../something/logic/AiControl'
;
import
{
JellyDisAni
}
from
'../something/anis/JellyDisAni'
;
import
{
EggBrokenAni
}
from
'../something/anis/EggBrokenAni'
;
import
{
FallAniData
,
FallType
}
from
'../something/interface/FallAniData'
;
import
{
EleMaskAni
}
from
'../something/anis/EleMaskAni'
;
// tslint:disable: no-var-keyword
// tslint:disable: prefer-const
// tslint:disable: cyclomatic-complexity
...
...
@@ -217,9 +219,20 @@ export default class MainScene extends Scene {
gameGuide
:
GameGuide
;
start
(
data
)
{
super
.
start
();
// var a={x:1}
// egret.Tween.get(a)
// .to({x:100},1000)
// .call(()=>{
// console.log(a.x)
// })
// .set({x:0})
// .call(()=>{
// console.log(a.x)
// })
//第几关
this
.
chapter
=
(
data
&&
data
.
chapter
)
?
data
.
chapter
:
1
;
// this.chapter =
81
;
// this.chapter =
24
;
this
.
chapterTxt
.
text
=
"第"
+
this
.
chapter
+
"关"
;
//关卡数据
var
mapDataIndex
=
this
.
chapter
;
...
...
@@ -423,9 +436,9 @@ export default class MainScene extends Scene {
// mask.graphics.beginFill(0xffffff, 1);
// mask.graphics.drawRect(Tool.offsetX, Tool.offsetY, Tool.width * Tool.colNum, Tool.height * Tool.rowNum + 100);
// mask.graphics.endFill();
var
mask
=
drawShape
(
path
);
this
.
elementContainer
.
mask
=
mask
;
this
.
addChild
(
mask
)
//
var mask = drawShape(path);
//
this.elementContainer.mask = mask;
//
this.addChild(mask)
//容器事件
this
.
elementContainer
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_BEGIN
,
this
.
mouseDownE
,
this
);
this
.
elementContainer
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_MOVE
,
this
.
mouseMoveE
,
this
);
...
...
@@ -1056,12 +1069,12 @@ export default class MainScene extends Scene {
if
(
!
anis
.
length
)
{
callback
();
}
else
{
this
.
fallAni
(
anis
,
()
=>
{
this
.
fallAni
Super
(
anis
,
()
=>
{
this
.
fall
(
callback
)
})
}
}
else
{
this
.
fallAni
(
anis
,
()
=>
{
this
.
fallAni
Super
(
anis
,
()
=>
{
this
.
fall
(
callback
)
},
true
)
}
...
...
@@ -1069,12 +1082,12 @@ export default class MainScene extends Scene {
var
anis
=
this
.
fallVertical
();
anis
=
anis
.
concat
(
this
.
fallSkewEx
());
if
(
!
anis
.
length
)
{
//如果没有能掉落的就直接回调
this
.
fallVerMark
=
false
;
//如果没有能掉落的就直接回调
callback
();
}
else
{
//有就执行掉落动画
this
.
fallAni
(
anis
,
()
=>
{
this
.
fallAni
Super
(
anis
,
()
=>
{
this
.
fall
(
callback
)
})
}
...
...
@@ -1082,11 +1095,11 @@ export default class MainScene extends Scene {
}
/**
* 竖直掉落
* 竖直掉落
,一格判断
* 逻辑要重写
*/
private
fallVertical
()
{
var
anis
=
[]
var
anis
:
FallAniData
[]
=
[]
//先把竖直的掉落完,掉满后
for
(
var
m
=
0
;
m
<
Tool
.
colNum
;
m
++
)
{
//同一列
...
...
@@ -1095,18 +1108,20 @@ export default class MainScene extends Scene {
let
lat
=
this
.
lattices
[
index
];
if
(
Tool
.
judgeFall
(
lat
))
{
//如果能掉落,,找down,下面,左下,右下是否有空格
var
latDown
,
indexDown
;
var
latDown
,
indexDown
,
connects
:
{
index
:
number
,
type
:
FallType
}[]
=
[]
;
if
(
lat
.
down
!=
null
)
{
latDown
=
this
.
lattices
[
lat
.
down
];
indexDown
=
lat
.
down
;
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
THROUGH
})
}
else
{
latDown
=
this
.
lattices
[
index
+
Tool
.
colNum
]
indexDown
=
index
+
Tool
.
colNum
;
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
STRIGHT
})
}
//下方有格子,并且再this.empty中
var
emptyIndex
=
this
.
emptys
.
indexOf
(
indexDown
)
if
(
emptyIndex
>
-
1
)
{
anis
.
push
(
[
lat
.
element
,
indexDown
]
);
anis
.
push
(
{
ele
:
lat
.
element
,
indexs
:
connects
}
);
//去掉一个
this
.
emptys
.
splice
(
emptyIndex
,
1
);
//加上一个
...
...
@@ -1116,7 +1131,7 @@ export default class MainScene extends Scene {
}
else
{
//如果有格子。无元素,是生成口
if
(
lat
&&
!
lat
.
element
&&
lat
.
isGenerate
)
{
anis
.
push
(
[
null
,
index
]
);
anis
.
push
(
{
ele
:
null
,
indexs
:
[{
index
:
index
,
type
:
FallType
.
STRIGHT
}]
}
);
Tool
.
removeEle
(
index
,
this
.
emptys
)
}
}
...
...
@@ -1129,23 +1144,23 @@ export default class MainScene extends Scene {
* 一次性都竖直掉落
*/
fallVerticalEx
()
{
var
anis
=
[]
var
anis
:
FallAniData
[]
=
[]
//先把竖直的掉落完,掉满后
var
maxCount
=
1
;
for
(
var
m
=
0
;
m
<
Tool
.
colNum
;
m
++
)
{
//同一列,先原有的填满,再查是否有生成口
for
(
var
n
=
Tool
.
rowNum
-
1
;
n
>=
0
;
n
--
)
{
let
index
=
Tool
.
rcToIndex
(
n
,
m
);
let
lat
=
this
.
lattices
[
index
];
if
(
Tool
.
judgeFall
(
lat
))
{
var
emptyIndex
=
Tool
.
findBottom
(
lat
,
this
.
emptys
,
this
.
lattices
);
var
downIndex
=
this
.
emptys
[
emptyIndex
];
if
(
emptyIndex
!=
null
)
{
var
ccc
=
(
downIndex
-
index
)
/
Tool
.
colNum
maxCount
=
Math
.
max
(
ccc
,
maxCount
);
anis
.
push
([
lat
.
element
,
downIndex
,
ccc
>
1
?
ccc
/
2
:
ccc
]);
//去掉一个
this
.
emptys
.
splice
(
emptyIndex
,
1
);
//待修改
var
indexs
=
Tool
.
findBottom
(
lat
,
this
.
emptys
,
this
.
lattices
);
if
(
indexs
!=
null
)
{
//最后一个
var
downIndex
=
indexs
[
indexs
.
length
-
1
].
index
;
anis
.
push
({
ele
:
lat
.
element
,
indexs
:
indexs
});
//去掉最后一个
// this.emptys.splice(emptyIndex, 1);
Tool
.
removeEle
(
downIndex
,
this
.
emptys
)
//加上一个
this
.
emptys
.
push
(
index
);
lat
.
element
=
null
...
...
@@ -1160,49 +1175,46 @@ export default class MainScene extends Scene {
let
index
=
this
.
generateIndexs
[
m
];
//如果有格子。无元素,是生成口,要补齐下面能掉落的
if
(
lat
&&
!
lat
.
element
&&
lat
.
isGenerate
)
{
//找出从生成口一直到能掉落的空格
var
arr
=
[];
//找出从生成口一直到能掉落的空格,两个
var
downIndex
=
index
;
var
type
:
FallType
=
FallType
.
STRIGHT
;
let
connects
:
{
index
:
number
,
type
:
FallType
}[]
=
[]
let
anisOther
:
FallAniData
[]
=
[]
while
(
this
.
emptys
.
indexOf
(
downIndex
)
>
-
1
)
{
arr
.
push
(
downIndex
);
connects
.
push
({
index
:
downIndex
,
type
:
type
,
})
anis
.
push
({
ele
:
null
,
indexs
:
connects
.
slice
()
});
Tool
.
removeEle
(
downIndex
,
this
.
emptys
)
if
(
this
.
lattices
[
downIndex
].
down
!=
null
)
{
downIndex
=
this
.
lattices
[
downIndex
].
down
;
type
=
FallType
.
THROUGH
}
else
{
downIndex
+=
Tool
.
colNum
;
type
=
FallType
.
STRIGHT
}
}
var
p
=
Tool
.
getPositionByIndex
(
index
);
var
len
=
arr
.
length
;
//越前面的越上面,y越小
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
let
tarIndex
=
arr
[
i
];
var
type
;
if
(
this
.
lollipopMark
)
{
this
.
lollipopMark
=
false
;
type
=
ElementType
.
LOLLIPOP
;
this
.
lollipopCount
++
;
}
else
{
type
=
Tool
.
randomT
(
this
.
chapterData
.
baseElementTypes
)
}
let
obj
=
Tool
.
getElement
(
type
)
obj
.
x
=
p
[
0
];
obj
.
y
=
p
[
1
]
-
Tool
.
height
*
(
len
-
i
);
this
.
elementContainer
.
addChild
(
obj
)
anis
.
push
([
obj
,
tarIndex
,
len
>
1
?
len
/
2
:
len
]);
Tool
.
removeEle
(
tarIndex
,
this
.
emptys
)
// var p = Tool.getPositionByIndex(index);
var
len
=
anis
.
length
;
//越前面的越上面,y越小
for
(
var
i
=
len
-
1
;
i
>=
len
-
connects
.
length
;
i
--
)
{
anis
[
i
].
wait
=
(
len
-
1
-
i
)
*
Tool
.
latDeltaTime
*
2
/
3
;
}
maxCount
=
Math
.
max
(
len
,
maxCount
);
// console.log(len)
}
}
}
anis
[
"maxCount"
]
=
maxCount
>
1
?
maxCount
/
2
:
maxCount
;
return
anis
;
}
/**
* 存在斜落的
*/
private
fallSkewEx
()
{
//记录一个对象和位置信息[obj,index]的数组,如果obj是null则生成,index位置上方
var
anis
=
[];
var
anis
:
FallAniData
[]
=
[];
var
emptys
=
this
.
emptys
;
//排序从大到小
emptys
.
sort
(
function
(
a
,
b
)
{
return
a
<
b
?
1
:
-
1
})
...
...
@@ -1212,7 +1224,7 @@ export default class MainScene extends Scene {
//判断是否是生成口
if
(
lat
.
isGenerate
)
{
//是生成口,就不用管落下乐
anis
.
push
(
[
null
,
indexMy
]
)
anis
.
push
(
{
ele
:
null
,
indexs
:
[{
index
:
indexMy
,
type
:
FallType
.
STRIGHT
}]
}
)
//去掉
emptys
.
splice
(
i
,
1
);
//优先判断生成的,不用管掉落了,跳下一个
...
...
@@ -1221,19 +1233,24 @@ export default class MainScene extends Scene {
}
let
latFall
;
let
indexFall
;
//找正上方是否有能掉落的。
var
latUp
=
this
.
lattices
[
indexMy
-
Tool
.
colNum
];
//上方格子为null,或格子上元素为null
if
(
Tool
.
judgeFall
(
latUp
))
{
latFall
=
latUp
;
indexFall
=
indexMy
-
Tool
.
colNum
;
}
let
type
:
FallType
=
FallType
.
STRIGHT
//找联通的up,一期没有复杂的联通,所以动画不用特殊处理
else
if
(
lat
.
up
)
{
if
(
lat
.
up
)
{
var
latUnUp
=
this
.
lattices
[
lat
.
up
];
if
(
Tool
.
judgeFall
(
latUnUp
))
{
latFall
=
latUnUp
;
indexFall
=
lat
.
up
;
type
=
FallType
.
THROUGH
}
}
//找正上方
if
(
!
latFall
&&
Tool
.
indexToRc
(
indexMy
)[
0
]
!=
0
)
{
var
latUp
=
this
.
lattices
[
indexMy
-
Tool
.
colNum
];
if
(
Tool
.
judgeFall
(
latUp
))
{
latFall
=
latUp
;
indexFall
=
indexMy
-
Tool
.
colNum
;
}
}
//找左上
...
...
@@ -1255,7 +1272,7 @@ export default class MainScene extends Scene {
//如果latFall存在
if
(
latFall
)
{
//能掉落,记录元素动画
anis
.
push
(
[
latFall
.
element
,
indexMy
]
);
anis
.
push
(
{
ele
:
latFall
.
element
,
indexs
:
[{
index
:
indexMy
,
type
:
type
}]
}
);
//去掉
// console.log(emptys)
// console.log(indexFall)
...
...
@@ -1295,21 +1312,7 @@ export default class MainScene extends Scene {
let
rowCount
=
anis
[
i
][
2
]
||
1
;
let
position
=
Tool
.
getPositionByIndex
(
index
);
if
(
!
obj
)
{
//考虑如果需要生成冰淇淋掉落,到时加
var
type
;
if
(
this
.
lollipopMark
)
{
this
.
lollipopMark
=
false
;
type
=
ElementType
.
LOLLIPOP
;
this
.
lollipopCount
++
;
}
else
{
type
=
Tool
.
randomT
(
this
.
chapterData
.
baseElementTypes
)
}
obj
=
Pool
.
takeOut
(
RecoverName
.
ELEMENT
);
if
(
!
obj
)
{
obj
=
new
Element
(
type
)
}
else
{
obj
.
reset
(
type
)
}
obj
=
this
.
createELement
()
//位置信息赋值
this
.
elementContainer
.
addChild
(
obj
);
obj
.
x
=
position
[
0
];
...
...
@@ -1345,6 +1348,148 @@ export default class MainScene extends Scene {
}
fallAniSuper
(
anis
:
FallAniData
[],
callback
:
Function
,
isVertical
:
boolean
=
false
)
{
let
deltaTime
=
Tool
.
latDeltaTime
;
//是竖直的。播放声音
if
(
isVertical
)
{
playSound
(
SoundType
.
fall
);
deltaTime
=
Tool
.
latDeltaTime
*
2
/
3
;
}
let
count
=
0
;
let
countAll
=
anis
.
length
;
for
(
let
i
=
0
;
i
<
anis
.
length
;
i
++
)
{
let
ani
:
FallAniData
=
anis
[
i
];
let
ele
:
Element
=
ani
.
ele
;
let
wait
:
number
=
ani
.
wait
||
0
;
let
indexs
:
{
index
:
number
,
type
:
FallType
}[]
=
ani
.
indexs
;
let
oriRow
:
number
;
let
oriCol
;
//最后的索引
let
endIndex
=
indexs
[
indexs
.
length
-
1
].
index
;
let
tween
:
egret
.
Tween
;
if
(
!
ele
)
{
ele
=
this
.
createELement
();
this
.
elementContainer
.
addChild
(
ele
);
//取出第一个索引
let
firstIndex
=
indexs
.
shift
()
oriRow
=
Tool
.
indexToRc
(
firstIndex
.
index
)[
0
];
let
fp
=
Tool
.
getPositionByIndex
(
firstIndex
.
index
);
ele
.
x
=
fp
[
0
];
ele
.
y
=
fp
[
1
]
-
Tool
.
height
;
//加遮罩
let
mask
=
Tool
.
getRectMask
();
mask
.
x
=
fp
[
0
];
mask
.
y
=
fp
[
1
];
this
.
elementContainer
.
addChild
(
mask
);
ele
.
mask
=
mask
;
tween
=
egret
.
Tween
.
get
(
ele
);
//有等待的话
if
(
wait
)
{
// console.log(wait)
tween
.
wait
(
wait
);
}
tween
.
to
({
x
:
fp
[
0
],
y
:
fp
[
1
]
},
deltaTime
)
.
call
(()
=>
{
//移除遮罩
ele
.
mask
=
null
;
//回收
mask
.
recover
()
})
wait
+=
deltaTime
}
else
{
oriRow
=
ele
.
row
;
tween
=
egret
.
Tween
.
get
(
ele
);
}
let
lastX
:
number
,
lastY
:
number
;
//对所有的indexs进行遍历动画
for
(
var
j
=
0
;
j
<
indexs
.
length
;
j
++
)
{
let
index
=
indexs
[
j
].
index
;
let
type
=
indexs
[
j
].
type
;
let
p
=
Tool
.
getPositionByIndex
(
index
);
if
(
type
==
FallType
.
THROUGH
)
{
let
indexUp
=
this
.
lattices
[
index
].
up
;
let
downPos
=
Tool
.
getPositionByIndex
(
index
);
let
upPos
=
Tool
.
getPositionByIndex
(
indexUp
);
//加遮罩
// let mask11 = Tool.getRectMask();
// mask11.x = indexUp[0];
// mask11.y = indexUp[1];
// ele.mask = mask11;
// this.elementContainer.addChild(mask11);
EleMaskAni
(
ele
,
upPos
,
wait
,
this
.
elementContainer
,
true
);
tween
.
set
({
alpha
:
0
})
.
wait
(
deltaTime
)
.
set
({
alpha
:
1
})
//down位置处的动画
EleMaskAni
(
ele
,
downPos
,
wait
,
this
.
elementContainer
);
//修改oriRow
oriRow
=
Tool
.
indexToRc
(
index
)[
0
];
lastX
=
downPos
[
0
];
lastY
=
downPos
[
1
];
}
else
{
//算间隔
var
delta
=
Tool
.
indexToRc
(
index
)[
0
]
-
oriRow
;
if
(
delta
>
0
)
{
//修改oriRow
oriRow
=
Tool
.
indexToRc
(
index
)[
0
];
//动画
if
(
lastX
!=
null
)
{
tween
.
set
({
x
:
lastX
,
y
:
lastY
})
}
tween
.
to
({
x
:
p
[
0
],
y
:
p
[
1
]
},
delta
*
deltaTime
)
//累计等待时间
wait
+=
delta
*
deltaTime
;
lastX
=
null
}
}
}
//元素赋值,考虑到底放哪好
var
lat
=
this
.
lattices
[
endIndex
];
lat
.
element
=
ele
;
ele
.
fallAni
()
//最终回调
tween
.
call
(()
=>
{
let
endP
=
Tool
.
getPositionByIndex
(
endIndex
);
ele
.
x
=
endP
[
0
];
ele
.
y
=
endP
[
1
];
if
(
ele
.
type
==
ElementType
.
LOLLIPOP
&&
Tool
.
indexToRc
(
endIndex
)[
0
]
==
this
.
endRowNum
)
{
this
.
recoverEle
(
endIndex
);
this
.
lollipopCount
--
;
//通关目标还有棒棒糖,并且,图中不足,下次需要生成
if
(
this
.
passElements
&&
this
.
passElements
[
ElementType
.
LOLLIPOP
]
&&
this
.
lollipopCount
<
this
.
passElements
[
ElementType
.
LOLLIPOP
])
{
this
.
lollipopMark
=
true
}
}
count
++
;
if
(
count
==
countAll
)
{
callback
()
}
})
}
}
/**
* 创建一个掉落元素,
* 逻辑包括棒棒糖逻辑
* 定制掉落元素逻辑
*/
createELement
()
{
var
type
;
if
(
this
.
lollipopMark
)
{
this
.
lollipopMark
=
false
;
type
=
ElementType
.
LOLLIPOP
;
this
.
lollipopCount
++
;
}
else
{
type
=
Tool
.
randomT
(
this
.
chapterData
.
baseElementTypes
)
}
return
Tool
.
getElement
(
type
);
}
/**
* 只关心交换后元素的可消除
* 或者冰淇淋的掉落
...
...
egret/src/something/Tool.ts
View file @
dfb92bdc
...
...
@@ -6,8 +6,11 @@ import { PassType } from "./enum/PassType";
import
{
EffectType
}
from
"./enum/EffectType"
;
import
{
Pool
}
from
"./Pool"
;
import
{
RecoverName
}
from
"./enum/RecoverName"
;
import
{
RectMask
}
from
"./class/RectMask"
;
import
{
FallType
}
from
"./interface/FallAniData"
;
export
class
Tool
{
public
static
latDeltaTime
=
100
;
public
static
rowNum
=
9
;
public
static
colNum
=
9
;
/**
...
...
@@ -715,37 +718,58 @@ export class Tool {
return
arr
}
/**
* 找一个格子,最终掉落点
,
* @param lattice 能掉落的格子
* 找一个格子,最终掉落点
,所有的index吧
* @param lattice 能掉落的格子
,格子上肯定有元素,并且能掉落
* @param empty
* @param lattices
* @return
返回空格数组中的索引
* @return
所有中间点吧数据
*/
public
static
findBottom
(
lattice
:
Lattice
,
emptys
:
number
[],
lattices
:
Lattice
[]):
number
{
let
indexDown
,
lat
;
public
static
findBottom
(
lattice
:
Lattice
,
emptys
:
number
[],
lattices
:
Lattice
[]):
{
index
:
number
,
type
:
FallType
}[]
{
let
indexDown
:
number
,
lat
:
Lattice
;
let
connects
:
{
index
:
number
,
type
:
FallType
}[]
=
[];
let
isThrough
:
boolean
=
false
;
//找下面的
if
(
lattice
.
down
!=
null
)
{
indexDown
=
lattice
.
down
;
isThrough
=
true
;
}
else
{
indexDown
=
lattice
.
index
+
this
.
colNum
;
}
let
lastEmptyIndex
:
number
;
//下方有格子,并且再this.empty中
let
emptyIndex
:
number
=
emptys
.
indexOf
(
indexDown
);
//只要还在里面就一直找下,直到
while
(
emptyIndex
>
-
1
)
{
if
(
isThrough
)
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
THROUGH
});
//记录下上一个满足的
lastEmptyIndex
=
emptyIndex
;
//下面格子变成lat
lat
=
lattices
[
indexDown
];
if
(
lat
.
down
!=
null
)
{
//如果上次是false的,就结束加入
if
(
!
isThrough
)
connects
.
push
({
index
:
indexDown
,
type
:
FallType
.
STRIGHT
});
isThrough
=
true
indexDown
=
lat
.
down
;
}
else
{
isThrough
=
false
indexDown
=
lat
.
index
+
this
.
colNum
;
}
emptyIndex
=
emptys
.
indexOf
(
indexDown
);
}
if
(
lastEmptyIndex
!=
undefined
)
{
return
lastEmptyIndex
//说明已经加过,然后down无空格,直线已加
if
(
isThrough
)
{
return
connects
}
//直线未加
else
{
connects
.
push
({
index
:
emptys
[
lastEmptyIndex
],
type
:
FallType
.
STRIGHT
})
return
connects
}
}
else
{
return
null
}
...
...
@@ -758,11 +782,18 @@ export class Tool {
var
index
=
Tool
.
rcToIndex
(
n
,
m
);
let
lat
=
lattices
[
index
];
if
(
Tool
.
judgeFall
(
lat
))
{
var
emptyIndex
=
Tool
.
findBottom
(
lat
,
emptys
,
lattices
);
var
downIndex
=
emptys
[
emptyIndex
];
if
(
emptyIndex
!=
null
)
{
if
(
(
downIndex
-
index
)
/
Tool
.
colNum
>
1
)
{
var
indexs
=
Tool
.
findBottom
(
lat
,
emptys
,
lattices
);
if
(
indexs
!=
null
)
{
//超过一步,肯定true
if
(
indexs
.
length
>
1
)
{
return
true
;
}
else
{
var
downIndex
:
number
=
indexs
[
0
].
index
;
var
type
:
FallType
=
indexs
[
0
].
type
;
//直线的
if
(
type
==
FallType
.
STRIGHT
&&
(
downIndex
-
index
)
/
Tool
.
colNum
>
1
)
{
return
true
;
}
}
}
}
else
{
...
...
@@ -773,7 +804,12 @@ export class Tool {
var
downIndex
=
index
;
while
(
emptys
.
indexOf
(
downIndex
)
>
-
1
)
{
arr
.
push
(
downIndex
);
downIndex
+=
Tool
.
colNum
;
if
(
lat
.
down
!=
null
)
{
downIndex
=
lat
.
down
;
}
else
{
downIndex
=
lat
.
index
+
this
.
colNum
;
}
lat
=
lattices
[
downIndex
];
}
if
(
arr
.
length
>
1
)
return
true
}
...
...
@@ -830,6 +866,14 @@ export class Tool {
}
return
obj
}
/**
* 获得矩形遮罩
*/
public
static
getRectMask
():
RectMask
{
let
rect
:
RectMask
=
Pool
.
takeOut
(
RecoverName
.
RECT_MASK
);
if
(
!
rect
)
rect
=
new
RectMask
()
return
rect
;
}
/**
* 返回个十百等,0是个位
...
...
egret/src/something/anis/EleMaskAni.ts
0 → 100644
View file @
dfb92bdc
import
{
Tool
}
from
"../Tool"
;
import
{
ElementType
}
from
"../enum/ElementType"
;
import
{
EffectType
}
from
"../enum/EffectType"
;
import
{
Element
}
from
"../class/Element"
;
import
{
Pool
}
from
"../Pool"
;
import
{
RecoverName
}
from
"../enum/RecoverName"
;
/**
* 矩形遮罩的元素动画
* @param eleC
* @param p
* @param con
* @param callback
*/
export
function
EleMaskAni
(
eleC
:
Element
,
p
:
number
[],
wait
:
number
,
con
:
egret
.
DisplayObjectContainer
,
isUp
:
boolean
=
false
,
callback
?:
Function
)
{
let
ele
=
Tool
.
getElement
(
eleC
.
type
);
ele
.
effectType
=
eleC
.
effectType
;
ele
.
x
=
p
[
0
];
ele
.
y
=
p
[
1
]
-
Tool
.
height
*
(
isUp
?
0
:
1
);
let
mask
=
Tool
.
getRectMask
();
mask
.
x
=
p
[
0
];
mask
.
y
=
p
[
1
];
ele
.
mask
=
mask
;
con
.
addChild
(
mask
);
egret
.
Tween
.
get
(
ele
)
.
wait
(
wait
)
.
call
(()
=>
{
con
.
addChild
(
ele
);
})
.
to
({
x
:
p
[
0
],
y
:
p
[
1
]
+
Tool
.
height
*
(
isUp
?
1
:
0
)
},
Tool
.
latDeltaTime
)
.
call
(()
=>
{
//回收元素
con
.
removeChild
(
ele
);
Pool
.
recover
(
RecoverName
.
ELEMENT
,
ele
);
//回收遮罩
ele
.
mask
=
null
;
mask
.
recover
();
//回调
callback
&&
callback
();
})
}
\ No newline at end of file
egret/src/something/class/RectMask.ts
0 → 100644
View file @
dfb92bdc
import
{
Tool
}
from
"../Tool"
;
import
{
Pool
}
from
"../Pool"
;
import
{
RecoverName
}
from
"../enum/RecoverName"
;
/**
* 元素出现及消失用到的矩形遮罩
*/
export
class
RectMask
extends
egret
.
Shape
{
constructor
()
{
super
();
this
.
graphics
.
beginFill
(
0xffffff
);
this
.
graphics
.
beginFill
(
0xff0000
,
1
);
this
.
graphics
.
drawRect
(
-
Tool
.
width
/
2
,
-
Tool
.
height
/
2
,
Tool
.
width
,
Tool
.
height
)
this
.
graphics
.
endFill
();
}
recover
()
{
if
(
this
.
parent
)
{
this
.
parent
.
removeChild
(
this
);
Pool
.
recover
(
RecoverName
.
RECT_MASK
,
this
);
}
}
}
\ No newline at end of file
egret/src/something/enum/RecoverName.ts
View file @
dfb92bdc
...
...
@@ -42,4 +42,7 @@ export enum RecoverName {
STEP_ANI
=
"StepAni"
,
JELLYDIS_ANI
=
"JellyDisAni"
,
EGGBROKEN_ANI
=
"EggBrokenAni"
,
//方形遮罩
RECT_MASK
=
"RectMask"
}
\ No newline at end of file
egret/src/something/interface/FallAniData.ts
0 → 100644
View file @
dfb92bdc
import
{
Element
}
from
"../class/Element"
;
/**
* 掉落动画数据
*/
export
interface
FallAniData
{
/**
* 掉落元素,设为null的时候要生成,并且通过遮罩,生成动画
*/
ele
:
Element
;
/**
* 等待时间,一般用于一个生成口有多个元素排列着的情况
* ele为null才需要wait
*/
wait
?:
number
;
/**
* 起点、中间点及终点的索引,穿过记录下格子,不可能为空
* 索引加类型
*/
indexs
:
{
index
:
number
,
type
:
FallType
}[]
// indexs:number[];
}
export
enum
FallType
{
STRIGHT
=
0
,
THROUGH
,
}
\ No newline at end of file
egret/src/something/interface/PathData.ts
View file @
dfb92bdc
/**
* 路径数据
* 路径数据
,废弃不用
*/
export
interface
PathData
{
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment