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
a8e5c753
Commit
a8e5c753
authored
Oct 26, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
e73267bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
10 deletions
+131
-10
MainScene.ts
egret/src/mainScene/MainScene.ts
+1
-2
HatchAni.ts
egret/src/something/anis/HatchAni.ts
+2
-3
AiControl.ts
egret/src/something/logic/AiControl.ts
+128
-5
No files found.
egret/src/mainScene/MainScene.ts
View file @
a8e5c753
...
...
@@ -1049,8 +1049,7 @@ export default class MainScene extends Scene {
}
fallVerMark
:
boolean
/**
* 修改方法,遍历所有格子,上面的元素进行掉落,
* @param emptys 消除后生成的空格
* 掉落方法还有问题,遇到那种少量垂直元素,只能等垂直元素到底后,才考虑斜落,以后再考虑一边掉落逻辑
* @param callback 所有fall完成后的回调,检查三消,
*/
fall
(
callback
:
Function
)
{
...
...
egret/src/something/anis/HatchAni.ts
View file @
a8e5c753
...
...
@@ -30,8 +30,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
thisObj
.
lattices
[
endIndex
].
element
.
reset
(
ElementType
.
CHICKEN
);
//动画,和bonusTime的效果一样,暂时没加
count
++
;
if
(
count
==
countAll
)
callback
();
if
(
++
count
==
countAll
)
callback
();
})
}
}
...
...
egret/src/something/logic/AiControl.ts
View file @
a8e5c753
...
...
@@ -11,6 +11,7 @@ import { PieceToEggAni } from "../anis/PieceToEggAni";
import
{
StateType
}
from
"../enum/StateType"
;
import
{
BubbleAni
}
from
"../anis/BubbleAni"
;
import
{
Element
}
from
"../class/Element"
;
import
{
HairballBrownState
}
from
"../states/HairballBrownState"
;
//孵鸡的数量
const
chickenNum
:
number
=
4
...
...
@@ -204,8 +205,7 @@ export class AiControl {
activeEgg
.
visible
=
true
;
})
count
++
;
if
(
count
==
countAll
)
{
if
(
++
count
==
countAll
)
{
//做个延时,有节奏感
setTimeout
(()
=>
{
//检测三消,有就执行消除,没有就回调
...
...
@@ -340,11 +340,100 @@ export class AiControl {
callback
();
return
}
//分裂的优先
//跳动的
//唤醒的
let
count
=
0
;
let
countAll
=
(
jumpBallIndexs
.
length
?
1
:
0
)
+
(
awakeBallIndexs
.
length
?
1
:
0
)
+
(
divideBallIndexs
.
length
?
1
:
0
)
let
callbackOperation
=
()
=>
{
if
(
++
count
==
countAll
)
{
setTimeout
(()
=>
{
//检测三消,有就执行消除,没有就回调
if
(
thisObj
.
threeMatch
())
{
thisObj
.
eliminate
();
}
else
{
callback
()
}
},
200
)
}
}
//分裂的优先,因为存在多出状态,不需要多次,按顺序就行
let
countDivide
=
0
;
let
countDivideAll
=
divideBallIndexs
.
length
;
for
(
var
a
=
0
;
a
<
divideBallIndexs
.
length
;
a
++
)
{
let
indexFrom
=
divideBallIndexs
[
a
];
let
elementFrom
:
Element
=
thisObj
.
lattices
[
indexFrom
].
element
;
//判断是否能分裂
let
indexEnd
=
judgeDivide
(
indexFrom
,
thisObj
.
lattices
);
//有执行分裂动画
if
(
indexEnd
!=
null
)
{
//去掉原先的褐色
elementFrom
.
setState
(
StateType
.
HAIRBALLBROWN
,
false
);
//变成灰色毛球
elementFrom
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
let
elementEnd
=
thisObj
.
lattices
[
indexEnd
].
element
;
//变成灰色毛球
elementEnd
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
//动画
setTimeout
(()
=>
{
//都执行了
if
(
++
countDivide
==
countDivideAll
)
callbackOperation
();
},
200
);
}
//没有则执行直接变灰动画
else
{
//去掉原先的褐色
elementFrom
.
setState
(
StateType
.
HAIRBALLBROWN
,
false
);
//变成灰色毛球
elementFrom
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
//动画
setTimeout
(()
=>
{
//都执行了
if
(
++
countDivide
==
countDivideAll
)
callbackOperation
();
},
200
);
}
}
//跳动的,需要考虑尽量都能跳,
let
countJump
=
0
;
let
countJumpAll
=
jumpBallIndexs
.
length
;
for
(
var
a
=
0
;
a
<
jumpBallIndexs
.
length
;
a
++
)
{
let
indexFrom
=
jumpBallIndexs
[
a
];
let
elementFrom
:
Element
=
thisObj
.
lattices
[
indexFrom
].
element
;
//判断是否能分裂
let
indexEnd
=
judgeDivide
(
indexFrom
,
thisObj
.
lattices
);
//有执行分裂动画
if
(
indexEnd
!=
null
)
{
//去掉原先的褐色
elementFrom
.
setState
(
StateType
.
HAIRBALLBROWN
,
false
);
//变成灰色毛球
elementFrom
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
let
elementEnd
=
thisObj
.
lattices
[
indexEnd
].
element
;
//变成灰色毛球
elementEnd
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
//动画
setTimeout
(()
=>
{
//都执行了
if
(
++
countDivide
==
countDivideAll
)
callbackOperation
();
},
200
);
}
//没有则执行直接变灰动画
else
{
//去掉原先的褐色
elementFrom
.
setState
(
StateType
.
HAIRBALLBROWN
,
false
);
//变成灰色毛球
elementFrom
.
setState
(
StateType
.
HAIRBALLGREY
,
true
);
//动画
setTimeout
(()
=>
{
//都执行了
if
(
++
countDivide
==
countDivideAll
)
callbackOperation
();
},
200
);
}
}
//唤醒的
}
}
...
...
@@ -498,6 +587,40 @@ function getBubbleType(index: number, lattices: Lattice[], baseElementTypes: num
return
Tool
.
randomT
(
arr
);
}
/**
* 判断可分裂的方向,并返回分裂终点的格子索引
* 判断和judgeSpread一样,但以防万一,单独写
* @param index
* @return 没有返回null,注意判断时可能有0
*/
function
judgeDivide
(
index
:
number
,
lattices
:
Lattice
[])
{
//四个方向尽量随机
var
arr
=
[
index
-
Tool
.
colNum
,
index
+
Tool
.
colNum
];
var
rc
=
Tool
.
indexToRc
(
index
);
var
col
=
rc
[
1
];
//列数大于0才可能有左边格子
if
(
col
>
0
)
arr
.
push
(
index
-
1
);
//列数不为最右边
if
(
col
<
Tool
.
colNum
-
1
)
arr
.
push
(
index
+
1
);
while
(
arr
.
length
)
{
var
rand
=
Math
.
floor
(
Math
.
random
()
*
arr
.
length
);
var
i
=
arr
.
splice
(
rand
,
1
)[
0
];
if
(
Tool
.
judgeBaseEle
(
lattices
[
i
])
&&
!
lattices
[
i
].
element
.
hasAnyState
())
{
return
i
}
}
return
null
}
/**
* 根据可跳的索引和所有的格子数据,返回
* @param jumpBallIndexs
* @param lattices
*/
function
returnAllJumps
(
jumpBallIndexs
:
number
,
lattices
:
Lattice
[]){
}
...
...
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