game.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /**
  2. * @author heyuchang
  3. * @file 游戏控制
  4. */
  5. import ATSDK from "./AnyThinkAds/ATJSSDK";
  6. import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoJSSDK";
  7. import AAJS2 from "./ATAndroidJS2";
  8. import AESUtil from "./AESUtil"
  9. var AC = require('GameAct')
  10. //AD播放完毕后需要进行什么奖励的标记,如:fuHuo等,启用游戏的时候需要清空该KEY
  11. var yxAdMark = 'yxAdMark'
  12. /**
  13. * AD播放完毕标识
  14. */
  15. var adPalyOverEve='adPalyOverEve'
  16. cc.Class({
  17. extends: cc.Component,
  18. properties: {
  19. _status: 0, //0 未开始 1 游戏开始 2 游戏暂停 3 游戏结束 4 下落状态 5无法触摸状态
  20. blockPrefab: cc.Prefab,
  21. blockSprite: [cc.SpriteFrame], //todo: 换成动态生成 暂不处理
  22. warningSpriteFrame: [cc.SpriteFrame],
  23. propSpriteFrame: [cc.SpriteFrame],
  24. checkMgr: require("elementCheck"),
  25. revivePage: cc.Node,
  26. },
  27. onLoad () {
  28. console.log('zh:1111game.js onload...')
  29. cc.sys.localStorage.removeItem(yxAdMark)
  30. this.yxAdEventInit();
  31. },
  32. start() {
  33. console.log('zh:game.js start...')
  34. console.log('zh: ad over 开始测试发送事件s')
  35. this.node.emit(adPalyOverEve, 'test');
  36. console.log('zh: ad over 开始测试发送事件e')
  37. this.bindNode()
  38. this.generatePool()
  39. this.loadRes()
  40. this.initAd()
  41. },
  42. //ad相关的事件初始化
  43. yxAdEventInit(){
  44. let that = this;
  45. this.node.on(adPalyOverEve, function (msg) {
  46. console.log('zh:接收到事件调用adPalyOverEve msg='+msg);
  47. switch(msg){
  48. case 'AdClosed':
  49. console.log('zh:ad over AdClosed')
  50. break;
  51. case 'AdPlayEnd':
  52. console.log('zh:好的,我知道广告播放完毕了,我进行奖励处理')
  53. that.yxAdPlayEndAction();
  54. break;
  55. default:
  56. break;
  57. }
  58. });
  59. },
  60. // 看完了广告那么就要发放奖励(道具)
  61. yxAdPlayEndAction(){
  62. let mark = cc.sys.localStorage.getItem(yxAdMark);//看广告用于 xx 标记
  63. console.log('zh:yxAdMark='+mark);
  64. switch(mark){
  65. case 'fuHuo'://复活
  66. console.log('zh:因为你看完了AD,所以开始发放复活道具')
  67. this.showReviveSuccess()
  68. break;
  69. default:
  70. console.log('zh:没有找到yxAdMark 相关的信息!!!!!!!')
  71. break;
  72. }
  73. this.clearAdMark();
  74. },
  75. /**
  76. * 清除AD 奖励标识
  77. */
  78. clearAdMark(){
  79. cc.sys.localStorage.removeItem(yxAdMark)
  80. },
  81. //#region "AD 监听start"
  82. onRewardedVideoAdLoaded(placementId) {
  83. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
  84. },
  85. onRewardedVideoAdFailed (placementId, errorInfo) {
  86. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
  87. // BrickMsger.emit(BrickMsger.on_play_sound, 1);
  88. // BrickMsger.emit(BrickMsger.on_changeto_start);
  89. //测试AD 事件
  90. // console.log('zh: ad over 开始发送事件aaaa')
  91. // this.node.emit("handleCustomEvent");
  92. // console.log('zh: ad over 开始发送事件bbb')
  93. },
  94. onRewardedVideoAdPlayStart (placementId, callbackInfo) {
  95. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
  96. let deviceId = AAJS2.getDeviceUserId();
  97. var setting = {};
  98. setting[ATRewardedVideoSDK.userIdKey] = deviceId;
  99. ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementID(),setting);
  100. },
  101. onRewardedVideoAdPlayEnd (placementId, callbackInfo) {
  102. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
  103. //that.retrive();
  104. // BrickMsger.emit(BrickMsger.on_play_sound, 1);
  105. // BrickMsger.emit(BrickMsger.on_changeto_start);
  106. console.log('zh: ad onRewardedVideoAdPlayEnd 开始发送事件s')
  107. this.node.emit(adPalyOverEve, 'AdPlayEnd');
  108. console.log('zh: ad onRewardedVideoAdPlayEnd 发送事件e')
  109. },
  110. onRewardedVideoAdPlayFailed (placementId, errorInfo, callbackInfo) {
  111. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
  112. // BrickMsger.emit(BrickMsger.on_play_sound, 1);
  113. // BrickMsger.emit(BrickMsger.on_changeto_start);
  114. },
  115. onRewardedVideoAdClosed (placementId, callbackInfo) {
  116. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
  117. console.log("onRewardxxxxxxclosed",this.state);
  118. console.log("zh:onRewardxxxxxxclosed",this.state);
  119. if(this.state==true){
  120. console.log('zh: ad onRewardedVideoAdClosed 开始发送事件s')
  121. this.node.emit(adPalyOverEve, 'AdClosed');
  122. console.log('zh: ad onRewardedVideoAdClosed 发送事件e')
  123. this.state = false;
  124. }else{
  125. this.state = false;
  126. }
  127. },
  128. onRewardedVideoAdPlayClicked (placementId, callbackInfo) {
  129. ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
  130. },
  131. onReward (placementId, callbackInfo) {
  132. ATSDK.printLog("AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
  133. console.log("onRewardxxxxxx");
  134. //BrickMsger.emit(BrickMsger.on_play_sound, 1);
  135. //BrickMsger.emit(BrickMsger.on_game_revie);
  136. this.state = true;
  137. },
  138. //#endregion "AD 监听end"
  139. /**
  140. * 初始化广告
  141. */
  142. initAd(){
  143. console.log('zh:AD init start')
  144. let placementID = AAJS2.getPlacementID();
  145. let deviceId = AAJS2.getDeviceUserId();
  146. var setting = {};
  147. setting[ATRewardedVideoSDK.userIdKey] = deviceId;
  148. ATRewardedVideoSDK.loadRewardedVideo(placementID,setting);
  149. //console.log('zh:bbb222')
  150. var customPlacementId = "";
  151. if (cc.sys.os === cc.sys.OS_IOS) {
  152. customPlacementId =placementID;
  153. } else if (cc.sys.os === cc.sys.OS_ANDROID) {
  154. customPlacementId = placementID;
  155. }
  156. // 初始化SDK
  157. //ATSDK.initSDK("h67161678d3fcf", "aa0e53109399d0c3a213140e896bdac07");//正式的,发布提交go0gle play
  158. //ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告 ???
  159. ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是cccc线上的
  160. ATSDK.setLogDebug(true);
  161. var GDPRLevel = ATSDK.getGDPRLevel();
  162. var state = false;
  163. // const listener = {
  164. // //。。。。。。。。
  165. // };
  166. // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
  167. ATSDK.getUserLocation(function (userLocation) {
  168. //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
  169. if (userLocation === ATSDK.kATUserLocationInEU) {
  170. if(ATSDK.getGDPRLevel() === ATSDK.UNKNOWN) {
  171. ATSDK.showGDPRAuth();
  172. }
  173. }
  174. });
  175. ATRewardedVideoSDK.setAdListener(this);
  176. if (cc.sys.os === cc.sys.OS_ANDROID) {
  177. setTimeout(() => {
  178. var allInfo = AAJS2.allInfo();
  179. ATSDK.printLog("zh:allInfo="+allInfo );
  180. let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
  181. let iv = "Jn0.aWsOu$y-Dbqb";
  182. let data = {data: AESUtil.AESencrypt(allInfo,key,iv)};
  183. ATSDK.printLog("zh:allInfo-jm="+JSON.stringify(data) );
  184. AAJS2.makePostRequestWithXhr(JSON.stringify(data));
  185. }, 300);
  186. }
  187. console.log('zh:AD init end')
  188. },
  189. loadRes() {
  190. },
  191. init(c) {
  192. this._controller = c
  193. this._score = c.scoreMgr
  194. this.rowNum = c.config.json.rowNum
  195. this.gap = c.config.json.gap
  196. this.animationSpeed = c.config.json.gap
  197. this.blockWidth = (730 - (this.rowNum + 1) * this.gap) / this.rowNum
  198. this.reviveTimer = null
  199. //console.log(this.gap)
  200. //console.log(this.blockWidth)
  201. },
  202. // 动态获取需要动态控制的组件
  203. bindNode() {
  204. this.blocksContainer = this.node.getChildByName('map')
  205. },
  206. //---------------- 游戏控制 ---------------------
  207. // 游戏开始
  208. gameStart() {
  209. this.recoveryAllBlocks().then()
  210. this._score.init(this)
  211. this.mapSet(this.rowNum).then((result) => {
  212. // console.log('游戏状态改变', result)
  213. this._status = 1
  214. })
  215. },
  216. // 初始化地图
  217. mapSet(num) {
  218. this.map = new Array()
  219. console.log('h:mamez.js mapSet 0 ')
  220. let self = this
  221. // 生成两个随机的对象数组
  222. let a = Math.floor(Math.random() * num)
  223. let b = Math.floor(Math.random() * num)
  224. let c = Math.floor(1 + Math.random() * (num - 1)) - 1
  225. a == c ? c++ : ''
  226. let d = Math.floor(Math.random() * num)
  227. return new Promise((resolve, reject) => {
  228. for (let i = 0; i < num; i++) { //行
  229. this.map[i] = new Array()
  230. for (let j = 0; j < num; j++) { //列
  231. let itemType = (i == a && j == b) ? 1 : (i == c && j == d) ? 2 : 0
  232. self.map[i][j] = self.instantiateBlock(self, {
  233. x: j,
  234. y: i,
  235. width: self.blockWidth,
  236. startTime: (i + j + 1) * self._controller.config.json.startAnimationTime / num * 2
  237. }, self.blocksContainer, itemType)
  238. }
  239. }
  240. this.checkMgr.init(this)
  241. setTimeout(() => {
  242. resolve('200 OK');
  243. this.checkMgr.elementCheck(this)
  244. }, self._controller.config.json.startAnimationTime * num / 2 / 1
  245. // (cc.game.getFrameRate() / 60)
  246. )
  247. })
  248. },
  249. //防抖动 判断是否需要检测下落
  250. checkNeedFall() {
  251. if (this.checkNeedFallTimer) {
  252. clearTimeout(this.checkNeedFallTimer)
  253. }
  254. this.checkNeedFallTimer = setTimeout(() => {
  255. if (this._status == 5) {
  256. this._status = 4
  257. this.onFall()
  258. }
  259. }, 300 / 1
  260. // (cc.game.getFrameRate() / 60)
  261. )
  262. },
  263. //方块下落
  264. onFall() {
  265. this.checkGenerateProp(this._score.chain).then(() => {
  266. let self = this
  267. let canFall = 0
  268. //从每一列的最下面一个开始往上判断
  269. //如果有空 就判断有几个空 然后让最上方的方块掉落下来
  270. for (let j = this.rowNum - 1; j >= 0; j--) {
  271. canFall = 0
  272. for (let i = this.rowNum - 1; i >= 0; i--) {
  273. if (this.map[i][j].getComponent('element')._status == 2) {
  274. this.blockPool.put(this.map[i][j])
  275. this.map[i][j] = null
  276. canFall++
  277. } else {
  278. if (canFall != 0) {
  279. this.map[i + canFall][j] = this.map[i][j]
  280. this.map[i][j] = null
  281. this.map[i + canFall][j].getComponent('element').playFallAction(canFall, {
  282. x: j,
  283. y: i + canFall,
  284. })
  285. }
  286. }
  287. }
  288. for (var k = 0; k < canFall; k++) {
  289. this.map[k][j] = this.instantiateBlock(this, {
  290. x: j,
  291. y: k,
  292. width: this.blockWidth,
  293. startTime: null
  294. }, this.blocksContainer, '', {
  295. x: j,
  296. y: -canFall + k
  297. })
  298. this.map[k][j].getComponent('element').playFallAction(canFall, null)
  299. }
  300. }
  301. setTimeout(() => {
  302. this.checkMgr.init(this)
  303. this.checkMgr.elementCheck(this)
  304. this._status = 1
  305. }, 250)
  306. })
  307. },
  308. gameOver() {
  309. this._status = 3
  310. this._controller.pageManager.addPage(2)
  311. this._controller.pageManager.addPage(4)
  312. if (this._controller.social.node.active) {
  313. this._controller.social.closeBannerAdv()
  314. }
  315. },
  316. // todo 复活
  317. askRevive() {
  318. this._controller.pageManager.addPage(2)
  319. this._controller.pageManager.addPage(5)
  320. this.revivePage.active = true
  321. this.revivePage.getChildByName('askRevive').active = true
  322. this.revivePage.getChildByName('successRevive').active = false
  323. this.rangeSprite = this.revivePage.getChildByName('askRevive').getChildByName('numBg').getChildByName('sprite').getComponent(cc.Sprite)
  324. this.rangeSprite.fillRange = 1
  325. this.isRangeAction = true
  326. let numLabel = this.revivePage.getChildByName('askRevive').getChildByName('numBg').getChildByName('num').getComponent(cc.Label)
  327. numLabel.string = 9
  328. if (this.reviveTimer) {
  329. clearInterval(this.reviveTimer)
  330. }
  331. this.reviveTimer = setInterval(() => {
  332. if (+numLabel.string > 0) {
  333. numLabel.string--
  334. this.rangeSprite.fillRange = 1
  335. } else {
  336. this.onSkipRevive()
  337. }
  338. }, 1000)
  339. },
  340. onReviveButton() {
  341. console.log('zh:点击复活按钮1')
  342. console.log('zh: 复活BUT 开始测试发送事件1s')
  343. cc.sys.localStorage.setItem(yxAdMark, 'fuHuo');//看广告用于 复活 标记
  344. this.node.emit(adPalyOverEve, 'AdPlayEnd');
  345. console.log('zh: 复活BUT 开始测试发送事件e')
  346. // setTimeout(()=>{
  347. // let placementID = AAJS2.getPlacementID();
  348. // if(ATRewardedVideoSDK.hasAdReady(placementID)){
  349. // cc.sys.localStorage.setItem(yxAdMark, 'fuHuo');//看广告用于 复活 标记
  350. // ATRewardedVideoSDK.showAd(placementID);
  351. // }else{
  352. // cc.sys.localStorage.setItem(yxAdMark, '');
  353. // console.log('zh:AD 没有准备好')
  354. // }
  355. // },300)
  356. // let testMark = false;//无限复活
  357. // if(testMark){
  358. // clearInterval(this.reviveTimer)
  359. // this.isRangeAction = false
  360. // if (this._controller.social.node.active) {
  361. // this._controller.social.onReviveButton(1)
  362. // } else {
  363. // this.showReviveSuccess()
  364. // }
  365. // }
  366. },
  367. showReviveSuccess() {
  368. console.log('zh:打开复活成功页面')
  369. this.revivePage.getChildByName('askRevive').active = false
  370. this.revivePage.getChildByName('successRevive').active = true
  371. },
  372. onReviveCertainBtn() {
  373. this._controller.pageManager.removePage(2)
  374. this.revivePage.active = false
  375. this._status = 1
  376. this._score.onRevive()
  377. },
  378. update() {
  379. if (this.isRangeAction) {
  380. this.rangeSprite.fillRange -= 1 / 60
  381. }
  382. },
  383. onSkipRevive() {
  384. console.log('zh:onSkipRevive')
  385. clearInterval(this.reviveTimer)
  386. this._controller.pageManager.pages[5].active = false
  387. this._score.onGameOver(true)
  388. this.isRangeAction = false
  389. },
  390. restart() {
  391. console.log('zh:restart')
  392. this._controller.pageManager.onOpenPage(1)
  393. this.recoveryAllBlocks().then(() => {
  394. this.gameStart()
  395. })
  396. },
  397. // -----------------道具相关---------------
  398. // 储存用户点击时的方块 用于生成道具
  399. onUserTouched(iid, jid, itemType, color, warning, pos) {
  400. this.target = {
  401. i: iid,
  402. j: jid,
  403. color: color,
  404. itemType: itemType,
  405. x: pos.x,
  406. y: pos.y,
  407. warning: warning
  408. }
  409. },
  410. // 生成道具 type 1为双倍倍数 2为炸弹 3为加五百
  411. generatePropItem(type) {
  412. return new Promise((resolve, reject) => {
  413. // 是否做道具生成动画
  414. this.map[this.target.i][this.target.j] = this.instantiateBlock(this, {
  415. x: this.target.j,
  416. y: this.target.i,
  417. color: this.target.color,
  418. width: this.blockWidth,
  419. startTime: null
  420. }, this.blocksContainer, type)
  421. setTimeout(() => {
  422. resolve()
  423. }, 300)
  424. })
  425. },
  426. checkGenerateProp(chain) {
  427. return new Promise((resolve, reject) => {
  428. if (this.target.warning) {
  429. this.generatePropItem(this.target.warning).then(() => {
  430. resolve()
  431. return
  432. })
  433. }
  434. resolve()
  435. })
  436. },
  437. onItem(type, color, pos) {
  438. switch (type) {
  439. case 1:
  440. // 分数翻倍 最高八倍
  441. this._score.tipBox.init(this._score, 1)
  442. this._score.addMult(color, pos)
  443. this._controller.musicManager.onDouble()
  444. for (let i = 0; i < this.rowNum; i++) { //行
  445. for (let j = 0; j < this.rowNum; j++) { //列
  446. if (this.map[i][j] && this.map[i][j].getComponent('element')._status == 1) {
  447. let distance = Math.sqrt(Math.pow(pos.x - this.map[i][j].x, 2) + Math.pow(pos.y - this.map[i][j].y, 2))
  448. if (distance != 0) {
  449. this.map[i][j].getComponent('element').surfaceAction(distance)
  450. }
  451. }
  452. }
  453. }
  454. break
  455. case 2:
  456. // 炸弹 消除同种颜色的
  457. this._score.tipBox.init(this._score, 2)
  458. this.node.runAction(AC.shackAction(0.1, 10))
  459. if (this._controller.social.node.active) {
  460. this._controller.social.onShakePhone()
  461. }
  462. this.isPropChain = true
  463. this._controller.musicManager.onBoom()
  464. for (let i = 0; i < this.rowNum; i++) { //行
  465. for (let j = 0; j < this.rowNum; j++) { //列
  466. if (this.map[i][j] && this.map[i][j].getComponent('element').color == color && this.map[i][j] && this.map[i][j].getComponent('element')._status != 2) {
  467. this.map[i][j].getComponent('element').onTouched(color, false, true)
  468. }
  469. else {
  470. this.map[i][j].runAction(AC.rockAction(0.2, 10))
  471. }
  472. }
  473. }
  474. break
  475. case 3: //: 加步数
  476. this._score.tipBox.init(this._score, 4)
  477. this._controller.musicManager.onDouble()
  478. for (let i = 0; i < this.rowNum; i++) { //行
  479. for (let j = 0; j < this.rowNum; j++) { //列
  480. if (this.map[i][j] && this.map[i][j].getComponent('element')._status == 1) {
  481. let distance = Math.sqrt(Math.pow(pos.x - this.map[i][j].x, 2) + Math.pow(pos.y - this.map[i][j].y, 2))
  482. if (distance != 0) {
  483. this.map[i][j].getComponent('element').surfaceAction(distance)
  484. }
  485. }
  486. }
  487. }
  488. this._score.onStep(3).then()
  489. break;
  490. case 4: // : 消除全部单身的方块
  491. this._score.tipBox.init(this._score, 5)
  492. this.isPropChain = true
  493. this._controller.musicManager.onMagic()
  494. for (let i = 0; i < this.rowNum; i++) { //行
  495. for (let j = 0; j < this.rowNum; j++) { //列
  496. if (this.map[i][j] && this.map[i][j].getComponent('element').isSingle && this.map[i][j] && this.map[i][j].getComponent('element')._status != 2) {
  497. let distance = Math.sqrt(Math.pow(pos.x - this.map[i][j].x, 2) + Math.pow(pos.y - this.map[i][j].y, 2))
  498. this.map[i][j].getComponent('element').onTouched(color, false, true, distance)
  499. console.log("魔法棒触发的点", i,j,this.map[i][j].getComponent('element').color, this.map[i][j].getComponent('element').isSingle)
  500. }
  501. }
  502. }
  503. break;
  504. }
  505. },
  506. //--------------------- 预制体实例化---------------------
  507. // 生成对象池
  508. generatePool() {
  509. this.blockPool = new cc.NodePool()
  510. for (let i = 0; i < Math.pow(this.rowNum, 2); i++) {
  511. let block = cc.instantiate(this.blockPrefab)
  512. this.blockPool.put(block)
  513. }
  514. },
  515. // 实例化单个方块
  516. instantiateBlock(self, data, parent, itemType, pos) {
  517. itemType = itemType ? itemType : 0
  518. if (itemType != 0) {
  519. // console.log("道具节点数据", data, itemType)
  520. }
  521. let block = null
  522. if (self.blockPool && self.blockPool.size() > 0) {
  523. block = self.blockPool.get()
  524. } else {
  525. block = cc.instantiate(self.blockPrefab)
  526. }
  527. block.parent = parent
  528. block.scale = 1
  529. block.x = 0
  530. block.y = 0
  531. block.getComponent('element').init(self, data, this.blockWidth, itemType, pos)
  532. return block
  533. },
  534. // 回收所有节点
  535. recoveryAllBlocks() {
  536. return new Promise((resolve, reject) => {
  537. let children = this.blocksContainer.children
  538. if (children.length != 0) {
  539. let length = children.length
  540. // console.log(length)
  541. for (let i = 0; i < length; i++) {
  542. this.blockPool.put(children[0])
  543. }
  544. for (let i = 0; i < this.rowNum; i++) {
  545. for (let j = 0; j < this.rowNum; j++) {
  546. this.map[i][j] = null
  547. }
  548. }
  549. }
  550. resolve('')
  551. })
  552. },
  553. });