Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
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
劳工
zeroing-libs
Commits
9d869388
Commit
9d869388
authored
Aug 04, 2020
by
zjz1994
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工行消消乐还原
parent
e29e32b9
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
249 additions
and
427 deletions
+249
-427
main.js
src/custom/xiaoxiaole/debug/main.js
+118
-181
main.js.map
src/custom/xiaoxiaole/debug/main.js.map
+1
-1
meta.json
src/custom/xiaoxiaole/meta.json
+17
-17
GameView.ts
src/custom/xiaoxiaole/src/game/GameView.ts
+54
-169
MapData.ts
src/custom/xiaoxiaole/src/game/MapData.ts
+57
-59
Element.ts
src/custom/xiaoxiaole/src/game/ele/Element.ts
+2
-0
No files found.
src/custom/xiaoxiaole/debug/main.js
View file @
9d869388
This diff is collapsed.
Click to expand it.
src/custom/xiaoxiaole/debug/main.js.map
View file @
9d869388
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/xiaoxiaole/meta.json
View file @
9d869388
...
@@ -21,43 +21,43 @@
...
@@ -21,43 +21,43 @@
"assets"
:
[
"assets"
:
[
{
{
"name"
:
"底图"
,
"name"
:
"底图"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
d2b599cece087d5ab315cd1392f94139941280bb
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
109e30fa662276e0ee4f2e2c35b85bee6f300050
.png"
,
"uuid"
:
"map"
,
"uuid"
:
"map"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"
狗
"
,
"name"
:
"
白虎
"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
26780d2fb48d047e111857da9e82fe49b0d310a8
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
b486b4a72c58850bbd1930b994e08802e34fb3e3
.png"
,
"uuid"
:
"
gdog
"
,
"uuid"
:
"
btiger
"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"
鸟
"
,
"name"
:
"
雌虎
"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
39a1a8865ca101d6fa29325bf1fc37c26190e382
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
c41afceb285432ed2c17c643df96efc20893adc8
.png"
,
"uuid"
:
"
pbird
"
,
"uuid"
:
"
gtiger
"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"
牛
"
,
"name"
:
"
猴子
"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
2e74dd7faab031f71e644dad340b4c83791b8bf0
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
ef7bc5d1fc38267adba71e07d517330f249d23ba
.png"
,
"uuid"
:
"
hniu
"
,
"uuid"
:
"
monkey
"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"
兔子
"
,
"name"
:
"
鸟
"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
6c4033a865bc6c73b680bc31d29de55ac347d397
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
9ad18dfa34e1729e9893ac362975f9e062263f70
.png"
,
"uuid"
:
"b
ribbit
"
,
"uuid"
:
"b
ird
"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"
猪
"
,
"name"
:
"
树熊
"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
c14e003bb3847bd7ab30eb6ba0915124f207bc31
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
277aa43d9f1bf3dd7a18e627335a166f0509684c
.png"
,
"uuid"
:
"
rpig
"
,
"uuid"
:
"
koala
"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
{
{
"name"
:
"选中框"
,
"name"
:
"选中框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
c6ed5f3f94958e74fcbfc1da56e99795056fd75a
.png"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
a3ce52a41ed53ccfa7ce404dbc10102961c4a805
.png"
,
"uuid"
:
"selected"
,
"uuid"
:
"selected"
,
"ext"
:
".png"
"ext"
:
".png"
},
},
...
...
src/custom/xiaoxiaole/src/game/GameView.ts
View file @
9d869388
...
@@ -31,12 +31,10 @@ export default class GameView extends engine.Container {
...
@@ -31,12 +31,10 @@ export default class GameView extends engine.Container {
//选中
//选中
selectArr
=
[];
selectArr
=
[];
selectimg
:
engine
.
Image
;
selectimg
:
engine
.
Image
;
selectw
:
number
;
selecth
:
number
;
//屋子
//屋子
//
homeimgday;
homeimgday
;
//
homeimgnight;
homeimgnight
;
conty
=
140
;
conty
=
140
;
homex
=
562
;
homex
=
562
;
...
@@ -75,8 +73,6 @@ export default class GameView extends engine.Container {
...
@@ -75,8 +73,6 @@ export default class GameView extends engine.Container {
level
=
0
;
level
=
0
;
inrecord
=
false
;
inrecord
=
false
;
requestGameOver
=
false
;
requestGameOver
=
false
;
elitype
=
1
;
//1原地消失,2飞到目标位置
set
gamestat
(
stat
){
//1游戏中,2,游戏外
set
gamestat
(
stat
){
//1游戏中,2,游戏外
this
.
_gamestat
=
stat
;
this
.
_gamestat
=
stat
;
if
(
stat
==
2
){
if
(
stat
==
2
){
...
@@ -96,18 +92,12 @@ export default class GameView extends engine.Container {
...
@@ -96,18 +92,12 @@ export default class GameView extends engine.Container {
sptime
=
Date
.
now
();
sptime
=
Date
.
now
();
eptime
;
eptime
;
seqscore
;
seqscore
;
//使用炸弹
useBoom
:
boolean
=
false
;
setup
()
{
setup
()
{
MapData
.
initPoolEle
();
MapData
.
initPoolEle
();
this
.
selectimg
=
new
engine
.
Image
(
getTextureByName
(
"选中框"
));
this
.
selectimg
=
new
engine
.
Image
(
getTextureByName
(
"选中框"
));
this
.
selectimg
.
mouseEnabled
=
false
;
this
.
selectimg
.
mouseEnabled
=
false
;
this
.
selectw
=
this
.
selectimg
.
texture
.
width
;
this
.
selecth
=
this
.
selectimg
.
texture
.
height
;
this
.
selectimg
.
anchorX
=
this
.
selectw
/
2
;
this
.
selectimg
.
anchorY
=
this
.
selecth
/
2
;
//箭头cont
//箭头cont
this
.
jiantou1
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
this
.
jiantou1
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
...
@@ -153,21 +143,21 @@ export default class GameView extends engine.Container {
...
@@ -153,21 +143,21 @@ export default class GameView extends engine.Container {
let
row
=
MapData
.
row
;
let
row
=
MapData
.
row
;
let
col
=
MapData
.
col
;
let
col
=
MapData
.
col
;
//
this.homeimgday = createSvga("房子动画");
this
.
homeimgday
=
createSvga
(
"房子动画"
);
//
this.homeimgday.x = this.homex;
this
.
homeimgday
.
x
=
this
.
homex
;
//
this.homeimgday.y = this.homey;
this
.
homeimgday
.
y
=
this
.
homey
;
//
this.homeimgday.stop();
this
.
homeimgday
.
stop
();
//
this.homeimgday.visible = false;
this
.
homeimgday
.
visible
=
false
;
//
this.addChild(this.homeimgday);
this
.
addChild
(
this
.
homeimgday
);
//
this.homeimgnight = createSvga("夜晚房子");
this
.
homeimgnight
=
createSvga
(
"夜晚房子"
);
//
this.homeimgnight.x = this.homex;
this
.
homeimgnight
.
x
=
this
.
homex
;
//
this.homeimgnight.y = this.homey;
this
.
homeimgnight
.
y
=
this
.
homey
;
//
this.homeimgnight.stop();
this
.
homeimgnight
.
stop
();
//
this.homeimgnight.visible = false;
this
.
homeimgnight
.
visible
=
false
;
//
this.addChild(this.homeimgnight);
this
.
addChild
(
this
.
homeimgnight
);
...
@@ -224,45 +214,13 @@ export default class GameView extends engine.Container {
...
@@ -224,45 +214,13 @@ export default class GameView extends engine.Container {
// testbtn.y = 900;
// testbtn.y = 900;
// testbtn.fillColor = "red";
// testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
//炸弹道具
let
zhadanbtn
=
new
engine
.
Label
();
zhadanbtn
.
text
=
"炸弹"
;
zhadanbtn
.
size
=
56
;
zhadanbtn
.
width
=
200
;
zhadanbtn
.
height
=
100
;
this
.
addChild
(
zhadanbtn
);
zhadanbtn
.
y
=
900
;
zhadanbtn
.
fillColor
=
"red"
;
zhadanbtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
zhadanFunc
,
this
);
//加时间道具
let
timebtn
=
new
engine
.
Label
();
timebtn
.
text
=
"加时"
;
timebtn
.
size
=
56
;
timebtn
.
width
=
200
;
timebtn
.
height
=
100
;
this
.
addChild
(
timebtn
);
timebtn
.
y
=
900
;
timebtn
.
x
=
500
;
timebtn
.
fillColor
=
"red"
;
timebtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
addTimeFunc
,
this
);
}
//炸弹
zhadanFunc
(){
this
.
useBoom
=
true
;
}
//加时间
addTimeFunc
(){
console
.
log
(
"加时间"
);
}
}
changeAni
(){
changeAni
(){
this
.
changeHomeShow
(
"night"
);
this
.
changeHomeShow
(
"night"
);
}
}
playComp
(){
playComp
(){
//
this.homeimgday.stop(1);
this
.
homeimgday
.
stop
(
1
);
//
this.homeimgnight.stop(1);
this
.
homeimgnight
.
stop
(
1
);
}
}
init
(
time
,
level
,
mode
){
init
(
time
,
level
,
mode
){
...
@@ -394,18 +352,18 @@ export default class GameView extends engine.Container {
...
@@ -394,18 +352,18 @@ export default class GameView extends engine.Container {
this
.
gametime
=
ngtime
;
this
.
gametime
=
ngtime
;
}
}
}
}
//
if(this.homeimgday&&this.homeimgday.visible){
if
(
this
.
homeimgday
&&
this
.
homeimgday
.
visible
){
//
let curframe = this.homeimgday.currentFrame;
let
curframe
=
this
.
homeimgday
.
currentFrame
;
//
if(curframe==this.homeimgday.totalFrames){
if
(
curframe
==
this
.
homeimgday
.
totalFrames
){
//
this.homeimgday.gotoAndStop(1);
this
.
homeimgday
.
gotoAndStop
(
1
);
//
}
}
//
}
}
//
if(this.homeimgnight&&this.homeimgnight.visible){
if
(
this
.
homeimgnight
&&
this
.
homeimgnight
.
visible
){
//
let curframe = this.homeimgnight.currentFrame;
let
curframe
=
this
.
homeimgnight
.
currentFrame
;
//
if(curframe==this.homeimgnight.totalFrames){
if
(
curframe
==
this
.
homeimgnight
.
totalFrames
){
//
this.homeimgnight.gotoAndStop(1);
this
.
homeimgnight
.
gotoAndStop
(
1
);
//
}
}
//
}
}
this
.
lastframeTime
=
ntime
;
this
.
lastframeTime
=
ntime
;
}
}
...
@@ -529,14 +487,6 @@ export default class GameView extends engine.Container {
...
@@ -529,14 +487,6 @@ export default class GameView extends engine.Container {
let
sc
=
data
.
c
;
let
sc
=
data
.
c
;
let
type
=
data
.
type
;
let
type
=
data
.
type
;
let
sname
=
sr
+
"_"
+
sc
;
let
sname
=
sr
+
"_"
+
sc
;
//使用炸弹
if
(
this
.
useBoom
){
if
(
type
==
"mouse_down"
){
this
.
unShowEleAttion
();
this
.
boomeEle
(
sr
,
sc
);
}
return
;
}
//新增滑动操作
//新增滑动操作
let
lnewSelect
=
this
.
newSelect
;
let
lnewSelect
=
this
.
newSelect
;
...
@@ -607,25 +557,11 @@ export default class GameView extends engine.Container {
...
@@ -607,25 +557,11 @@ export default class GameView extends engine.Container {
let
r
=
rcname
.
split
(
"_"
)[
0
];
let
r
=
rcname
.
split
(
"_"
)[
0
];
let
c
=
rcname
.
split
(
"_"
)[
1
];
let
c
=
rcname
.
split
(
"_"
)[
1
];
let
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
let
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
engine
.
Tween
.
removeTweens
(
this
.
selectimg
);
this
.
anicontainer
.
addChild
(
this
.
selectimg
);
this
.
anicontainer
.
addChild
(
this
.
selectimg
);
this
.
selectimg
.
x
=
rcpos
[
0
]
-
3
;
this
.
selectimg
.
x
=
rcpos
[
0
];
this
.
selectimg
.
y
=
rcpos
[
1
]
+
this
.
conty
-
3
;
this
.
selectimg
.
y
=
rcpos
[
1
]
+
this
.
conty
;
this
.
startTweenSelectImg
()
}
startTweenSelectImg
(){
this
.
selectimg
.
scaleX
=
1
;
this
.
selectimg
.
scaleY
=
1
;
engine
.
Tween
.
get
(
this
.
selectimg
,{
loop
:
true
})
.
to
({
scaleX
:
0.9
,
scaleY
:
0.9
},
500
)
.
to
({
scaleX
:
1
,
scaleY
:
1
},
500
);
}
}
changeElePos
(){
changeElePos
(){
...
@@ -719,7 +655,7 @@ export default class GameView extends engine.Container {
...
@@ -719,7 +655,7 @@ export default class GameView extends engine.Container {
let
ielidata1
=
this
.
eliminateArr
[
i
];
let
ielidata1
=
this
.
eliminateArr
[
i
];
let
ielileng
=
ielidata1
.
length
;
let
ielileng
=
ielidata1
.
length
;
let
addscore
=
0
;
let
addscore
=
0
;
if
(
ielileng
<
=
3
){
if
(
ielileng
=
=
3
){
addscore
=
props
.
threeEscore
;
addscore
=
props
.
threeEscore
;
}
else
if
(
ielileng
==
4
){
}
else
if
(
ielileng
==
4
){
addscore
=
props
.
fourEscore
;
addscore
=
props
.
fourEscore
;
...
@@ -743,20 +679,13 @@ export default class GameView extends engine.Container {
...
@@ -743,20 +679,13 @@ export default class GameView extends engine.Container {
let
ielix
=
ielinode
.
x
;
let
ielix
=
ielinode
.
x
;
let
ieliy
=
ielinode
.
y
;
let
ieliy
=
ielinode
.
y
;
let
ietype
=
ielinode
.
type
;
let
ietype
=
ielinode
.
type
;
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
,
ietype
);
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
if
(
this
.
elitype
==
1
){
//原地消失
this
.
lattices
[
ielidxname
]
=
"empty"
;
this
.
lattices
[
ielidxname
]
=
"empty"
;
//元素层消除,动画层添加
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
goHomeAni
(
ielitype
,
ielix
,
ieliy
);
this
.
goDisplayAni1
(
ielinode
,
ietype
,
ielix
,
ieliy
);
}
else
{
//飞到目标位置
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
,
ietype
);
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
lattices
[
ielidxname
]
=
"empty"
;
//元素层消除,动画层添加
this
.
goHomeAni
(
ielitype
,
ielix
,
ieliy
);
}
}
}
}
}
...
@@ -772,8 +701,8 @@ export default class GameView extends engine.Container {
...
@@ -772,8 +701,8 @@ export default class GameView extends engine.Container {
res1
();
res1
();
},
500
)
},
500
)
})
})
//
this.homeimgday.play(1,1);
this
.
homeimgday
.
play
(
1
,
1
);
//
this.homeimgnight.play(1,1);
this
.
homeimgnight
.
play
(
1
,
1
);
}
}
//掉落
//掉落
async
fall
(
type
=
"normal"
){
async
fall
(
type
=
"normal"
){
...
@@ -904,7 +833,7 @@ export default class GameView extends engine.Container {
...
@@ -904,7 +833,7 @@ export default class GameView extends engine.Container {
}
}
//原地消失
//原地消失
goDisplayAni
(
ielitype
,
ielix
,
ieliy
){
goDisplayAni
(
ielitype
,
ielix
,
ieliy
){
//
console.log("老原地消失");
console
.
log
(
"老原地消失"
);
let
aniele
=
MapData
.
getOneEle
(
ielitype
);
let
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
alpha
=
0
;
aniele
.
alpha
=
0
;
...
@@ -1584,21 +1513,22 @@ export default class GameView extends engine.Container {
...
@@ -1584,21 +1513,22 @@ export default class GameView extends engine.Container {
let
txtcolor
=
"#bd882f"
;
let
txtcolor
=
"#bd882f"
;
switch
(
ietype
){
switch
(
ietype
){
case
ElementType
.
gdog
:
case
ElementType
.
btiger
:
txtcolor
=
"#
d3ff6d
"
;
txtcolor
=
"#
ffffff
"
;
break
;
break
;
case
ElementType
.
pbird
:
case
ElementType
.
gtiger
:
txtcolor
=
"#f
f51d4
"
;
txtcolor
=
"#f
5a900
"
;
break
;
break
;
case
ElementType
.
hniu
:
case
ElementType
.
monkey
:
txtcolor
=
"#
ffab55
"
;
txtcolor
=
"#
bd882f
"
;
break
;
break
;
case
ElementType
.
b
ribbit
:
case
ElementType
.
b
ird
:
txtcolor
=
"#
b3d4f
f"
;
txtcolor
=
"#
54c1e
f"
;
break
;
break
;
case
ElementType
.
rpig
:
case
ElementType
.
koala
:
txtcolor
=
"#
f2453b
"
;
txtcolor
=
"#
c7c8c9
"
;
break
;
break
;
default
:
default
:
console
.
error
(
"未定义类型,检查"
);
console
.
error
(
"未定义类型,检查"
);
break
;
break
;
...
@@ -1644,52 +1574,7 @@ export default class GameView extends engine.Container {
...
@@ -1644,52 +1574,7 @@ export default class GameView extends engine.Container {
}
else
{
}
else
{
_v
=
false
;
_v
=
false
;
}
}
// this.homeimgday.visible = _v;
this
.
homeimgday
.
visible
=
_v
;
// this.homeimgnight.visible = !_v;
this
.
homeimgnight
.
visible
=
!
_v
;
}
//使用炸弹
boomeEle
(
row
,
col
){
this
.
useBoom
=
false
;
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
changeEnable
(
false
);
this
.
selectArr
=
new
Array
();
// console.log("使用炸弹rc",row,col);
this
.
eliminateArr
=
new
Array
();
for
(
let
r
=
0
;
r
<
MapData
.
row
;
r
++
){
let
irc
=
r
+
"_"
+
col
;
let
ielename
=
this
.
lattices
[
irc
];
let
iele
:
Element
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
){
let
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
])
}
}
for
(
let
c
=
0
;
c
<
MapData
.
col
;
c
++
){
if
(
c
!=
col
){
let
irc
=
row
+
"_"
+
c
;
let
ielename
=
this
.
lattices
[
irc
];
let
iele
:
Element
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
){
let
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
])
}
}
}
// console.log("使用炸弹消除的元素",this.eliminateArr);
this
.
eliminate
();
}
}
}
}
src/custom/xiaoxiaole/src/game/MapData.ts
View file @
9d869388
import
Element
from
"./ele/Element"
;
import
Element
from
"./ele/Element"
;
import
{
getTextureByName
}
from
"./utils"
;
import
{
getTextureByName
}
from
"./utils"
;
export
enum
ElementType
{
export
enum
ElementType
{
gdog
=
1
,
btiger
=
1
,
pbird
,
gtiger
,
hniu
,
monkey
,
b
ribbit
,
b
ird
,
rpig
koala
}
}
export
enum
GameEvent
{
export
enum
GameEvent
{
SelectEle
=
"SelectEle"
,
SelectEle
=
"SelectEle"
,
}
}
export
default
class
MapData
{
export
default
class
MapData
{
//单格大小
//单格大小
static
itemsize
=
1
16
;
static
itemsize
=
1
29
;
//
//
static
paddingw
=
7
;
static
paddingb
=
10
;
static
paddingh
=
7
;
static
paddingi
=
5
;
static
paddingwi
=
4
;
static
paddinghi
=
2
;
//
//
static
row
=
5
;
static
row
=
5
;
static
col
=
5
;
static
col
=
5
;
...
@@ -30,11 +28,11 @@ export default class MapData{
...
@@ -30,11 +28,11 @@ export default class MapData{
static
anispeed
=
1000
;
static
anispeed
=
1000
;
static
gdot
Tex
:
engine
.
Texture
;
static
btiger
Tex
:
engine
.
Texture
;
static
pbird
Tex
:
engine
.
Texture
;
static
gtiger
Tex
:
engine
.
Texture
;
static
hniu
Tex
:
engine
.
Texture
;
static
monkey
Tex
:
engine
.
Texture
;
static
b
ribbit
Tex
:
engine
.
Texture
;
static
b
ird
Tex
:
engine
.
Texture
;
static
rpig
Tex
:
engine
.
Texture
;
static
koala
Tex
:
engine
.
Texture
;
static
levelData
:
Array
<
Array
<
Array
<
number
>>>
=
[
static
levelData
:
Array
<
Array
<
Array
<
number
>>>
=
[
[
[
...
@@ -75,10 +73,10 @@ export default class MapData{
...
@@ -75,10 +73,10 @@ export default class MapData{
]
]
static
getRy
(
r
){
static
getRy
(
r
){
return
this
.
padding
h
+
r
*
(
this
.
itemsize
+
this
.
paddingh
i
);
return
this
.
padding
b
+
r
*
(
this
.
itemsize
+
this
.
padding
i
);
}
}
static
getCx
(
c
){
static
getCx
(
c
){
return
this
.
padding
w
+
c
*
(
this
.
itemsize
+
this
.
paddingw
i
);
return
this
.
padding
b
+
c
*
(
this
.
itemsize
+
this
.
padding
i
);
}
}
static
getRCPos
(
r
,
c
){
static
getRCPos
(
r
,
c
){
let
x
=
this
.
getCx
(
c
);
let
x
=
this
.
getCx
(
c
);
...
@@ -94,20 +92,20 @@ export default class MapData{
...
@@ -94,20 +92,20 @@ export default class MapData{
static
getEtypeImgName
(
type
:
ElementType
){
static
getEtypeImgName
(
type
:
ElementType
){
let
ename
:
string
;
let
ename
:
string
;
switch
(
type
){
switch
(
type
){
case
ElementType
.
gdog
:
case
ElementType
.
btiger
:
ename
=
"
狗
"
;
ename
=
"
白虎
"
;
break
;
break
;
case
ElementType
.
pbird
:
case
ElementType
.
gtiger
:
ename
=
"
鸟
"
;
ename
=
"
雌虎
"
;
break
;
break
;
case
ElementType
.
hniu
:
case
ElementType
.
monkey
:
ename
=
"
牛
"
;
ename
=
"
猴子
"
;
break
;
break
;
case
ElementType
.
b
ribbit
:
case
ElementType
.
b
ird
:
ename
=
"
兔子
"
;
ename
=
"
鸟
"
;
break
;
break
;
case
ElementType
.
rpig
:
case
ElementType
.
koala
:
ename
=
"
猪
"
;
ename
=
"
树熊
"
;
break
;
break
;
default
:
default
:
console
.
error
(
"未定义元素类型"
);
console
.
error
(
"未定义元素类型"
);
...
@@ -118,40 +116,40 @@ export default class MapData{
...
@@ -118,40 +116,40 @@ export default class MapData{
static
getEtypeImgTex
(
type
:
ElementType
){
static
getEtypeImgTex
(
type
:
ElementType
){
let
etex
:
engine
.
Texture
;
let
etex
:
engine
.
Texture
;
switch
(
type
){
switch
(
type
){
case
ElementType
.
gdog
:
case
ElementType
.
btiger
:
if
(
!
this
.
gdot
Tex
){
if
(
!
this
.
btiger
Tex
){
this
.
gdotTex
=
getTextureByName
(
"狗
"
);
this
.
btigerTex
=
getTextureByName
(
"白虎
"
);
console
.
log
(
"新素材加载---
狗
"
);
console
.
log
(
"新素材加载---
白虎
"
);
}
}
etex
=
this
.
gdot
Tex
;
etex
=
this
.
btiger
Tex
;
break
;
break
;
case
ElementType
.
pbird
:
case
ElementType
.
gtiger
:
if
(
!
this
.
pbird
Tex
){
if
(
!
this
.
gtiger
Tex
){
this
.
pbirdTex
=
getTextureByName
(
"鸟
"
);
this
.
gtigerTex
=
getTextureByName
(
"雌虎
"
);
console
.
log
(
"新素材加载---
鸟
"
);
console
.
log
(
"新素材加载---
雌虎
"
);
}
}
etex
=
this
.
pbird
Tex
;
etex
=
this
.
gtiger
Tex
;
break
;
break
;
case
ElementType
.
hniu
:
case
ElementType
.
monkey
:
if
(
!
this
.
hniu
Tex
){
if
(
!
this
.
monkey
Tex
){
this
.
hniuTex
=
getTextureByName
(
"牛
"
);
this
.
monkeyTex
=
getTextureByName
(
"猴子
"
);
console
.
log
(
"新素材加载---
牛
"
);
console
.
log
(
"新素材加载---
猴子
"
);
}
}
etex
=
this
.
hniu
Tex
;
etex
=
this
.
monkey
Tex
;
break
;
break
;
case
ElementType
.
b
ribbit
:
case
ElementType
.
b
ird
:
if
(
!
this
.
b
ribbit
Tex
){
if
(
!
this
.
b
ird
Tex
){
this
.
b
ribbitTex
=
getTextureByName
(
"兔子
"
);
this
.
b
irdTex
=
getTextureByName
(
"鸟
"
);
console
.
log
(
"新素材加载---
兔子
"
);
console
.
log
(
"新素材加载---
鸟
"
);
}
}
etex
=
this
.
b
ribbit
Tex
;
etex
=
this
.
b
ird
Tex
;
break
;
break
;
case
ElementType
.
rpig
:
case
ElementType
.
koala
:
if
(
!
this
.
rpig
Tex
){
if
(
!
this
.
koala
Tex
){
this
.
rpigTex
=
getTextureByName
(
"猪
"
);
this
.
koalaTex
=
getTextureByName
(
"树熊
"
);
console
.
log
(
"新素材加载---
猪
"
);
console
.
log
(
"新素材加载---
树熊
"
);
}
}
etex
=
this
.
rpig
Tex
;
etex
=
this
.
koala
Tex
;
break
;
break
;
default
:
default
:
console
.
error
(
"未定义元素类型"
);
console
.
error
(
"未定义元素类型"
);
...
@@ -161,22 +159,22 @@ export default class MapData{
...
@@ -161,22 +159,22 @@ export default class MapData{
}
}
static
getRandEtype
(){
static
getRandEtype
(){
let
eletypeArr
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
let
eletypeArr
=
[
ElementType
.
btiger
,
ElementType
.
gtiger
,
ElementType
.
monkey
,
ElementType
.
bird
,
ElementType
.
koala
];
let
etype
=
eletypeArr
[
Math
.
floor
(
Math
.
random
()
*
eletypeArr
.
length
)];
let
etype
=
eletypeArr
[
Math
.
floor
(
Math
.
random
()
*
eletypeArr
.
length
)];
return
etype
;
return
etype
;
}
}
static
initPoolEle
(){
static
initPoolEle
(){
// console.error("初始化元素池");
// console.error("初始化元素池");
this
.
gdotTex
=
getTextureByName
(
"狗
"
);
this
.
btigerTex
=
getTextureByName
(
"白虎
"
);
this
.
pbirdTex
=
getTextureByName
(
"鸟
"
);
this
.
gtigerTex
=
getTextureByName
(
"雌虎
"
);
this
.
hniuTex
=
getTextureByName
(
"牛
"
);
this
.
monkeyTex
=
getTextureByName
(
"猴子
"
);
this
.
b
ribbitTex
=
getTextureByName
(
"兔子
"
);
this
.
b
irdTex
=
getTextureByName
(
"鸟
"
);
this
.
rpigTex
=
getTextureByName
(
"猪
"
);
this
.
koalaTex
=
getTextureByName
(
"树熊
"
);
let
eletypes
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
let
eletypes
=
[
ElementType
.
btiger
,
ElementType
.
gtiger
,
ElementType
.
monkey
,
ElementType
.
bird
,
ElementType
.
koala
];
this
.
elePool
[
"ele"
]
=
new
Array
();
this
.
elePool
[
"ele"
]
=
new
Array
();
//初始5*5个元素备用;
//初始5*5个元素备用;
for
(
let
i
=
0
;
i
<
eletypes
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
eletypes
.
length
;
i
++
){
...
...
src/custom/xiaoxiaole/src/game/ele/Element.ts
View file @
9d869388
...
@@ -40,6 +40,8 @@ export default class Element extends engine.Container{
...
@@ -40,6 +40,8 @@ export default class Element extends engine.Container{
// console.log("大小",imgwid,imghei);
// console.log("大小",imgwid,imghei);
this
.
eimage
.
x
=
(
this
.
width
-
imgwid
)
/
2
;
this
.
eimage
.
x
=
(
this
.
width
-
imgwid
)
/
2
;
this
.
eimage
.
y
=
(
this
.
height
-
imghei
)
/
2
;
this
.
eimage
.
y
=
(
this
.
height
-
imghei
)
/
2
;
}
}
setrc
(
r
,
c
){
setrc
(
r
,
c
){
this
.
inrow
=
r
;
this
.
inrow
=
r
;
...
...
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