Commit c3efc5cf authored by huangwenjie's avatar huangwenjie

1

parent a6b83c15
......@@ -79,7 +79,7 @@ export enum SoundType {
speedUp = "speedUp",
move = "move",
createEle = "createEle",
createEles = "createELes",
createEles = "createEles",
bomb = "bomb",
exchange = "exchange",
gameOver = "gameOver",
......
......@@ -149,6 +149,12 @@
"@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": {
"version": "3.3.35",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.35.tgz",
......@@ -4874,6 +4880,12 @@
"integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==",
"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": {
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz",
......
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 { MovieClip } from './../../../engine/2d/svga/MovieClip';
import { Shape } from './../../../engine/2d/graphics/Shape';
......@@ -13,7 +17,7 @@ import { Container, Sprite } from '../../../engine/2d/display';
import { Graphics } from '../../../engine/2d/graphics';
import Tween from '../../../engine/tween/Tween';
import { RES } from '../../../module/RES';
import { getTools } from '../../commonNet'
import { getTools, getSoundStatus, useTools } from '../../commonNet'
export class PlayScene extends Scene {
get groupNames() { return ["playScene"] }
......@@ -26,6 +30,8 @@ export class PlayScene extends Scene {
start() {
this.initUI()
this.initEvents()
}
board: any[] = []
......@@ -42,16 +48,29 @@ export class PlayScene extends Scene {
return this._score
}
_unlockScore = 2
set unlockScore(value) {
this._unlockScore = value
this.unlockScoreTxt.text = this._unlockScore + ""
_unlockGrade = 2
set unlockGrade(value) {
this._unlockGrade = value
this.unlockGradeTxt.text = this._unlockGrade + ""
}
get unlockScore() {
return this._unlockScore
get unlockGrade() {
return this._unlockGrade
}
isPlayMusic: boolean = true
_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")
}
}
get isPlayMusic() {
return this._isPlayMusic
}
bg: Sprite
goBackBtn: Button
......@@ -63,7 +82,7 @@ export class PlayScene extends Scene {
filterBtn: Button
filterCountTxt: TextField
scoreTxt: TextField
unlockScoreTxt: TextField
unlockGradeTxt: TextField
initUI() {
......@@ -80,7 +99,7 @@ export class PlayScene extends Scene {
this.addEventListener("updateScoreTxt", this.updateScoreTxt, this)
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.y = 1280
......@@ -167,7 +186,11 @@ export class PlayScene extends Scene {
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 = []
......@@ -235,6 +258,11 @@ export class PlayScene extends Scene {
this.exchangeBtn.addEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this)
this.bombBtn.addEventListener(MouseEvent.CLICK, this.onClick_bombBtn, 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
......@@ -285,7 +313,6 @@ export class PlayScene extends Scene {
exchangeTarget1
exchangeTarget2
onClick_exchangeBtn() {
if (this.exchanging || this.exchangeCount <= 0) {
return
}
......@@ -372,27 +399,29 @@ export class PlayScene extends Scene {
async checkExchange() {
if (this.exchangeTargetPool.length >= 2) {
showWaiting()
useTools(async (s) => {
hideWaiting()
if (!s) {
//扣道具失败
this.removeAnis()
this.renderBoard()
this.removeChild(this.exchangeMask)
this.removeAllClick()
this.exchangeTargetPool = []
this.exchanging = false
this.exchangeBtn.mouseEnable = true
return
}
let num0 = this.board[this.exchangeTargetPool[0].cx][this.exchangeTargetPool[0].cy]
let num1 = this.board[this.exchangeTargetPool[1].cx][this.exchangeTargetPool[1].cy]
this.removeAnis()
// 交换动效
checkMusic("exchange", this.isPlayMusic)
// 交换动效
await this.exchangeAni()
// if (num0 == num1) {
// console.log("选中相同元素");
// this.exchangeTargetPool[0].removeChild(this.exchangeTargetPool[0].exchangeTips)
// this.exchangeTargetPool[1].removeChild(this.exchangeTargetPool[1].exchangeTips)
// this.removeAllClick()
// this.exchangeTargetPool = []
// this.exchanging = false
// return
// }
// 进行扣道具
let tem = num0
num0 = num1
......@@ -405,13 +434,14 @@ export class PlayScene extends Scene {
this.removeChild(this.exchangeMask)
this.removeAllClick()
this.exchangeTargetPool = []
this.exchanging = false
this.exchangeBtn.mouseEnable = true
getTools()
this.exchanging = false
this.exchangeBtn.mouseEnable = true
if (!this.isGameWin())
this.isGameOver()
}, PropType.exchange)
} else if (this.exchangeTargetPool.length = 1) {
for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) {
......@@ -508,6 +538,17 @@ export class PlayScene extends Scene {
for (let y = 0; y < 4; y++) {
if (this.board[x][y] > 0) {
this.containerPool[x][y].addEventListener(MouseEvent.CLICK, (e) => {
showWaiting()
useTools((s) => {
hideWaiting()
if (!s) {
// 使用失败
this.removeAllClick()
this.removeChild(this.bombMask)
this.bombBtn.mouseEnable = true
this.bombing = false
return
}
// 炸弹动效
var arr = [];
for (var i = 1; i <= 20; i++)arr.push(RES.getRes("bomb(" + i + ").png"));
......@@ -529,6 +570,7 @@ export class PlayScene extends Scene {
this.removeChild(showImage)
}, 300);
}, PropType.boom)
}, this)
}
}
......@@ -579,6 +621,18 @@ export class PlayScene extends Scene {
this.addChild(this.doFilterBtn)
let 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 = [];
for (var i = 1; i <= 17; i++)arr.push(RES.getRes("filting (" + i + ").png"));
......@@ -604,7 +658,7 @@ export class PlayScene extends Scene {
}
}
}
checkMusic("bomb", this.isPlayMusic)
this.filterMask.removeAllEventListener()
this.doFilterBtn.removeAllEventListener()
setTimeout(() => {
......@@ -617,7 +671,7 @@ export class PlayScene extends Scene {
if (!this.isGameWin())
this.isGameOver()
}, 300);
}, PropType.net)
}, this)
}
......@@ -712,6 +766,7 @@ export class PlayScene extends Scene {
this.exchangeBtn.removeEventListener(MouseEvent.CLICK, this.onClick_exchangeBtn, this)
this.bombBtn.removeEventListener(MouseEvent.CLICK, this.onClick_bombBtn, this)
this.filterBtn.removeEventListener(MouseEvent.CLICK, this.onClick_filterBtn, this)
this.musicBtn.removeEventListener(MouseEvent.CLICK, this.onClick_musicBtn, this)
}
async checkMove() {
......@@ -878,8 +933,8 @@ export class PlayScene extends Scene {
this.containerPool[x][y].addChild(ele)
if (num >= this.unlockScore) {
this.unlockScore = num
if (num >= this.unlockGrade) {
this.unlockGrade = num
}
}
}
......@@ -931,9 +986,11 @@ export class PlayScene extends Scene {
}
currMoveType
combineCount: number = 0
moveToLeft(type) {
let arr = [], tag = false
this.currMoveType = "left"
this.combineCount = 0
for (let x = 0; x < 4; x++) {
arr[x] = new Array()
arr[x] = this.board[x]
......@@ -942,6 +999,14 @@ export class PlayScene extends Scene {
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) {
this.board = arr
}
......@@ -952,6 +1017,7 @@ export class PlayScene extends Scene {
moveToTop(type) {
let arr = [], tag = false
this.currMoveType = "top"
this.combineCount = 0
for (let y = 0; y < 4; y++) {
arr[y] = new Array()
for (let x = 0; x < 4; x++) {
......@@ -960,8 +1026,18 @@ export class PlayScene extends Scene {
tag = tag || this.canMove(arr[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) {
for (let x = 0; x < 4; x++) {
for (let y = 0; y < 4; y++) {
......@@ -978,6 +1054,7 @@ export class PlayScene extends Scene {
moveToRight(type) {
let arr = [], tag = false
this.currMoveType = "right"
this.combineCount = 0
for (let x = 0; x < 4; x++) {
arr[x] = new Array()
// 数组反向传入处理函数
......@@ -989,6 +1066,14 @@ export class PlayScene extends Scene {
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) {
for (let x = 0; x < 4; x++) {
......@@ -1004,6 +1089,7 @@ export class PlayScene extends Scene {
moveToBottom(type) {
let arr = [], tag = false
this.currMoveType = "bottom"
this.combineCount = 0
for (let y = 0; y < 4; y++) {
arr[y] = new Array()
for (let x = 0; x < 4; x++) {
......@@ -1012,6 +1098,16 @@ export class PlayScene extends Scene {
tag = tag || this.canMove(arr[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) {
for (let x = 0; x < 4; x++) {
arr[x].reverse()
......@@ -1083,8 +1179,11 @@ export class PlayScene extends Scene {
arr.splice(i, 1)
arr.push(0)
this.combineCount++
//一次性走完就让 i = 0 例如 2240 =》8000
//i = 0 //此处不能 i -= 1 [8,2,2,4]会出问题
// 播放对应合成svga
this.createArr.forEach((num, idx) => {
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