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
b9f0340b
Commit
b9f0340b
authored
Oct 26, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
570a98f8
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
827 additions
and
168 deletions
+827
-168
GameGuide.ts
egret/src/mainScene/GameGuide.ts
+5
-5
MainScene.ts
egret/src/mainScene/MainScene.ts
+113
-96
Tool.ts
egret/src/something/Tool.ts
+12
-17
HatchAni.ts
egret/src/something/anis/HatchAni.ts
+1
-1
JellySpreadAni.ts
egret/src/something/anis/JellySpreadAni.ts
+15
-3
Chapter2.ts
egret/src/something/chapters/Chapter2.ts
+459
-2
Element.ts
egret/src/something/class/Element.ts
+32
-2
ElementType.ts
egret/src/something/enum/ElementType.ts
+12
-11
AiControl.ts
egret/src/something/logic/AiControl.ts
+157
-17
HairballBlackState.ts
egret/src/something/states/HairballBlackState.ts
+21
-14
No files found.
egret/src/mainScene/GameGuide.ts
View file @
b9f0340b
...
@@ -293,19 +293,19 @@ const chapterFuns = {
...
@@ -293,19 +293,19 @@ const chapterFuns = {
]
]
},
},
//笼子消除
//笼子消除
2
4
:
{
2
5
:
{
stepCount
:
1
,
stepCount
:
1
,
showIndexs
:
[
showIndexs
:
[
[
40
,
49
,
58
,
50
],
[
0
,
1
,
2
,
3
],
],
],
hideIndexs
:
[
hideIndexs
:
[
[
40
,
58
],
[
0
,
1
],
],
],
handIndexs
:
[
handIndexs
:
[
[
49
,
50
]
[
3
,
2
]
],
],
msg
:
[
msg
:
[
"
被困住的元素无法进行移动,当触发元素
\n
消除时,元素上的藤蔓即可被消除
"
"
和困住藤蔓里的动物匹配
\n
消除,就可以打破藤蔓啦!
"
]
]
},
},
//果冻消除
//果冻消除
...
...
egret/src/mainScene/MainScene.ts
View file @
b9f0340b
This diff is collapsed.
Click to expand it.
egret/src/something/Tool.ts
View file @
b9f0340b
import
{
ChapterData
}
from
"./interface/ChapterData"
;
import
{
ChapterData
}
from
"./interface/ChapterData"
;
import
{
Element
}
from
"./class/Element"
;
import
{
Element
}
from
"./class/Element"
;
import
{
Lattice
}
from
"./class/Lattice"
;
import
{
Lattice
}
from
"./class/Lattice"
;
import
{
ElementType
}
from
"./enum/ElementType"
;
import
{
ElementType
,
FiveBaseElementTypes
}
from
"./enum/ElementType"
;
import
{
PassType
}
from
"./enum/PassType"
;
import
{
PassType
}
from
"./enum/PassType"
;
import
{
EffectType
}
from
"./enum/EffectType"
;
import
{
EffectType
}
from
"./enum/EffectType"
;
import
{
Pool
}
from
"./Pool"
;
import
{
Pool
}
from
"./Pool"
;
...
@@ -16,7 +16,7 @@ export class Tool {
...
@@ -16,7 +16,7 @@ export class Tool {
* 每格掉落时间
* 每格掉落时间
* 掉落速度这个定
* 掉落速度这个定
*/
*/
public
static
latDeltaTime
:
number
=
90
;
public
static
latDeltaTime
:
number
=
90
;
/**
/**
* 总行数
* 总行数
*/
*/
...
@@ -304,21 +304,18 @@ export class Tool {
...
@@ -304,21 +304,18 @@ export class Tool {
/**
/**
* 判断格子上是基础元素,包括各种状态的
* 判断格子上是基础元素,包括各种状态的
*
* @param lat
* @param lat
*/
*/
public
static
judgeBaseEle
(
lat
:
Lattice
)
{
public
static
judgeBaseEle
(
lat
:
Lattice
)
{
//上方格子为null,或格子上元素为null
if
(
lat
&&
if
(
!
lat
||
!
lat
.
element
)
{
lat
.
element
&&
return
false
FiveBaseElementTypes
.
indexOf
(
lat
.
element
.
type
)
>=
0
//在5种基本元素中
}
)
{
//不是基础元素,元素类型枚举01234
else
if
(
lat
.
element
.
type
>
4
)
{
return
false
}
//剩下情况
else
{
return
true
return
true
}
}
return
false
}
}
/**
/**
...
@@ -654,9 +651,7 @@ export class Tool {
...
@@ -654,9 +651,7 @@ export class Tool {
//记录是否有三个格子挨着,且未锁定,没有毛球,这个逻辑略烦,暂定至少都未锁定,有bug再改
//记录是否有三个格子挨着,且未锁定,没有毛球,这个逻辑略烦,暂定至少都未锁定,有bug再改
var
hasThree
=
false
;
var
hasThree
=
false
;
for
(
var
i
=
0
;
i
<
lattices
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
lattices
.
length
;
i
++
)
{
if
(
lattices
[
i
]
&&
if
(
this
.
judgeBaseEle
(
lattices
[
i
])
&&
lattices
[
i
].
element
&&
lattices
[
i
].
element
.
type
<=
4
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
LOCK
)
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
LOCK
)
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
HAIRBALLGREY
)
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
HAIRBALLGREY
)
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
HAIRBALLBLACK
)
&&
!
lattices
[
i
].
element
.
hasState
(
StateType
.
HAIRBALLBLACK
)
&&
...
@@ -938,7 +933,7 @@ export class Tool {
...
@@ -938,7 +933,7 @@ export class Tool {
* 十位是基础元素类型,对应数字减1就是基础元素类型
* 十位是基础元素类型,对应数字减1就是基础元素类型
* 个位是特效类型(0表示无特效),对应数字减1就是特效类型
* 个位是特效类型(0表示无特效),对应数字减1就是特效类型
* @param num
* @param num
* @return [] 0下标是元素类型,1下标是特效类型
* @return [] 0下标是元素类型
(返回null说明不合规则)
,1下标是特效类型
*/
*/
public
static
praseEleNumber
(
num
)
{
public
static
praseEleNumber
(
num
)
{
//解析num;
//解析num;
...
@@ -946,7 +941,7 @@ export class Tool {
...
@@ -946,7 +941,7 @@ export class Tool {
//基础类型,没有就是null,有就-1,对ElementType对应
//基础类型,没有就是null,有就-1,对ElementType对应
var
baseType
=
arr
[
1
]
?
arr
[
1
]
-
1
:
null
;
var
baseType
=
arr
[
1
]
?
arr
[
1
]
-
1
:
null
;
//不是基础类型
//不是基础类型
if
(
baseType
>
4
)
baseType
=
null
;
if
(
FiveBaseElementTypes
.
indexOf
(
baseType
)
==
-
1
)
baseType
=
null
;
//特效类型
//特效类型
var
effectType
=
arr
[
0
]
?
arr
[
0
]
-
1
:
null
;
var
effectType
=
arr
[
0
]
?
arr
[
0
]
-
1
:
null
;
return
[
baseType
,
effectType
];
return
[
baseType
,
effectType
];
...
...
egret/src/something/anis/HatchAni.ts
View file @
b9f0340b
...
@@ -26,7 +26,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
...
@@ -26,7 +26,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
//回收
//回收
thisObj
.
removeChild
(
eleC
);
thisObj
.
removeChild
(
eleC
);
Pool
.
recover
(
RecoverName
.
ELEMENT
,
eleC
);
Pool
.
recover
(
RecoverName
.
ELEMENT
,
eleC
);
//对应的索引的类型变成鸡
//对应的索引的类型变成鸡
,抛物线动画时间都一致,其实可以在统一回调里执行数据更新
thisObj
.
lattices
[
endIndex
].
element
.
reset
(
ElementType
.
CHICKEN
);
thisObj
.
lattices
[
endIndex
].
element
.
reset
(
ElementType
.
CHICKEN
);
//动画,和bonusTime的效果一样,暂时没加
//动画,和bonusTime的效果一样,暂时没加
...
...
egret/src/something/anis/JellySpreadAni.ts
View file @
b9f0340b
...
@@ -4,6 +4,7 @@ import { RecoverName } from "../enum/RecoverName";
...
@@ -4,6 +4,7 @@ import { RecoverName } from "../enum/RecoverName";
import
{
playSound
,
SoundType
}
from
"../../soundCtrl"
;
import
{
playSound
,
SoundType
}
from
"../../soundCtrl"
;
import
{
Tool
}
from
"../Tool"
;
import
{
Tool
}
from
"../Tool"
;
import
{
ElementType
}
from
"../enum/ElementType"
;
import
{
ElementType
}
from
"../enum/ElementType"
;
import
{
Element
}
from
"../class/Element"
;
/**
/**
* 需要回调的
* 需要回调的
...
@@ -18,7 +19,7 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
...
@@ -18,7 +19,7 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
shoot
:
egret
.
Bitmap
;
shoot
:
egret
.
Bitmap
;
constructor
()
{
constructor
()
{
super
()
super
()
var
texture
:
egret
.
Texture
=
RES
.
getRes
(
"ele"
+
ElementType
.
JELLY
+
"_png"
)
var
texture
:
egret
.
Texture
=
RES
.
getRes
(
"ele"
+
ElementType
.
JELLY
+
"_png"
)
this
.
targetImage
=
new
egret
.
Bitmap
(
texture
);
this
.
targetImage
=
new
egret
.
Bitmap
(
texture
);
this
.
targetImage
.
anchorOffsetX
=
texture
.
textureWidth
/
2
;
this
.
targetImage
.
anchorOffsetX
=
texture
.
textureWidth
/
2
;
this
.
targetImage
.
anchorOffsetY
=
texture
.
textureHeight
/
2
;
this
.
targetImage
.
anchorOffsetY
=
texture
.
textureHeight
/
2
;
...
@@ -35,9 +36,14 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
...
@@ -35,9 +36,14 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
this
.
addChild
(
this
.
shoot
);
this
.
addChild
(
this
.
shoot
);
}
}
play
(
startP
:
number
[],
endP
:
number
[]
,
callback
:
Function
)
{
play
(
startP
:
number
[],
cloneEle
:
Element
,
callback
:
Function
)
{
this
.
x
=
startP
[
0
];
this
.
x
=
startP
[
0
];
this
.
y
=
startP
[
1
];
this
.
y
=
startP
[
1
];
//终点位置全局先赋值出来,判断用
var
endP
=
[
cloneEle
.
x
,
cloneEle
.
y
];
//添加进
this
.
addChildAt
(
cloneEle
,
0
);
this
.
shoot
.
visible
=
true
;
this
.
shoot
.
visible
=
true
;
this
.
shoot
.
x
=
0
this
.
shoot
.
x
=
0
...
@@ -80,7 +86,9 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
...
@@ -80,7 +86,9 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
obj
.
x
=
-
Tool
.
width
;
obj
.
x
=
-
Tool
.
width
;
}
}
}
}
//cloneEle的位置赋值
cloneEle
.
x
=
this
.
targetImage
.
x
;
cloneEle
.
y
=
this
.
targetImage
.
y
;
egret
.
Tween
.
get
(
this
.
oriImage
)
egret
.
Tween
.
get
(
this
.
oriImage
)
.
to
({
scaleX
:
1.07
,
scaleY
:
0.89
},
150
)
.
to
({
scaleX
:
1.07
,
scaleY
:
0.89
},
150
)
...
@@ -94,6 +102,10 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
...
@@ -94,6 +102,10 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
.
to
({
scaleX
:
2
,
scaleY
:
1
},
230
)
.
to
({
scaleX
:
2
,
scaleY
:
1
},
230
)
.
to
(
obj
,
50
)
.
to
(
obj
,
50
)
.
call
(()
=>
{
.
call
(()
=>
{
//回收克隆元素
this
.
removeChild
(
cloneEle
);
Pool
.
recover
(
RecoverName
.
ELEMENT
,
cloneEle
)
//回调
callback
();
callback
();
this
.
shoot
.
visible
=
false
;
this
.
shoot
.
visible
=
false
;
this
.
targetImage
.
visible
=
true
;
this
.
targetImage
.
visible
=
true
;
...
...
egret/src/something/chapters/Chapter2.ts
View file @
b9f0340b
This diff is collapsed.
Click to expand it.
egret/src/something/class/Element.ts
View file @
b9f0340b
...
@@ -15,6 +15,7 @@ import { HairballBrownState } from "../states/HairballBrownState";
...
@@ -15,6 +15,7 @@ import { HairballBrownState } from "../states/HairballBrownState";
import
{
BubbleState
}
from
"../states/BubbleState"
;
import
{
BubbleState
}
from
"../states/BubbleState"
;
import
{
HairballGreyState
}
from
"../states/HairballGreyState"
;
import
{
HairballGreyState
}
from
"../states/HairballGreyState"
;
import
{
HairballBlackState
}
from
"../states/HairballBlackState"
;
import
{
HairballBlackState
}
from
"../states/HairballBlackState"
;
import
{
Tool
}
from
"../Tool"
;
/**
/**
...
@@ -124,10 +125,14 @@ export class Element extends eui.Component {
...
@@ -124,10 +125,14 @@ export class Element extends eui.Component {
/**
/**
* 所有的状态,注意,变色气泡特殊,不能和特效共存,所以初始化时,气泡的不能加特效。生成特效,去掉气泡
* 所有的状态,注意,变色气泡特殊,不能和特效共存,所以初始化时,气泡的不能加特效。生成特效,去掉气泡
* 索引必须按枚举
* 索引必须按
StateType的
枚举
*/
*/
private
states
:
State
[]
=
[]
private
states
:
State
[]
=
[]
/**
*
* @param type 只应该是基础元素和特殊元素
*/
constructor
(
type
:
ElementType
)
{
constructor
(
type
:
ElementType
)
{
super
();
super
();
this
.
_type
=
type
;
this
.
_type
=
type
;
...
@@ -170,7 +175,7 @@ export class Element extends eui.Component {
...
@@ -170,7 +175,7 @@ export class Element extends eui.Component {
/**
/**
* 会重置掉所有特效类型,枷锁,鸡蛋等
* 会重置掉所有特效类型,枷锁,鸡蛋等
* @param type
* @param type
只应该是基础元素和特殊元素
*/
*/
reset
(
type
:
ElementType
)
{
reset
(
type
:
ElementType
)
{
this
.
alpha
=
this
.
scaleX
=
this
.
scaleY
=
1
;
this
.
alpha
=
this
.
scaleX
=
this
.
scaleY
=
1
;
...
@@ -229,6 +234,7 @@ export class Element extends eui.Component {
...
@@ -229,6 +234,7 @@ export class Element extends eui.Component {
/**
/**
* 只修改类型,不改变其他状态
* 只修改类型,不改变其他状态
* @param type 只应该是基础元素和特殊元素
*/
*/
resetType
(
type
:
ElementType
)
{
resetType
(
type
:
ElementType
)
{
//如果重置成特殊元素,或鸡蛋,或石头,或果冻,或棒棒糖,直接用reset方法
//如果重置成特殊元素,或鸡蛋,或石头,或果冻,或棒棒糖,直接用reset方法
...
@@ -408,4 +414,28 @@ export class Element extends eui.Component {
...
@@ -408,4 +414,28 @@ export class Element extends eui.Component {
getState
(
state
:
StateType
):
any
{
getState
(
state
:
StateType
):
any
{
return
this
.
states
[
state
]
return
this
.
states
[
state
]
}
}
/**
* 克隆一个
* 类型
* 特效
* 状态
* 位置
*/
clone
():
Element
{
let
ele
=
Tool
.
getElement
(
this
.
type
);
//特效加上
ele
.
effectType
=
this
.
effectType
;
//状态加上
for
(
var
i
=
0
;
i
<
this
.
states
.
length
;
i
++
)
{
let
state
=
this
.
states
[
i
];
if
(
!
state
)
continue
;
ele
.
setState
(
i
,
true
,
this
.
type
)
}
//位置信息
ele
.
x
=
this
.
x
;
ele
.
y
=
this
.
y
;
return
ele
}
}
}
\ No newline at end of file
egret/src/something/enum/ElementType.ts
View file @
b9f0340b
/**
/**
* 元素类型 <=4就是基础元素
* 元素类型 <=4就是基础元素
*
*
枚举尽量从后面添加,否则要改很多东西,submitTran重新对应,ele图片重新对应,开始弹框目标实现等等,没改全后果自负
* 修改索引时,需要修改ele的图片,和通关目标类。飞入特效类
* 修改索引时,需要修改ele的图片,和通关目标类。飞入特效类
*/
*/
export
enum
ElementType
{
export
enum
ElementType
{
...
@@ -26,17 +26,18 @@ export enum ElementType {
...
@@ -26,17 +26,18 @@ export enum ElementType {
HAIRBALLBROWN
,
//褐色毛球11
HAIRBALLBROWN
,
//褐色毛球11
HAIRBALLBLACK
,
//黑色毛球12
HAIRBALLBLACK
,
//黑色毛球12
}
}
var
a
=
[
0
,
40
,
30
,
0
,
44
,
0
,
20
,
40
,
0
,
/**
0
,
20
,
20
,
0
,
40
,
0
,
50
,
50
,
0
,
* 5种基本元素的数组,每项是ElementType的枚举值
0
,
30
,
50
,
0
,
3
,
0
,
20
,
30
,
0
,
*/
0
,
10
,
0
,
0
,
0
,
0
,
0
,
20
,
0
,
export
const
FiveBaseElementTypes
:
ElementType
[]
=
[
0
,
50
,
40
,
0
,
0
,
0
,
10
,
30
,
0
,
ElementType
.
RABBIT
,
30
,
10
,
30
,
50
,
0
,
40
,
50
,
50
,
20
,
ElementType
.
CHICKEN
,
0
,
50
,
40
,
30
,
50
,
20
,
10
,
40
,
0
,
ElementType
.
CATTLE
,
0
,
0
,
10
,
10
,
3
,
30
,
50
,
0
,
0
,
ElementType
.
LION
,
0
,
0
,
0
,
30
,
50
,
40
,
0
,
0
,
0
,
ElementType
.
PIG
,
]
]
export
const
codeMsgs
=
{
export
const
codeMsgs
=
{
"E1002090011"
:
"用户关卡记录异常"
,
"E1002090011"
:
"用户关卡记录异常"
,
"E1002090012"
:
"暂不能挑战此关卡"
,
"E1002090012"
:
"暂不能挑战此关卡"
,
...
...
egret/src/something/logic/AiControl.ts
View file @
b9f0340b
...
@@ -10,12 +10,16 @@ import { HatchAni } from "../anis/HatchAni";
...
@@ -10,12 +10,16 @@ import { HatchAni } from "../anis/HatchAni";
import
{
PieceToEggAni
}
from
"../anis/PieceToEggAni"
;
import
{
PieceToEggAni
}
from
"../anis/PieceToEggAni"
;
import
{
StateType
}
from
"../enum/StateType"
;
import
{
StateType
}
from
"../enum/StateType"
;
import
{
BubbleAni
}
from
"../anis/BubbleAni"
;
import
{
BubbleAni
}
from
"../anis/BubbleAni"
;
import
{
Element
}
from
"../class/Element"
;
//孵鸡的数量
//孵鸡的数量
const
chickenNum
:
number
=
4
const
chickenNum
:
number
=
4
export
class
AiControl
{
export
class
AiControl
{
private
static
_ins
:
AiControl
private
static
_ins
:
AiControl
/**
* 只实例一次,所以不能直接把thisObj干进来,每个方法里带吧
*/
static
get
ins
()
{
static
get
ins
()
{
return
AiControl
.
_ins
||
(
AiControl
.
_ins
=
new
AiControl
())
return
AiControl
.
_ins
||
(
AiControl
.
_ins
=
new
AiControl
())
}
}
...
@@ -32,7 +36,7 @@ export class AiControl {
...
@@ -32,7 +36,7 @@ export class AiControl {
*/
*/
private
hasBubble
:
boolean
;
private
hasBubble
:
boolean
;
/**
/**
* 判断是否还有毛球,暂时不考虑毛球能再生
* 判断是否还有毛球,暂时不考虑毛球能再生
,以后可能改能掉落毛球,再说
*/
*/
private
hasHairball
:
boolean
;
private
hasHairball
:
boolean
;
...
@@ -102,16 +106,28 @@ export class AiControl {
...
@@ -102,16 +106,28 @@ export class AiControl {
jellySpreadAni
=
new
JellySpreadAni
()
jellySpreadAni
=
new
JellySpreadAni
()
}
}
thisObj
.
addChild
(
jellySpreadAni
);
thisObj
.
addChild
(
jellySpreadAni
);
//隐藏原来的元素
//起始元素
thisObj
.
lattices
[
spread
[
0
]].
element
.
visible
=
false
;
let
fromEle
:
Element
=
thisObj
.
lattices
[
spread
[
0
]].
element
;
jellySpreadAni
.
play
(
Tool
.
getPositionByIndex
(
spread
[
0
]),
Tool
.
getPositionByIndex
(
spread
[
1
]),
()
=>
{
//终点元素
//显示隐藏元素
let
endEle
:
Element
=
thisObj
.
lattices
[
spread
[
1
]].
element
;
thisObj
.
lattices
[
spread
[
0
]].
element
.
visible
=
true
;
//克隆一个终点元素
//播放完后,将终点元素变成果冻
let
cloneEle
:
Element
=
endEle
.
clone
();
thisObj
.
lattices
[
spread
[
1
]].
element
.
reset
(
ElementType
.
JELLY
);
//对后续有影响的数据必须提交更新,视图不对就隐藏先,动画里加上对应视图,动画播放回调里去掉动画视图,显示数据视图;
//执行回调
//将终点元素变成果冻,,
callback
()
endEle
.
reset
(
ElementType
.
JELLY
);
})
//隐藏元素
fromEle
.
visible
=
false
;
endEle
.
visible
=
false
;
jellySpreadAni
.
play
(
Tool
.
getPositionByIndex
(
spread
[
0
]),
cloneEle
,
()
=>
{
//显示隐藏元素
fromEle
.
visible
=
true
;
endEle
.
visible
=
true
;
//执行回调
callback
()
})
}
}
/**
/**
* 鸡蛋得孵化逻辑
* 鸡蛋得孵化逻辑
...
@@ -171,6 +187,7 @@ export class AiControl {
...
@@ -171,6 +187,7 @@ export class AiControl {
//补上剩下的,如果还不足,就不管
//补上剩下的,如果还不足,就不管
four
=
four
.
concat
(
Tool
.
getRandomArrayElementsEx
(
chickenIndexs
,
chickenNum
-
four
.
length
))
four
=
four
.
concat
(
Tool
.
getRandomArrayElementsEx
(
chickenIndexs
,
chickenNum
-
four
.
length
))
}
}
//四个元素变成鸡的数据更新在动画播放完的函数里执行,暂时对数据无影响,延后更新数据无妨
//播蛋壳动画
//播蛋壳动画
let
activeEgg
=
thisObj
.
lattices
[
activeEggIndex
].
element
.
chickenEgg
;
let
activeEgg
=
thisObj
.
lattices
[
activeEggIndex
].
element
.
chickenEgg
;
activeEgg
.
visible
=
false
;
activeEgg
.
visible
=
false
;
...
@@ -215,12 +232,12 @@ export class AiControl {
...
@@ -215,12 +232,12 @@ export class AiControl {
callback
();
callback
();
return
return
}
}
//找出所有的气泡
//找出所有的气泡
,必须按顺序,从左到右,从上到下
var
indexs
:
number
[]
=
[];
var
indexs
:
number
[]
=
[];
for
(
var
i
=
0
;
i
<
thisObj
.
lattices
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
thisObj
.
lattices
.
length
;
i
++
)
{
var
lat
=
thisObj
.
lattices
[
i
];
var
lat
=
thisObj
.
lattices
[
i
];
//是基础元素,有气泡状态
//是基础元素,有气泡状态
if
(
Tool
.
judgeBaseEle
(
lat
)
&&
!
lat
.
element
.
hasState
(
StateType
.
BUBBLE
))
{
if
(
Tool
.
judgeBaseEle
(
lat
)
&&
lat
.
element
.
hasState
(
StateType
.
BUBBLE
))
{
indexs
.
push
(
i
);
indexs
.
push
(
i
);
}
}
}
}
...
@@ -240,8 +257,8 @@ export class AiControl {
...
@@ -240,8 +257,8 @@ export class AiControl {
let
ele
=
lat
.
element
;
let
ele
=
lat
.
element
;
let
fromType
=
ele
.
type
;
let
fromType
=
ele
.
type
;
//计算type
//计算type
let
type
:
ElementType
=
1
;
let
type
:
ElementType
=
getBubbleType
(
index
,
thisObj
.
lattices
,
thisObj
.
chapterData
.
baseElementTypes
)
;
//直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示
//直接重置类型,为了后续计算
泡泡类型
,但是要隐藏,待动画播放完显示
ele
.
resetType
(
type
);
ele
.
resetType
(
type
);
ele
.
visible
=
false
;
ele
.
visible
=
false
;
//变色动画
//变色动画
...
@@ -265,6 +282,70 @@ export class AiControl {
...
@@ -265,6 +282,70 @@ export class AiControl {
})
})
}
}
}
}
/**
* 跳动,以及褐色毛球的分裂
* 黑色毛球眩晕不执行跳动,不过结束后要重置为不眩晕状态,和callback同步执行
* @param thisObj
* @param callback
*/
hairballMotion
(
thisObj
:
MainScene
,
callback
:
Function
)
{
//没有毛球。直接回调
if
(
!
this
.
hasHairball
)
{
callback
();
return
}
//找出所有能跳动的毛球;
var
jumpBallIndexs
:
number
[]
=
[];
//即将唤醒的黑色毛球
var
awakeBallIndexs
:
number
[]
=
[];
//即将分裂的褐色毛球
var
divideBallIndexs
:
number
[]
=
[];
for
(
var
i
=
0
;
i
<
thisObj
.
lattices
.
length
;
i
++
)
{
var
lat
=
thisObj
.
lattices
[
i
];
//是基础元素
if
(
Tool
.
judgeBaseEle
(
lat
))
{
//灰色直接进跳动
if
(
lat
.
element
.
hasState
(
StateType
.
HAIRBALLGREY
))
{
jumpBallIndexs
.
push
(
i
);
}
//黑色
if
(
lat
.
element
.
hasState
(
StateType
.
HAIRBALLBLACK
))
{
//醒着的跳动
if
(
lat
.
element
.
getState
(
StateType
.
HAIRBALLBLACK
).
isAwake
)
{
jumpBallIndexs
.
push
(
i
);
}
//晕着的即将醒
else
{
awakeBallIndexs
.
push
(
i
);
}
}
//褐色
if
(
lat
.
element
.
hasState
(
StateType
.
HAIRBALLBROWN
))
{
//激活的即将分裂
if
(
lat
.
element
.
getState
(
StateType
.
HAIRBALLBROWN
).
isActive
)
{
divideBallIndexs
.
push
(
i
);
}
//未激活的跳动
else
{
jumpBallIndexs
.
push
(
i
);
}
};
}
}
//没有毛球,直接回调,
if
(
!
jumpBallIndexs
.
length
&&
!
awakeBallIndexs
.
length
&&
!
divideBallIndexs
.
length
)
{
//标记无毛球
this
.
hasHairball
=
false
;
callback
();
return
}
//分裂的优先
//跳动的
//唤醒的
}
}
}
/**
/**
...
@@ -282,7 +363,7 @@ function judgeJellyExist(lattices: Lattice[]) {
...
@@ -282,7 +363,7 @@ function judgeJellyExist(lattices: Lattice[]) {
return
false
;
return
false
;
}
}
/**
/**
* 判断毛球是否存在
* 判断毛球是否存在
,甭管什么毛球
* @param lattices
* @param lattices
*/
*/
function
judgeHairballExist
(
lattices
:
Lattice
[])
{
function
judgeHairballExist
(
lattices
:
Lattice
[])
{
...
@@ -355,8 +436,67 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
...
@@ -355,8 +436,67 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
}
}
return
null
return
null
}
}
/**
* 获得气泡变化类型
* @param index 变化的格子索引
* @param lattices 所有格子
* @param baseElementTypes 可选基础类型
*/
function
getBubbleType
(
index
:
number
,
lattices
:
Lattice
[],
baseElementTypes
:
number
[]):
ElementType
{
//变色,只取基础类型
var
rc
=
Tool
.
indexToRc
(
index
);
var
arr
=
baseElementTypes
.
slice
();
let
operation
=
(
lat1
:
Lattice
,
lat2
:
Lattice
)
=>
{
//必须是都可匹配的
if
(
Tool
.
judgeMatch
(
lat1
)
&&
Tool
.
judgeMatch
(
lat2
)
&&
lat1
.
element
.
type
==
lat2
.
element
.
type
)
{
Tool
.
removeEle
(
lat1
.
element
.
type
,
arr
);
}
}
//和左边两个比较
if
(
rc
[
1
]
>
1
)
operation
(
lattices
[
index
-
1
],
lattices
[
index
-
2
])
//和上边两个比较
if
(
rc
[
0
]
>
1
)
operation
(
lattices
[
index
-
Tool
.
colNum
],
lattices
[
index
-
Tool
.
colNum
*
2
])
//下面的比较都要忽略因为顺序从小到大,所以忽略带气泡状态的,
//与左右边两个比较,不能是第一列和最后一列
if
(
rc
[
1
]
>
0
&&
rc
[
1
]
<
Tool
.
colNum
-
1
)
{
let
lat1
=
lattices
[
index
-
1
];
let
lat2
=
lattices
[
index
+
1
];
//右边的格子,不能有气泡,有气泡就不用去判断了
if
(
Tool
.
judgeMatch
(
lat2
)
&&
!
lat2
.
element
.
hasState
(
StateType
.
BUBBLE
))
operation
(
lat1
,
lat2
)
}
//与上下两个比较,不能是第一行和最后一行
if
(
rc
[
0
]
>
0
&&
rc
[
0
]
<
Tool
.
rowNum
-
1
)
{
let
lat1
=
lattices
[
index
-
Tool
.
colNum
];
let
lat2
=
lattices
[
index
+
Tool
.
colNum
];
//下边的格子,不能有气泡,有气泡就不用去判断了
if
(
Tool
.
judgeMatch
(
lat2
)
&&
!
lat2
.
element
.
hasState
(
StateType
.
BUBBLE
))
operation
(
lat1
,
lat2
)
}
// function getBubble
//右二或下二的判断操作
let
operationAdd
=
(
lat1
:
Lattice
,
lat2
:
Lattice
)
=>
{
if
(
Tool
.
judgeMatch
(
lat1
)
&&
Tool
.
judgeMatch
(
lat2
)
&&
!
lat1
.
element
.
hasState
(
StateType
.
BUBBLE
)
&&
!
lat2
.
element
.
hasState
(
StateType
.
BUBBLE
)
&&
lat1
.
element
.
type
==
lat2
.
element
.
type
)
{
Tool
.
removeEle
(
lat1
.
element
.
type
,
arr
);
}
}
//与右边两个比较
if
(
rc
[
1
]
<
Tool
.
colNum
-
2
)
operationAdd
(
lattices
[
index
+
1
],
lattices
[
index
+
2
]);
//与下边两个比较
if
(
rc
[
0
]
<
Tool
.
colNum
-
2
)
operationAdd
(
lattices
[
index
+
Tool
.
colNum
],
lattices
[
index
+
Tool
.
colNum
*
2
]);
//如果没有可选,返回自身的类型,动画还是要放的
if
(
!
arr
.
length
)
return
lattices
[
index
].
element
.
type
;
//随机一个
return
Tool
.
randomT
(
arr
);
}
...
...
egret/src/something/states/HairballBlackState.ts
View file @
b9f0340b
...
@@ -7,35 +7,42 @@ import { ElementType } from "../enum/ElementType";
...
@@ -7,35 +7,42 @@ import { ElementType } from "../enum/ElementType";
/**
/**
* 黑色毛球状态
* 黑色毛球状态
* 两次消除,需要修改图片,,,再说,还没写
* 两次消除,需要修改图片,,,再说,还没写
,切换眩晕状态,是否有动画,都再说
*/
*/
export
class
HairballBlackState
extends
State
{
export
class
HairballBlackState
extends
State
{
private
showImage
:
egret
.
Bitmap
;
private
showImage
:
egret
.
Bitmap
;
/**
/**
* 是否激活
* 是否激活
*/
*/
isActive
:
boolean
;
_isAwake
:
boolean
;
get
isAwake
():
boolean
{
return
this
.
_isAwake
;
}
set
isAwake
(
value
:
boolean
)
{
this
.
_isAwake
=
value
;
//换图
}
constructor
()
{
constructor
()
{
super
();
super
();
var
texture
:
egret
.
Texture
=
RES
.
getRes
(
"ele"
+
ElementType
.
HAIRBALLBLACK
+
"_png"
)
this
.
showImage
=
new
egret
.
Bitmap
();
this
.
showImage
=
new
egret
.
Bitmap
(
texture
);
this
.
addChild
(
this
.
showImage
);
this
.
addChild
(
this
.
showImage
);
this
.
showImage
.
x
=
-
texture
.
textureWidth
/
2
;
this
.
changeSource
(
"ele"
+
ElementType
.
HAIRBALLBLACK
+
"_png"
)
this
.
showImage
.
y
=
-
texture
.
textureHeight
/
2
;
this
.
_isAwake
=
true
;
this
.
isActive
=
false
;
}
}
reset
()
{
reset
()
{
this
.
isActive
=
false
;
this
.
_isAwake
=
true
;
//换图
this
.
changeSource
(
"ele"
+
ElementType
.
HAIRBALLBLACK
+
"_png"
)
}
}
recover
()
{
recover
()
{
if
(
this
.
parent
)
this
.
parent
.
removeChild
(
this
);
if
(
this
.
parent
)
this
.
parent
.
removeChild
(
this
);
Pool
.
recover
(
RecoverName
.
HAIRBALLBLACK_STATE
,
this
);
Pool
.
recover
(
RecoverName
.
HAIRBALLBLACK_STATE
,
this
);
}
}
//
private changeSource(source: string) {
private
changeSource
(
source
:
string
)
{
//
var texture: egret.Texture = RES.getRes(source);
var
texture
:
egret
.
Texture
=
RES
.
getRes
(
source
);
//
this.showImage.texture = texture;
this
.
showImage
.
texture
=
texture
;
//
this.showImage.x = -texture.textureWidth / 2;
this
.
showImage
.
x
=
-
texture
.
textureWidth
/
2
;
//
this.showImage.y = -texture.textureHeight / 2
this
.
showImage
.
y
=
-
texture
.
textureHeight
/
2
//
}
}
}
}
\ No newline at end of file
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