Commit b171662d authored by huangwenjie's avatar huangwenjie

1

parent bdd543d4
...@@ -919,7 +919,7 @@ export class PlayScene extends Scene { ...@@ -919,7 +919,7 @@ export class PlayScene extends Scene {
// 随机生成基础元素 // 随机生成基础元素
generateOneElement() { generateOneElement() {
// 随机生成一个数字 2or4 // 随机生成一个数字 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 randNumberX = Math.floor(Math.random() * 4)
let randNumberY = Math.floor(Math.random() * 4) let randNumberY = Math.floor(Math.random() * 4)
...@@ -1270,7 +1270,7 @@ export class PlayScene extends Scene { ...@@ -1270,7 +1270,7 @@ export class PlayScene extends Scene {
beforeArr[x][y] = beforeArr[xb][y] beforeArr[x][y] = beforeArr[xb][y]
beforeArr[xb][y] = 0 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 this.containerPool[xb][y].children[0].visible = false
let origin = new GameEle(beforeArr[xb][y]) let origin = new GameEle(beforeArr[xb][y])
this.addChild(origin) this.addChild(origin)
...@@ -1317,7 +1317,7 @@ export class PlayScene extends Scene { ...@@ -1317,7 +1317,7 @@ export class PlayScene extends Scene {
beforeArr[x][y] = beforeArr[x][yr] beforeArr[x][y] = beforeArr[x][yr]
beforeArr[x][yr] = 0 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 this.containerPool[x][yr].children[0].visible = false
let origin = new GameEle(beforeArr[x][yr]) let origin = new GameEle(beforeArr[x][yr])
this.addChild(origin) this.addChild(origin)
...@@ -1364,7 +1364,7 @@ export class PlayScene extends Scene { ...@@ -1364,7 +1364,7 @@ export class PlayScene extends Scene {
beforeArr[x][y] = beforeArr[xt][y] beforeArr[x][y] = beforeArr[xt][y]
beforeArr[xt][y] = 0 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 this.containerPool[xt][y].children[0].visible = false
let origin = new GameEle(beforeArr[xt][y]) let origin = new GameEle(beforeArr[xt][y])
this.addChild(origin) this.addChild(origin)
...@@ -1411,7 +1411,7 @@ export class PlayScene extends Scene { ...@@ -1411,7 +1411,7 @@ export class PlayScene extends Scene {
beforeArr[x][y] = beforeArr[x][yl] beforeArr[x][y] = beforeArr[x][yl]
beforeArr[x][yl] = 0 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 this.containerPool[x][yl].children[0].visible = false
let origin = new GameEle(beforeArr[x][yl]) let origin = new GameEle(beforeArr[x][yl])
this.addChild(origin) this.addChild(origin)
...@@ -1449,7 +1449,7 @@ export class PlayScene extends Scene { ...@@ -1449,7 +1449,7 @@ export class PlayScene extends Scene {
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
if (arr[i] === 0) { if (arr[i] === 0) {
hasZero = true 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 return true
} else { } else {
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment