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
403187b9
Commit
403187b9
authored
Jul 10, 2020
by
zjz1994
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码暂存
parent
e0fcb941
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
235 additions
and
25 deletions
+235
-25
xiaoxiaole.json
dist/customs/xiaoxiaole.json
+1
-1
main.js
src/custom/xiaoxiaole/debug/main.js
+103
-11
main.js.map
src/custom/xiaoxiaole/debug/main.js.map
+1
-1
GameView.ts
src/custom/xiaoxiaole/src/game/GameView.ts
+94
-11
Element.ts
src/custom/xiaoxiaole/src/game/ele/Element.ts
+36
-1
No files found.
dist/customs/xiaoxiaole.json
View file @
403187b9
This diff is collapsed.
Click to expand it.
src/custom/xiaoxiaole/debug/main.js
View file @
403187b9
...
...
@@ -53,7 +53,36 @@
c
:
this
.
incol
});
};
Element
.
prototype
.
flyToHome
=
function
()
{
Object
.
defineProperty
(
Element
.
prototype
,
"factor"
,
{
get
:
function
()
{
return
0
;
},
set
:
function
(
value
)
{
this
.
x
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1x
+
2
*
value
*
(
1
-
value
)
*
this
.
c1x
+
value
*
value
*
this
.
p2x
;
this
.
y
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1y
+
2
*
value
*
(
1
-
value
)
*
this
.
c1y
+
value
*
value
*
this
.
p2y
;
var
mscale
=
(
1
-
value
)
*
(
1
-
value
)
*
1
+
2
*
value
*
(
1
-
value
)
*
0.6
+
value
*
value
*
0
;
this
.
scaleX
=
mscale
;
this
.
scaleY
=
mscale
;
},
enumerable
:
true
,
configurable
:
true
});
Element
.
prototype
.
flyToHome
=
function
(
tx
,
ty
,
time
)
{
var
_this
=
this
;
this
.
p1x
=
this
.
x
;
this
.
p1y
=
this
.
y
;
this
.
c1x
=
(
this
.
p1x
-
tx
)
/
4
+
tx
;
this
.
c1y
=
ty
;
this
.
p2x
=
tx
;
this
.
p2y
=
ty
;
engine
.
Tween
.
get
(
this
).
to
({
factor
:
1
},
time
)
.
call
(
function
()
{
var
nodeparent
=
_this
.
parent
;
nodeparent
&&
nodeparent
.
removeChild
(
_this
);
MapData
.
recoverEle
(
_this
);
});
};
Element
.
prototype
.
changePos
=
function
()
{
};
...
...
@@ -229,6 +258,7 @@
}
}
this
.
checkEliminate
();
this
.
attionEliminate
();
};
GameView
.
prototype
.
setLatticeEleRc
=
function
(
rcidx
)
{
var
rename
=
this
.
lattices
[
rcidx
];
...
...
@@ -344,6 +374,7 @@
var
ielix
=
ielinode
.
x
;
var
ieliy
=
ielinode
.
y
;
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
);
this
.
lattices
[
ielidxname
]
=
"empty"
;
this
.
goHomeAni
(
ielitype
,
ielix
,
ieliy
);
}
...
...
@@ -431,21 +462,15 @@
};
GameView
.
prototype
.
goHomeAni
=
function
(
ielitype
,
ielix
,
ieliy
)
{
var
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
touch
=
false
;
var
anix
=
ielix
;
var
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
var
anidis
=
MapData
.
getDistance
([
this
.
tanix
,
this
.
taniy
],
[
anix
,
aniy
]);
var
anitime
=
Math
.
ceil
((
anidis
/
this
.
anispeed
)
*
1000
);
engine
.
Tween
.
get
(
aniele
)
.
to
({
x
:
this
.
tanix
,
y
:
this
.
taniy
,
scaleX
:
0
,
scaleY
:
0
},
anitime
);
aniele
.
flyToHome
(
this
.
tanix
,
this
.
taniy
,
anitime
);
};
GameView
.
prototype
.
changeEnable
=
function
(
v
)
{
for
(
var
key
in
this
.
lattices
)
{
...
...
@@ -455,6 +480,64 @@
}
};
GameView
.
prototype
.
attionEliminate
=
function
()
{
var
attiondata
;
for
(
var
r
=
MapData
.
row
-
1
;
r
>
-
1
;
r
--
)
{
for
(
var
c
=
MapData
.
col
-
1
;
c
>
-
1
;
c
--
)
{
var
checktype
=
this
.
getEleTypeByRc
(
r
,
c
);
var
edatarow
=
this
.
getEliminateRow
(
r
,
c
);
var
edatacol
=
this
.
getEliminateCol
(
r
,
c
);
if
(
edatarow
.
length
>
2
||
edatacol
.
length
>
2
)
{
console
.
error
(
"啥情况,检查----------------"
);
}
if
(
edatarow
.
length
==
2
)
{
console
.
log
(
"横向查找"
,
edatarow
);
var
releidx1
=
edatarow
[
0
];
var
releidx2
=
edatarow
[
1
];
var
relerow1
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
var
relerow2
=
Number
(
releidx2
.
split
(
"_"
)[
0
]);
var
relecol
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
var
downrow
=
relerow1
+
1
;
var
uprow
=
relerow2
-
1
;
var
rightcol
=
relecol
+
1
;
var
leftcol
=
relecol
-
1
;
var
mayeleidxs
=
new
Array
();
if
(
downrow
<
MapData
.
row
)
{
if
(
rightcol
<
MapData
.
col
)
{
mayeleidxs
.
push
(
downrow
+
"_"
+
rightcol
);
}
if
(
leftcol
>
-
1
)
{
mayeleidxs
.
push
(
downrow
+
"_"
+
leftcol
);
}
}
if
(
uprow
>
-
1
)
{
if
(
rightcol
<
MapData
.
col
)
{
mayeleidxs
.
push
(
uprow
+
"_"
+
rightcol
);
}
if
(
leftcol
>
-
1
)
{
mayeleidxs
.
push
(
uprow
+
"_"
+
leftcol
);
}
}
for
(
var
ir
=
0
;
ir
<
mayeleidxs
.
length
;
ir
++
)
{
var
iridx
=
mayeleidxs
[
ir
];
var
irename
=
this
.
lattices
[
iridx
];
if
(
irename
)
{
var
irerow
=
Number
(
iridx
.
split
(
"_"
)[
0
]);
var
irecol
=
Number
(
iridx
.
split
(
"_"
)[
1
]);
var
iretype
=
this
.
getEleTypeByRc
(
irerow
,
irecol
);
if
(
iretype
==
checktype
)
{
console
.
log
(
"相邻检测到了"
,
iridx
);
attiondata
=
iridx
;
return
;
}
}
}
}
if
(
edatacol
.
length
==
2
)
{
console
.
log
(
"竖向查找"
,
edatacol
);
}
}
}
console
.
log
(
"相邻检测--------------"
,
attiondata
);
};
GameView
.
prototype
.
checkEliminate
=
function
()
{
this
.
eliminateArr
=
new
Array
();
...
...
@@ -469,7 +552,7 @@
}
}
};
GameView
.
prototype
.
getEliminate
=
function
(
x
,
y
)
{
GameView
.
prototype
.
getEliminate
Row
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
...
...
@@ -482,6 +565,10 @@
break
;
}
}
return
relearr
;
};
GameView
.
prototype
.
getEliminateCol
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
celearr
=
new
Array
();
celearr
.
push
(
x
+
"_"
+
y
);
for
(
var
c
=
y
-
1
;
c
>
-
1
;
c
--
)
{
...
...
@@ -493,6 +580,12 @@
break
;
}
}
return
celearr
;
};
GameView
.
prototype
.
getEliminate
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
relearr
=
this
.
getEliminateRow
(
x
,
y
);
var
celearr
=
this
.
getEliminateCol
(
x
,
y
);
var
eliminatearr
=
new
Array
();
if
(
relearr
.
length
>=
3
)
{
eliminatearr
.
push
.
apply
(
eliminatearr
,
relearr
);
...
...
@@ -550,7 +643,6 @@
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
...
...
src/custom/xiaoxiaole/debug/main.js.map
View file @
403187b9
This diff is collapsed.
Click to expand it.
src/custom/xiaoxiaole/src/game/GameView.ts
View file @
403187b9
...
...
@@ -117,6 +117,8 @@ export default class GameView extends engine.Container {
}
this
.
checkEliminate
();
this
.
attionEliminate
();
}
//关联
setLatticeEleRc
(
rcidx
){
...
...
@@ -250,6 +252,7 @@ export default class GameView extends engine.Container {
let
ielix
=
ielinode
.
x
;
let
ieliy
=
ielinode
.
y
;
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
);
this
.
lattices
[
ielidxname
]
=
"empty"
;
//元素层消除,动画层添加
...
...
@@ -334,23 +337,25 @@ export default class GameView extends engine.Container {
}
goHomeAni
(
ielitype
,
ielix
,
ieliy
){
let
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
touch
=
false
;
let
anix
=
ielix
;
let
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
let
anidis
=
MapData
.
getDistance
([
this
.
tanix
,
this
.
taniy
],[
anix
,
aniy
]);
let
anitime
=
Math
.
ceil
((
anidis
/
this
.
anispeed
)
*
1000
);
engine
.
Tween
.
get
(
aniele
)
.
to
({
x
:
this
.
tanix
,
y
:
this
.
taniy
,
scaleX
:
0
,
scaleY
:
0
},
anitime
);
aniele
.
flyToHome
(
this
.
tanix
,
this
.
taniy
,
anitime
);
// engine.Tween.get(aniele)
// .to({
// x:this.tanix,
// y:this.taniy,
// scaleX:0,
// scaleY:0
// },anitime);
}
//修改元素点击
...
...
@@ -362,8 +367,75 @@ export default class GameView extends engine.Container {
}
}
//相邻检测
attionEliminate
(){
let
attiondata
;
for
(
let
r
=
MapData
.
row
-
1
;
r
>-
1
;
r
--
){
for
(
let
c
=
MapData
.
col
-
1
;
c
>-
1
;
c
--
){
let
checktype
=
this
.
getEleTypeByRc
(
r
,
c
);
let
edatarow
=
this
.
getEliminateRow
(
r
,
c
);
let
edatacol
=
this
.
getEliminateCol
(
r
,
c
);
if
(
edatarow
.
length
>
2
||
edatacol
.
length
>
2
){
console
.
error
(
"啥情况,检查----------------"
);
}
if
(
edatarow
.
length
==
2
){
console
.
log
(
"横向查找"
,
edatarow
);
let
releidx1
=
edatarow
[
0
];
let
releidx2
=
edatarow
[
1
];
let
relerow1
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
let
relerow2
=
Number
(
releidx2
.
split
(
"_"
)[
0
]);
let
relecol
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
let
downrow
=
relerow1
+
1
;
let
uprow
=
relerow2
-
1
;
let
rightcol
=
relecol
+
1
;
let
leftcol
=
relecol
-
1
;
let
mayeleidxs
=
new
Array
();
if
(
downrow
<
MapData
.
row
){
if
(
rightcol
<
MapData
.
col
){
mayeleidxs
.
push
(
downrow
+
"_"
+
rightcol
)
}
if
(
leftcol
>-
1
){
mayeleidxs
.
push
(
downrow
+
"_"
+
leftcol
);
}
}
if
(
uprow
>-
1
){
if
(
rightcol
<
MapData
.
col
){
mayeleidxs
.
push
(
uprow
+
"_"
+
rightcol
)
}
if
(
leftcol
>-
1
){
mayeleidxs
.
push
(
uprow
+
"_"
+
leftcol
);
}
}
for
(
let
ir
=
0
;
ir
<
mayeleidxs
.
length
;
ir
++
){
let
iridx
=
mayeleidxs
[
ir
];
let
irename
=
this
.
lattices
[
iridx
];
if
(
irename
){
let
irerow
=
Number
(
iridx
.
split
(
"_"
)[
0
]);
let
irecol
=
Number
(
iridx
.
split
(
"_"
)[
1
]);
let
iretype
=
this
.
getEleTypeByRc
(
irerow
,
irecol
);
if
(
iretype
==
checktype
){
console
.
log
(
"相邻检测到了"
,
iridx
);
attiondata
=
iridx
;
return
;
}
}
}
}
if
(
edatacol
.
length
==
2
){
console
.
log
(
"竖向查找"
,
edatacol
);
}
}
}
console
.
log
(
"相邻检测--------------"
,
attiondata
);
}
//检测消除
checkEliminate
(){
...
...
@@ -380,7 +452,7 @@ export default class GameView extends engine.Container {
}
}
getEliminate
(
x
,
y
){
getEliminate
Row
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
relearr
=
new
Array
();
...
...
@@ -393,7 +465,10 @@ export default class GameView extends engine.Container {
break
;
}
}
return
relearr
;
}
getEliminateCol
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
celearr
=
new
Array
();
celearr
.
push
(
x
+
"_"
+
y
);
for
(
let
c
=
y
-
1
;
c
>-
1
;
c
--
){
...
...
@@ -404,6 +479,14 @@ export default class GameView extends engine.Container {
break
;
}
}
return
celearr
;
}
getEliminate
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
relearr
=
this
.
getEliminateRow
(
x
,
y
);
let
celearr
=
this
.
getEliminateCol
(
x
,
y
);
let
eliminatearr
=
new
Array
();
if
(
relearr
.
length
>=
3
){
...
...
src/custom/xiaoxiaole/src/game/ele/Element.ts
View file @
403187b9
...
...
@@ -48,9 +48,44 @@ export default class Element extends engine.Container{
})
}
public
get
factor
():
number
{
return
0
;
}
public
set
factor
(
value
:
number
)
{
this
.
x
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1x
+
2
*
value
*
(
1
-
value
)
*
this
.
c1x
+
value
*
value
*
this
.
p2x
;
this
.
y
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1y
+
2
*
value
*
(
1
-
value
)
*
this
.
c1y
+
value
*
value
*
this
.
p2y
;
var
mscale
=
(
1
-
value
)
*
(
1
-
value
)
*
1
+
2
*
value
*
(
1
-
value
)
*
0.6
+
value
*
value
*
0
;
this
.
scaleX
=
mscale
;
this
.
scaleY
=
mscale
;
}
p1x
;
p1y
;
c1x
;
c1y
;
p2x
;
p2y
;
//飞到小屋
flyToHome
(){
flyToHome
(
tx
,
ty
,
time
){
this
.
p1x
=
this
.
x
;
this
.
p1y
=
this
.
y
;
this
.
c1x
=
(
this
.
p1x
-
tx
)
/
4
+
tx
;
this
.
c1y
=
ty
;
this
.
p2x
=
tx
;
this
.
p2y
=
ty
;
engine
.
Tween
.
get
(
this
).
to
({
factor
:
1
},
time
)
.
call
(()
=>
{
let
nodeparent
:
engine
.
Container
=
this
.
parent
;
nodeparent
&&
nodeparent
.
removeChild
(
this
);
MapData
.
recoverEle
(
this
);
})
}
changePos
(){
...
...
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