Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game2048
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
熊东起
game2048
Commits
55ea3cbc
Commit
55ea3cbc
authored
Apr 24, 2020
by
wjf
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab2.dui88.com:MrKwon/game2048
parents
85a1fbf4
b171662d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
PlayScene.ts
src/scenes/playScene/PlayScene.ts
+21
-20
No files found.
src/scenes/playScene/PlayScene.ts
View file @
55ea3cbc
import
{
PropPanel
}
from
'./../../panels/PropPanel'
;
import
{
QuitPanel
}
from
'./../../panels/QuitPanel'
;
import
{
PropOutPanel
}
from
'./../../panels/PropOutPanel'
;
import
{
showWaiting
,
hideWaiting
}
from
'./../../../module/ctrls/waitingCtrl'
;
...
...
@@ -452,7 +453,7 @@ export class PlayScene extends Scene {
getTools
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
},
PropType
.
exchange
)
}
else
if
(
this
.
exchangeTargetPool
.
length
=
1
)
{
...
...
@@ -685,7 +686,7 @@ export class PlayScene extends Scene {
this
.
removeChild
(
this
.
doFilterBtn
)
this
.
filtering
=
false
this
.
removeAnis
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
},
300
);
},
PropType
.
net
)
...
...
@@ -817,7 +818,7 @@ export class PlayScene extends Scene {
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
}
}
...
...
@@ -828,7 +829,7 @@ export class PlayScene extends Scene {
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
}
}
...
...
@@ -841,7 +842,7 @@ export class PlayScene extends Scene {
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
}
}
...
...
@@ -852,7 +853,7 @@ export class PlayScene extends Scene {
await
this
.
moveAni
(
beforeArr
)
this
.
renderBoard
()
this
.
generateOneElement
()
if
(
!
this
.
isGameWin
())
//
if (!this.isGameWin())
this
.
isGameOver
()
}
}
...
...
@@ -918,7 +919,7 @@ export class PlayScene extends Scene {
// 随机生成基础元素
generateOneElement
()
{
// 随机生成一个数字 2or4
let
randNumber
=
Math
.
random
()
<
0.9
?
2
:
4
let
randNumber
=
Math
.
random
()
<
0.9
?
2
:
2048
// 随机生成位置
let
randNumberX
=
Math
.
floor
(
Math
.
random
()
*
4
)
let
randNumberY
=
Math
.
floor
(
Math
.
random
()
*
4
)
...
...
@@ -989,7 +990,7 @@ export class PlayScene extends Scene {
gameover
()
{
// 游戏结束
console
.
log
(
"游戏结束"
);
showPanel
(
PropPanel
)
}
isGameWin
()
{
...
...
@@ -1166,7 +1167,7 @@ export class PlayScene extends Scene {
let
addScore
=
0
for
(
let
i
=
1
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
===
0
)
break
if
(
arr
[
i
]
===
arr
[
i
-
1
])
{
if
(
arr
[
i
]
===
arr
[
i
-
1
]
&&
arr
[
i
-
1
]
<
2048
)
{
// fromIdx 要改成转换前的idx
// this.moveData[t].push({ "fromValue": arr[i - 1], "toValue": arr[i - 1] * 2, "fromIdx": i, "toIdx": i - 1 })
...
...
@@ -1269,7 +1270,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
xb
][
y
]
beforeArr
[
xb
][
y
]
=
0
}
else
if
(
beforeArr
[
xb
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockBottom
(
x
,
xb
,
y
,
beforeArr
))
{
}
else
if
(
beforeArr
[
xb
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockBottom
(
x
,
xb
,
y
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
xb
][
y
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
xb
][
y
])
this
.
addChild
(
origin
)
...
...
@@ -1316,7 +1317,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
x
][
yr
]
beforeArr
[
x
][
yr
]
=
0
}
else
if
(
beforeArr
[
x
][
yr
]
===
beforeArr
[
x
][
y
]
&&
noBlockRight
(
x
,
y
,
yr
,
beforeArr
))
{
}
else
if
(
beforeArr
[
x
][
yr
]
===
beforeArr
[
x
][
y
]
&&
noBlockRight
(
x
,
y
,
yr
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
x
][
yr
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
x
][
yr
])
this
.
addChild
(
origin
)
...
...
@@ -1363,7 +1364,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
xt
][
y
]
beforeArr
[
xt
][
y
]
=
0
}
else
if
(
beforeArr
[
xt
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockTop
(
x
,
xt
,
y
,
beforeArr
))
{
}
else
if
(
beforeArr
[
xt
][
y
]
===
beforeArr
[
x
][
y
]
&&
noBlockTop
(
x
,
xt
,
y
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
xt
][
y
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
xt
][
y
])
this
.
addChild
(
origin
)
...
...
@@ -1410,7 +1411,7 @@ export class PlayScene extends Scene {
beforeArr
[
x
][
y
]
=
beforeArr
[
x
][
yl
]
beforeArr
[
x
][
yl
]
=
0
}
else
if
(
beforeArr
[
x
][
yl
]
===
beforeArr
[
x
][
y
]
&&
noBlockLeft
(
x
,
y
,
yl
,
beforeArr
))
{
}
else
if
(
beforeArr
[
x
][
yl
]
===
beforeArr
[
x
][
y
]
&&
noBlockLeft
(
x
,
y
,
yl
,
beforeArr
)
&&
beforeArr
[
x
][
y
]
<
2048
)
{
this
.
containerPool
[
x
][
yl
].
children
[
0
].
visible
=
false
let
origin
=
new
GameEle
(
beforeArr
[
x
][
yl
])
this
.
addChild
(
origin
)
...
...
@@ -1448,7 +1449,7 @@ export class PlayScene extends Scene {
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
===
0
)
{
hasZero
=
true
}
else
if
(
arr
[
i
]
!==
0
&&
hasZero
||
arr
[
i
]
===
arr
[
i
+
1
]
)
{
}
else
if
(
arr
[
i
]
!==
0
&&
hasZero
||
(
arr
[
i
]
===
arr
[
i
+
1
]
&&
arr
[
i
]
<
2048
)
)
{
return
true
}
else
{
continue
...
...
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