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
c7feef76
Commit
c7feef76
authored
Jan 13, 2020
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
abf327ea
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
144 additions
and
38 deletions
+144
-38
MainScene.ts
egret/src/mainScene/MainScene.ts
+27
-5
jellyMonsterAI.ts
egret/src/mainScene/jellyMonsterAI.ts
+76
-0
JellySpreadAni.ts
egret/src/something/anis/JellySpreadAni.ts
+4
-1
Chapter14.ts
egret/src/something/chapters/Chapter14.ts
+20
-28
Element.ts
egret/src/something/class/Element.ts
+11
-1
ElementType.ts
egret/src/something/enum/ElementType.ts
+1
-1
AiControl.ts
egret/src/something/logic/AiControl.ts
+5
-2
No files found.
egret/src/mainScene/MainScene.ts
View file @
c7feef76
...
...
@@ -98,6 +98,7 @@ import { createCandyDis1Ani } from '../something/anis/candy/createCandyDis1Ani';
import
{
createCandyDis2Ani
}
from
'../something/anis/candy/createCandyDis2Ani'
;
import
{
createCandyDis3Ani
}
from
'../something/anis/candy/createCandyDis3Ani'
;
import
{
createCandyDis4Ani
}
from
'../something/anis/candy/createCandyDis4Ani'
;
import
jellyMonsterAI
from
'./jellyMonsterAI'
;
const
aniClass
=
{
"BoomAni"
:
BoomAni
,
...
...
@@ -1965,11 +1966,21 @@ export default class MainScene extends Scene {
}
//消除结束之后检查石门
await
this
.
checkAllBlock
();
//检查糖果
const
candyResult
=
await
this
.
checkAllCandy
();
if
(
candyResult
)
{
if
(
candyResult
)
{
//是不是有融化了的
this
.
eliminate
();
return
};
//果冻怪物
let
jellyMonsterAIResult
=
0
;
if
(
!
this
.
jellyBrokenMark
)
{
jellyMonsterAIResult
=
await
jellyMonsterAI
(
this
);
//0说明怪物没有地方可吐了
console
.
log
(
'干刚才吐了几个'
,
jellyMonsterAIResult
);
if
(
jellyMonsterAIResult
>
0
)
//吐了果冻相当于破了个果冻,那么不再蔓延
this
.
jellyBrokenMark
=
true
;
}
//再检查一次
if
(
this
.
threeMatch
())
{
this
.
eliminate
()
...
...
@@ -2410,10 +2421,13 @@ export default class MainScene extends Scene {
}
//果冻
else
if
(
ele
.
type
==
ElementType
.
JELLY
)
{
this
.
removeJelly
(
index
);
this
.
removeJelly
(
index
,
ele
.
isMonsterJelly
);
//算个数
this
.
goElementTarget
(
ele
.
type
,
[
ele
.
x
,
ele
.
y
]);
}
// else if (ele.type == ElementType.MONSTER_JELLY) {
// this.removeMonsterJelly(index);
// }
//鸡蛋
else
if
(
ele
.
type
==
ElementType
.
CHICKEN_EGG
)
{
//额外逻辑,
...
...
@@ -3019,13 +3033,21 @@ export default class MainScene extends Scene {
* 果冻的移除,包括动效
* @param index
*/
removeJelly
(
index
:
number
)
{
removeJelly
(
index
:
number
,
isMonsterJelly
:
boolean
)
{
this
.
jellyBrokenMark
=
true
;
this
.
removeOperation
(
index
);
//播放动效,果冻的特效,待写
if
(
isMonsterJelly
)
this
.
playAni
(
RecoverName
.
ELEDIS_ANI
,
Tool
.
getPositionByIndex
(
index
))
else
this
.
playAni
(
RecoverName
.
JELLYDIS_ANI
,
Tool
.
getPositionByIndex
(
index
))
}
// removeMonsterJelly(index: number) {
// this.jellyBrokenMark = true;
// this.removeOperation(index);
// this.playAni(RecoverName.ELEDIS_ANI, Tool.getPositionByIndex(index))
// }
//移除小红包,包括动效,还有个数累计等等。发接口,等等
removeFestivalEleSmall
(
index
:
number
)
{
let
ele
=
this
.
removeOperation
(
index
);
...
...
egret/src/mainScene/jellyMonsterAI.ts
0 → 100644
View file @
c7feef76
import
{
Element
}
from
"../something/class/Element"
;
import
{
Lattice
}
from
"../something/class/Lattice"
;
import
{
ElementType
}
from
"../something/enum/ElementType"
;
import
{
Tool
}
from
"../something/Tool"
;
import
MainScene
from
"./MainScene"
;
import
wait
from
"../../libs/new_tc/wait"
;
import
{
AiControl
}
from
"../something/logic/AiControl"
;
export
default
async
(
thisObj
:
MainScene
)
=>
{
//找到所有的怪物
//不用判断石门下是否有果冻
//找出所有果冻索引
var
indexs
:
number
[]
=
[];
for
(
var
i
=
0
;
i
<
thisObj
.
lattices
.
length
;
i
++
)
{
var
lattice
=
thisObj
.
lattices
[
i
]
if
(
lattice
&&
lattice
.
element
&&
lattice
.
element
.
type
==
ElementType
.
JELLY_MONSTER
)
indexs
.
push
(
i
);
}
//获取果冻动画,0是自身索引,1是终点索引
let
spreads
:
number
[][]
=
[];
for
(
const
fromIndex
of
indexs
)
{
var
toIndex
=
judgeActionIndex
(
fromIndex
,
thisObj
.
lattices
);
//考虑0,判断null,有就break
if
(
toIndex
!=
null
)
{
//能蔓延,返回自身索引和蔓延的索引
spreads
.
push
([
fromIndex
,
toIndex
]);
}
}
if
(
spreads
.
length
>
0
)
AiControl
.
ins
.
setHasJelly
(
true
);
await
wait
(
1000
);
for
(
const
spread
of
spreads
)
{
const
[
fromIndex
,
toIndex
]
=
spread
;
//起始元素
const
fromEle
:
Element
=
thisObj
.
lattices
[
fromIndex
].
element
;
//终点元素
const
endEle
:
Element
=
thisObj
.
lattices
[
toIndex
].
element
;
endEle
.
reset
(
ElementType
.
JELLY
);
endEle
.
isMonsterJelly
=
true
;
}
return
spreads
.
length
;
}
/**
* 判断可蔓延的方向,并返回蔓延终点的格子索引
* 判断可分裂的方向,并返回分裂终点的格子索引
* 判断可跳动的方向,并返回跳动终点的格子索引
*
* 4个方向随机,
* 得是基础元素,且无任何状态,可以有特效
* @param index
* @return 没有返回null,注意判断时可能有0
*/
function
judgeActionIndex
(
index
:
number
,
lattices
:
Lattice
[]):
number
{
//四个方向尽量随机
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
);
//随机4个方向
var
i
=
arr
.
splice
(
rand
,
1
)[
0
];
if
(
Tool
.
judgeBaseEle
(
lattices
[
i
])
&&
!
lattices
[
i
].
element
.
hasAnyState
()
&&
!
lattices
[
i
].
element
.
candy
)
{
return
i
}
}
return
null
}
\ No newline at end of file
egret/src/something/anis/JellySpreadAni.ts
View file @
c7feef76
...
...
@@ -36,7 +36,10 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
this
.
addChild
(
this
.
shoot
);
}
play
(
startP
:
number
[],
cloneEle
:
Element
,
callback
:
Function
)
{
play
(
startP
:
number
[],
cloneEle
:
Element
,
callback
:
Function
,
isMonsterJelly
)
{
if
(
isMonsterJelly
)
this
.
targetImage
.
texture
=
RES
.
getRes
(
'ele20_png'
);
this
.
oriImage
.
texture
=
RES
.
getRes
(
'ele20_png'
);
this
.
x
=
startP
[
0
];
this
.
y
=
startP
[
1
];
//终点位置全局先赋值出来,判断用
...
...
egret/src/something/chapters/Chapter14.ts
View file @
c7feef76
This diff is collapsed.
Click to expand it.
egret/src/something/class/Element.ts
View file @
c7feef76
...
...
@@ -35,6 +35,7 @@ import getResPath from "../../../libs/new_tc/getResPath";
export
class
Element
extends
eui
.
Component
{
_mv
;
async
resetMonster
()
{
this
.
changeSource
(
'empty_png'
);
const
mv
:
any
=
await
loadSvga
(
getResPath
()
+
'resource/assets/svgas/monster.svga'
);
this
.
_mv
=
mv
;
this
.
addChild
(
mv
);
...
...
@@ -48,6 +49,15 @@ export class Element extends eui.Component {
this
.
toStandByAction
();
}
private
_isMonsterJelly
:
boolean
;
set
isMonsterJelly
(
val
:
boolean
)
{
this
.
_isMonsterJelly
=
val
;
this
.
changeSource
(
'ele20_png'
)
}
get
isMonsterJelly
()
{
return
this
.
_isMonsterJelly
;
}
toStandByAction
()
{
if
(
!
this
.
_mv
)
return
;
const
mv
=
this
.
_mv
;
...
...
@@ -308,7 +318,7 @@ export class Element extends eui.Component {
changeSource
(
source
:
string
)
{
// this.showImage.source = source;
var
texture
:
egret
.
Texture
=
RES
.
getRes
(
source
);
if
(
!
texture
)
return
;
if
(
!
texture
)
{
return
;}
this
.
showImage
.
texture
=
texture
this
.
showImage
.
x
=
-
texture
.
textureWidth
/
2
;
...
...
egret/src/something/enum/ElementType.ts
View file @
c7feef76
...
...
@@ -36,7 +36,7 @@ export enum ElementType {
CANDY_LION
,
//狮子
CANDY_PIG
,
//猪
MONSTER_JELLY
,
MONSTER_JELLY
1
,
JELLY_MONSTER
,
}
...
...
egret/src/something/logic/AiControl.ts
View file @
c7feef76
...
...
@@ -40,6 +40,7 @@ export class AiControl {
* 判断是否还有果冻,暂时不考虑果冻无中生有,否则逻辑修改
*/
private
hasJelly
:
boolean
;
setHasJelly
(
val
)
{
this
.
hasJelly
=
val
}
/**
* 提前记录所有的鸡蛋的索引,因为鸡蛋数量不会改变
*/
...
...
@@ -265,6 +266,8 @@ export class AiControl {
//对后续有影响的数据必须提交更新,视图不对就隐藏先,动画里加上对应视图,动画播放回调里去掉动画视图,显示数据视图;
//将终点元素变成果冻,,
endEle
.
reset
(
ElementType
.
JELLY
);
if
(
fromEle
.
isMonsterJelly
)
endEle
.
isMonsterJelly
=
true
;
//隐藏元素
fromEle
.
visible
=
false
;
endEle
.
visible
=
false
;
...
...
@@ -277,7 +280,7 @@ export class AiControl {
endEle
.
visible
=
true
;
//执行回调
callback
()
})
}
,
fromEle
.
isMonsterJelly
)
}
/**
* 鸡蛋得孵化逻辑
...
...
@@ -728,7 +731,7 @@ function judgeActionIndex(index: number, lattices: Lattice[]): number {
var
rand
=
Math
.
floor
(
Math
.
random
()
*
arr
.
length
);
var
i
=
arr
.
splice
(
rand
,
1
)[
0
];
if
(
Tool
.
judgeBaseEle
(
lattices
[
i
])
&&
!
lattices
[
i
].
element
.
hasAnyState
())
{
!
lattices
[
i
].
element
.
hasAnyState
()
&&
!
lattices
[
i
].
element
.
candy
)
{
return
i
}
}
...
...
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