Commit c3efc5cf authored by huangwenjie's avatar huangwenjie

1

parent a6b83c15
...@@ -79,7 +79,7 @@ export enum SoundType { ...@@ -79,7 +79,7 @@ export enum SoundType {
speedUp = "speedUp", speedUp = "speedUp",
move = "move", move = "move",
createEle = "createEle", createEle = "createEle",
createEles = "createELes", createEles = "createEles",
bomb = "bomb", bomb = "bomb",
exchange = "exchange", exchange = "exchange",
gameOver = "gameOver", gameOver = "gameOver",
......
...@@ -149,6 +149,12 @@ ...@@ -149,6 +149,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/howler": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@types/howler/-/howler-2.1.2.tgz",
"integrity": "sha512-gK7snhJcWVvTdiE6cCBAjeZ9od9Q8LmB5lEyB/3n6jMJOLn7EQ8Zvmkz8XPhnN5xB+b7QzCiqxJY3YiHrM3Jpg==",
"dev": true
},
"@types/jquery": { "@types/jquery": {
"version": "3.3.35", "version": "3.3.35",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.35.tgz", "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.35.tgz",
...@@ -4874,6 +4880,12 @@ ...@@ -4874,6 +4880,12 @@
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
"dev": true "dev": true
}, },
"howler": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/howler/-/howler-2.1.3.tgz",
"integrity": "sha512-PSGbOi1EYgw80C5UQbxtJM7TmzD+giJunIMBYyH3RVzHZx2fZLYBoes0SpVVHi/SFa1GoNtgXj/j6I7NOKYBxQ==",
"dev": true
},
"hpack.js": { "hpack.js": {
"version": "2.1.6", "version": "2.1.6",
"resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz",
......
...@@ -42,4 +42,4 @@ ...@@ -42,4 +42,4 @@
}, },
"author": "", "author": "",
"license": "ISC" "license": "ISC"
} }
\ No newline at end of file
import { showWaiting, hideWaiting } from './../../../module/ctrls/waitingCtrl';
import { PropType } from './../../commonNet';
import { UnlockPanel } from './../../panels/UnlockPanel';
import { playSound } from './../../../module/ctrls/soundCtrl';
import { FrameAni } from './../../../engine/2d/ui/FrameAni'; import { FrameAni } from './../../../engine/2d/ui/FrameAni';
import { MovieClip } from './../../../engine/2d/svga/MovieClip'; import { MovieClip } from './../../../engine/2d/svga/MovieClip';
import { Shape } from './../../../engine/2d/graphics/Shape'; import { Shape } from './../../../engine/2d/graphics/Shape';
...@@ -13,7 +17,7 @@ import { Container, Sprite } from '../../../engine/2d/display'; ...@@ -13,7 +17,7 @@ import { Container, Sprite } from '../../../engine/2d/display';
import { Graphics } from '../../../engine/2d/graphics'; import { Graphics } from '../../../engine/2d/graphics';
import Tween from '../../../engine/tween/Tween'; import Tween from '../../../engine/tween/Tween';
import { RES } from '../../../module/RES'; import { RES } from '../../../module/RES';
import { getTools } from '../../commonNet' import { getTools, getSoundStatus, useTools } from '../../commonNet'
export class PlayScene extends Scene { export class PlayScene extends Scene {
get groupNames() { return ["playScene"] } get groupNames() { return ["playScene"] }
...@@ -26,6 +30,8 @@ export class PlayScene extends Scene { ...@@ -26,6 +30,8 @@ export class PlayScene extends Scene {
start() { start() {
this.initUI() this.initUI()
this.initEvents() this.initEvents()
} }
board: any[] = [] board: any[] = []
...@@ -42,16 +48,29 @@ export class PlayScene extends Scene { ...@@ -42,16 +48,29 @@ export class PlayScene extends Scene {
return this._score return this._score
} }
_unlockScore = 2 _unlockGrade = 2
set unlockScore(value) { set unlockGrade(value) {
this._unlockScore = value this._unlockGrade = value
this.unlockScoreTxt.text = this._unlockScore + "" this.unlockGradeTxt.text = this._unlockGrade + ""
}
get unlockGrade() {
return this._unlockGrade
} }
get unlockScore() {
return this._unlockScore _isPlayMusic: boolean = false
set isPlayMusic(value) {
this._isPlayMusic = value
if (this._isPlayMusic) {
this.musicBtn.texture = RES.getRes("musicOn.png")
} else {
this.musicBtn.texture = RES.getRes("musicOff.png")
}
} }
isPlayMusic: boolean = true get isPlayMusic() {
return this._isPlayMusic
}
bg: Sprite bg: Sprite
goBackBtn: Button goBackBtn: Button
...@@ -63,7 +82,7 @@ export class PlayScene extends Scene { ...@@ -63,7 +82,7 @@ export class PlayScene extends Scene {
filterBtn: Button filterBtn: Button
filterCountTxt: TextField filterCountTxt: TextField
scoreTxt: TextField scoreTxt: TextField
unlockScoreTxt: TextField unlockGradeTxt: TextField
initUI() { initUI() {
...@@ -80,7 +99,7 @@ export class PlayScene extends Scene { ...@@ -80,7 +99,7 @@ export class PlayScene extends Scene {
this.addEventListener("updateScoreTxt", this.updateScoreTxt, this) this.addEventListener("updateScoreTxt", this.updateScoreTxt, this)
this.score = 0 this.score = 0
this.unlockScoreTxt = this.addChild(this.drawTxt(this.unlockScore, 520, 340, "#ffffff", 36)) as TextField this.unlockGradeTxt = this.addChild(this.drawTxt(this.unlockGrade, 520, 340, "#ffffff", 36)) as TextField
this.exchangeBtn = new Button(RES.getRes('exchangeBtn.png')) this.exchangeBtn = new Button(RES.getRes('exchangeBtn.png'))
this.exchangeBtn.y = 1280 this.exchangeBtn.y = 1280
...@@ -167,7 +186,11 @@ export class PlayScene extends Scene { ...@@ -167,7 +186,11 @@ export class PlayScene extends Scene {
this.generateOneElement() this.generateOneElement()
} }
this.updateProp(2, 2, 1) this.isPlayMusic = getSoundStatus()
this.updateProp(this.gameData.bombCount, this.gameData.exchangeCount, this.gameData.netCount)
this.unlockGrade = this.gameData.unlockGrade ? this.gameData.unlockGrade : 2
} }
createAniPool = [] createAniPool = []
...@@ -235,6 +258,11 @@ export class PlayScene extends Scene { ...@@ -235,6 +258,11 @@ export class PlayScene extends Scene {
this.exchangeBtn.addEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this) this.exchangeBtn.addEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this)
this.bombBtn.addEventListener(MouseEvent.CLICK, this.onClick_bombBtn, this) this.bombBtn.addEventListener(MouseEvent.CLICK, this.onClick_bombBtn, this)
this.filterBtn.addEventListener(MouseEvent.CLICK, this.onClick_filterBtn, this) this.filterBtn.addEventListener(MouseEvent.CLICK, this.onClick_filterBtn, this)
this.musicBtn.addEventListener(MouseEvent.CLICK, this.onClick_musicBtn, this)
}
onClick_musicBtn() {
this.isPlayMusic = !this.isPlayMusic
} }
_bombCount: number = 0 _bombCount: number = 0
...@@ -285,7 +313,6 @@ export class PlayScene extends Scene { ...@@ -285,7 +313,6 @@ export class PlayScene extends Scene {
exchangeTarget1 exchangeTarget1
exchangeTarget2 exchangeTarget2
onClick_exchangeBtn() { onClick_exchangeBtn() {
if (this.exchanging || this.exchangeCount <= 0) { if (this.exchanging || this.exchangeCount <= 0) {
return return
} }
...@@ -372,46 +399,49 @@ export class PlayScene extends Scene { ...@@ -372,46 +399,49 @@ export class PlayScene extends Scene {
async checkExchange() { async checkExchange() {
if (this.exchangeTargetPool.length >= 2) { if (this.exchangeTargetPool.length >= 2) {
let num0 = this.board[this.exchangeTargetPool[0].cx][this.exchangeTargetPool[0].cy] showWaiting()
let num1 = this.board[this.exchangeTargetPool[1].cx][this.exchangeTargetPool[1].cy] useTools(async (s) => {
hideWaiting()
if (!s) {
this.removeAnis() //扣道具失败
this.removeAnis()
checkMusic("exchange", this.isPlayMusic) this.renderBoard()
// 交换动效 this.removeChild(this.exchangeMask)
await this.exchangeAni() this.removeAllClick()
// if (num0 == num1) { this.exchangeTargetPool = []
this.exchanging = false
this.exchangeBtn.mouseEnable = true
return
}
// console.log("选中相同元素"); let num0 = this.board[this.exchangeTargetPool[0].cx][this.exchangeTargetPool[0].cy]
// this.exchangeTargetPool[0].removeChild(this.exchangeTargetPool[0].exchangeTips) let num1 = this.board[this.exchangeTargetPool[1].cx][this.exchangeTargetPool[1].cy]
// this.exchangeTargetPool[1].removeChild(this.exchangeTargetPool[1].exchangeTips)
// this.removeAllClick() this.removeAnis()
// this.exchangeTargetPool = [] // 交换动效
// this.exchanging = false checkMusic("exchange", this.isPlayMusic)
// return // 交换动效
// } await this.exchangeAni()
// 进行扣道具
let tem = num0 let tem = num0
num0 = num1 num0 = num1
num1 = tem num1 = tem
this.board[this.exchangeTargetPool[0].cx][this.exchangeTargetPool[0].cy] = num0 this.board[this.exchangeTargetPool[0].cx][this.exchangeTargetPool[0].cy] = num0
this.board[this.exchangeTargetPool[1].cx][this.exchangeTargetPool[1].cy] = num1 this.board[this.exchangeTargetPool[1].cx][this.exchangeTargetPool[1].cy] = num1
this.renderBoard() this.renderBoard()
this.removeChild(this.exchangeMask) this.removeChild(this.exchangeMask)
this.removeAllClick() this.removeAllClick()
this.exchangeTargetPool = [] this.exchangeTargetPool = []
this.exchanging = false
this.exchangeBtn.mouseEnable = true
getTools() getTools()
this.exchanging = false if (!this.isGameWin())
this.exchangeBtn.mouseEnable = true this.isGameOver()
if (!this.isGameWin()) }, PropType.exchange)
this.isGameOver()
} else if (this.exchangeTargetPool.length = 1) { } else if (this.exchangeTargetPool.length = 1) {
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
...@@ -508,27 +538,39 @@ export class PlayScene extends Scene { ...@@ -508,27 +538,39 @@ export class PlayScene extends Scene {
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
if (this.board[x][y] > 0) { if (this.board[x][y] > 0) {
this.containerPool[x][y].addEventListener(MouseEvent.CLICK, (e) => { this.containerPool[x][y].addEventListener(MouseEvent.CLICK, (e) => {
// 炸弹动效 showWaiting()
var arr = []; useTools((s) => {
for (var i = 1; i <= 20; i++)arr.push(RES.getRes("bomb(" + i + ").png")); hideWaiting()
let showImage = new FrameAni(arr); if (!s) {
showImage.x = this.containerPool[x][y].x + 60 // 使用失败
showImage.y = this.containerPool[x][y].y + 60 this.removeAllClick()
showImage.scale.set(0.5, 0.5) this.removeChild(this.bombMask)
this.addChild(showImage); this.bombBtn.mouseEnable = true
showImage.play() this.bombing = false
return
checkMusic("bomb", this.isPlayMusic) }
setTimeout(() => { // 炸弹动效
this.board[x][y] = 0 var arr = [];
this.renderBoard() for (var i = 1; i <= 20; i++)arr.push(RES.getRes("bomb(" + i + ").png"));
this.removeAllClick() let showImage = new FrameAni(arr);
this.removeChild(this.bombMask) showImage.x = this.containerPool[x][y].x + 60
this.bombBtn.mouseEnable = true showImage.y = this.containerPool[x][y].y + 60
this.bombing = false showImage.scale.set(0.5, 0.5)
this.removeChild(showImage) this.addChild(showImage);
}, 300); showImage.play()
checkMusic("bomb", this.isPlayMusic)
setTimeout(() => {
this.board[x][y] = 0
this.renderBoard()
this.removeAllClick()
this.removeChild(this.bombMask)
this.bombBtn.mouseEnable = true
this.bombing = false
this.removeChild(showImage)
}, 300);
}, PropType.boom)
}, this) }, this)
} }
} }
...@@ -579,45 +621,57 @@ export class PlayScene extends Scene { ...@@ -579,45 +621,57 @@ export class PlayScene extends Scene {
this.addChild(this.doFilterBtn) this.addChild(this.doFilterBtn)
let btnFunc let btnFunc
this.doFilterBtn.addEventListener(MouseEvent.CLICK, btnFunc = () => { this.doFilterBtn.addEventListener(MouseEvent.CLICK, btnFunc = () => {
showWaiting()
useTools((s) => {
hideWaiting()
if (!s) {
this.filterBtn.mouseEnable = true
this.removeChild(this.filterMask)
this.removeChild(this.doFilterBtn)
this.filtering = false
this.removeAnis()
return
}
var arr = []; var arr = [];
for (var i = 1; i <= 17; i++)arr.push(RES.getRes("filting (" + i + ").png")); for (var i = 1; i <= 17; i++)arr.push(RES.getRes("filting (" + i + ").png"));
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
if (this.board[x][y] > 0 && this.board[x][y] < 128) { if (this.board[x][y] > 0 && this.board[x][y] < 128) {
// 滤网动效 // 滤网动效
let showImage = new FrameAni(arr); let showImage = new FrameAni(arr);
showImage.x = this.containerPool[x][y].x + 60 showImage.x = this.containerPool[x][y].x + 60
showImage.y = this.containerPool[x][y].y + 60 showImage.y = this.containerPool[x][y].y + 60
showImage.scale.set(0.9, 0.9) showImage.scale.set(0.9, 0.9)
this.addChild(showImage); this.addChild(showImage);
showImage.play() showImage.play()
setTimeout(() => { setTimeout(() => {
this.removeChild(showImage) this.removeChild(showImage)
}, 500); }, 500);
Tween.get(this.containerPool[x][y].children[0]) Tween.get(this.containerPool[x][y].children[0])
.to({ scaleX: 0, scaleY: 0 }, 200) .to({ scaleX: 0, scaleY: 0 }, 200)
.call(() => { .call(() => {
this.containerPool[x][y].removeChild(this.containerPool[x][y].children[0]) this.containerPool[x][y].removeChild(this.containerPool[x][y].children[0])
}) })
this.board[x][y] = 0 this.board[x][y] = 0
}
} }
} }
} checkMusic("bomb", this.isPlayMusic)
this.filterMask.removeAllEventListener()
this.filterMask.removeAllEventListener() this.doFilterBtn.removeAllEventListener()
this.doFilterBtn.removeAllEventListener() setTimeout(() => {
setTimeout(() => { this.renderBoard()
this.renderBoard() this.filterBtn.mouseEnable = true
this.filterBtn.mouseEnable = true this.removeChild(this.filterMask)
this.removeChild(this.filterMask) this.removeChild(this.doFilterBtn)
this.removeChild(this.doFilterBtn) this.filtering = false
this.filtering = false this.removeAnis()
this.removeAnis() if (!this.isGameWin())
if (!this.isGameWin()) this.isGameOver()
this.isGameOver() }, 300);
}, 300); }, PropType.net)
}, this) }, this)
} }
...@@ -712,6 +766,7 @@ export class PlayScene extends Scene { ...@@ -712,6 +766,7 @@ export class PlayScene extends Scene {
this.exchangeBtn.removeEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this) this.exchangeBtn.removeEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this)
this.bombBtn.removeEventListener(MouseEvent.CLICK, this.onClick_bombBtn, this) this.bombBtn.removeEventListener(MouseEvent.CLICK, this.onClick_bombBtn, this)
this.filterBtn.removeEventListener(MouseEvent.CLICK, this.onClick_filterBtn, this) this.filterBtn.removeEventListener(MouseEvent.CLICK, this.onClick_filterBtn, this)
this.musicBtn.removeEventListener(MouseEvent.CLICK, this.onClick_musicBtn, this)
} }
async checkMove() { async checkMove() {
...@@ -878,8 +933,8 @@ export class PlayScene extends Scene { ...@@ -878,8 +933,8 @@ export class PlayScene extends Scene {
this.containerPool[x][y].addChild(ele) this.containerPool[x][y].addChild(ele)
if (num >= this.unlockScore) { if (num >= this.unlockGrade) {
this.unlockScore = num this.unlockGrade = num
} }
} }
} }
...@@ -931,9 +986,11 @@ export class PlayScene extends Scene { ...@@ -931,9 +986,11 @@ export class PlayScene extends Scene {
} }
currMoveType currMoveType
combineCount: number = 0
moveToLeft(type) { moveToLeft(type) {
let arr = [], tag = false let arr = [], tag = false
this.currMoveType = "left" this.currMoveType = "left"
this.combineCount = 0
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
arr[x] = new Array() arr[x] = new Array()
arr[x] = this.board[x] arr[x] = this.board[x]
...@@ -942,6 +999,14 @@ export class PlayScene extends Scene { ...@@ -942,6 +999,14 @@ export class PlayScene extends Scene {
this.updateArr(arr[x], x) this.updateArr(arr[x], x)
} }
} }
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
} else {
checkMusic("createEles", this.isPlayMusic)
}
}
if (tag && type) { if (tag && type) {
this.board = arr this.board = arr
} }
...@@ -952,6 +1017,7 @@ export class PlayScene extends Scene { ...@@ -952,6 +1017,7 @@ export class PlayScene extends Scene {
moveToTop(type) { moveToTop(type) {
let arr = [], tag = false let arr = [], tag = false
this.currMoveType = "top" this.currMoveType = "top"
this.combineCount = 0
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
arr[y] = new Array() arr[y] = new Array()
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
...@@ -960,8 +1026,18 @@ export class PlayScene extends Scene { ...@@ -960,8 +1026,18 @@ export class PlayScene extends Scene {
tag = tag || this.canMove(arr[y]) tag = tag || this.canMove(arr[y])
if (type) { if (type) {
this.updateArr(arr[y], y) this.updateArr(arr[y], y)
}
}
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
} else {
checkMusic("createEles", this.isPlayMusic)
} }
} }
if (tag && type) { if (tag && type) {
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
...@@ -978,6 +1054,7 @@ export class PlayScene extends Scene { ...@@ -978,6 +1054,7 @@ export class PlayScene extends Scene {
moveToRight(type) { moveToRight(type) {
let arr = [], tag = false let arr = [], tag = false
this.currMoveType = "right" this.currMoveType = "right"
this.combineCount = 0
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
arr[x] = new Array() arr[x] = new Array()
// 数组反向传入处理函数 // 数组反向传入处理函数
...@@ -989,6 +1066,14 @@ export class PlayScene extends Scene { ...@@ -989,6 +1066,14 @@ export class PlayScene extends Scene {
if (type) this.updateArr(arr[x], x) if (type) this.updateArr(arr[x], x)
} }
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
} else {
checkMusic("createEles", this.isPlayMusic)
}
}
// 数组再一次反向 即为此方向上的正确值顺序 // 数组再一次反向 即为此方向上的正确值顺序
if (tag && type) { if (tag && type) {
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
...@@ -1004,6 +1089,7 @@ export class PlayScene extends Scene { ...@@ -1004,6 +1089,7 @@ export class PlayScene extends Scene {
moveToBottom(type) { moveToBottom(type) {
let arr = [], tag = false let arr = [], tag = false
this.currMoveType = "bottom" this.currMoveType = "bottom"
this.combineCount = 0
for (let y = 0; y < 4; y++) { for (let y = 0; y < 4; y++) {
arr[y] = new Array() arr[y] = new Array()
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
...@@ -1012,6 +1098,16 @@ export class PlayScene extends Scene { ...@@ -1012,6 +1098,16 @@ export class PlayScene extends Scene {
tag = tag || this.canMove(arr[y]) tag = tag || this.canMove(arr[y])
if (type) this.updateArr(arr[y], y) if (type) this.updateArr(arr[y], y)
} }
if (this.combineCount > 0) {
if (this.combineCount == 1) {
checkMusic("createEle", this.isPlayMusic)
} else {
checkMusic("createEles", this.isPlayMusic)
}
}
if (tag && type) { if (tag && type) {
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
arr[x].reverse() arr[x].reverse()
...@@ -1083,8 +1179,11 @@ export class PlayScene extends Scene { ...@@ -1083,8 +1179,11 @@ export class PlayScene extends Scene {
arr.splice(i, 1) arr.splice(i, 1)
arr.push(0) arr.push(0)
this.combineCount++
//一次性走完就让 i = 0 例如 2240 =》8000 //一次性走完就让 i = 0 例如 2240 =》8000
//i = 0 //此处不能 i -= 1 [8,2,2,4]会出问题 //i = 0 //此处不能 i -= 1 [8,2,2,4]会出问题
// 播放对应合成svga // 播放对应合成svga
this.createArr.forEach((num, idx) => { this.createArr.forEach((num, idx) => {
if (num === arr[i - 1]) { if (num === arr[i - 1]) {
......
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