Commit c84a6d20 authored by spc's avatar spc

modified: src/com/SuccessNoAwardPanel.ts

parent 078d9f48
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel"; import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { GDispatcher } from "../Main";
import { sendTbNet, TbNetName } from "../TaoBaoNet"; import { sendTbNet, TbNetName } from "../TaoBaoNet";
export class FailedPanel extends Panel { export class FailedPanel extends Panel {
...@@ -22,7 +23,7 @@ export class FailedPanel extends Panel { ...@@ -22,7 +23,7 @@ export class FailedPanel extends Panel {
playAgainBtn.x = bg.width - playAgainBtn.width >> 1 playAgainBtn.x = bg.width - playAgainBtn.width >> 1
playAgainBtn.y = 350 playAgainBtn.y = 350
this.addChild(playAgainBtn) this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this) playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.playAgain, this)
} }
// 退出游戏 返回主页 // 退出游戏 返回主页
...@@ -30,4 +31,11 @@ export class FailedPanel extends Panel { ...@@ -30,4 +31,11 @@ export class FailedPanel extends Panel {
this.hidePanel() this.hidePanel()
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') }) sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
} }
// 再来一局
playAgain() {
this.hidePanel()
GDispatcher.dispatchEvent("gameReset")
}
} }
\ No newline at end of file
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel"; import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { GDispatcher } from "../Main";
import { sendTbNet, TbNetName } from "../TaoBaoNet"; import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
...@@ -18,7 +19,7 @@ export class SuccessNoAwardPanel extends Panel { ...@@ -18,7 +19,7 @@ export class SuccessNoAwardPanel extends Panel {
this.addChild(closeBtn) this.addChild(closeBtn)
closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this) closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
// let text = Tools.getText(this.data && this.data.type == 6 ? "抽奖次数+" + this.data.num : "奖品与你擦肩而过,\n再接再励哦~", 30, "#fff", FYGE.TEXT_ALIGN.CENTER) // let text = Tools.getText(this.data && this.data.type == 6 ? "抽奖次数+" + this.data.num : "奖品与你擦肩而过,\n再接再励哦~", 30, "#fff", FYGE.TEXT_ALIGN.CENTER)
let text = Tools.getText(this.data && this.data.type == 6 ? "抽奖次数+" + this.data.num : "奖品与你擦肩而过,\n再接再励哦~", 30, "#fff", FYGE.TEXT_ALIGN.CENTER) let text = Tools.getText(this.data && this.data.type == 6 ? "抽奖次数+" + this.data.num : "奖品与你擦肩而过,\n再接再励哦~", 30, "#fff", FYGE.TEXT_ALIGN.CENTER)
...@@ -31,7 +32,7 @@ export class SuccessNoAwardPanel extends Panel { ...@@ -31,7 +32,7 @@ export class SuccessNoAwardPanel extends Panel {
playAgainBtn.x = bg.width - playAgainBtn.width >> 1 playAgainBtn.x = bg.width - playAgainBtn.width >> 1
playAgainBtn.y = 350 playAgainBtn.y = 350
this.addChild(playAgainBtn) this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this) playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.playAgain, this)
} }
// 退出游戏 返回主页 // 退出游戏 返回主页
...@@ -39,4 +40,10 @@ export class SuccessNoAwardPanel extends Panel { ...@@ -39,4 +40,10 @@ export class SuccessNoAwardPanel extends Panel {
this.hidePanel() this.hidePanel()
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') }) sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
} }
// 再来一局
playAgain() {
this.hidePanel()
GDispatcher.dispatchEvent("gameReset")
}
} }
\ No newline at end of file
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel"; import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins"; import { Ins } from "../Ins";
import { GDispatcher } from "../Main";
import { sendTbNet, TbNetName } from "../TaoBaoNet"; import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
...@@ -36,7 +37,7 @@ export class SuccessPanel extends Panel { ...@@ -36,7 +37,7 @@ export class SuccessPanel extends Panel {
playAgainBtn.x = (bg.width - playAgainBtn.width >> 1) + bg.width / 4 playAgainBtn.x = (bg.width - playAgainBtn.width >> 1) + bg.width / 4
playAgainBtn.y = 490 playAgainBtn.y = 490
this.addChild(playAgainBtn) this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this) playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.playAgain, this)
let seePrizeBtn = Ins.initSprite("9152efa4-2647-4354-9aec-7e23eb02bc22") let seePrizeBtn = Ins.initSprite("9152efa4-2647-4354-9aec-7e23eb02bc22")
seePrizeBtn.x = (bg.width - seePrizeBtn.width >> 1) - bg.width / 4 seePrizeBtn.x = (bg.width - seePrizeBtn.width >> 1) - bg.width / 4
...@@ -56,4 +57,11 @@ export class SuccessPanel extends Panel { ...@@ -56,4 +57,11 @@ export class SuccessPanel extends Panel {
this.hidePanel() this.hidePanel()
sendTbNet(TbNetName.seePrize, {}, (s, res) => { console.log('backToPage') }) sendTbNet(TbNetName.seePrize, {}, (s, res) => { console.log('backToPage') })
} }
// // 再来一局
playAgain() {
this.hidePanel()
GDispatcher.dispatchEvent("gameReset")
}
} }
\ No newline at end of file
...@@ -11,6 +11,8 @@ export class Star extends FYGE.Container { ...@@ -11,6 +11,8 @@ export class Star extends FYGE.Container {
tipText: FYGE.TextField = Tools.getText("1000分", 20) tipText: FYGE.TextField = Tools.getText("1000分", 20)
lightCircle: LightCircle = new LightCircle() lightCircle: LightCircle = new LightCircle()
isBling = false
constructor(text: string) { constructor(text: string) {
super() super()
this.addChild(this.starContainer) this.addChild(this.starContainer)
...@@ -38,9 +40,15 @@ export class Star extends FYGE.Container { ...@@ -38,9 +40,15 @@ export class Star extends FYGE.Container {
bling() { bling() {
this.isBling = true
this.lightCircle.play() this.lightCircle.play()
FYGE.Tween.get(this.starContainer).to({ scaleX: 0.3, scaleY: 0.3 }, 200).call(() => { FYGE.Tween.get(this.starContainer).to({ scaleX: 0.3, scaleY: 0.3 }, 200).call(() => {
this.pinkStar.visible = true this.pinkStar.visible = true
}).to({ scaleX: 1.3, scaleY: 1.3 }, 200).to({ scaleX: 1, scaleY: 1 }, 100) }).to({ scaleX: 1.3, scaleY: 1.3 }, 200).to({ scaleX: 1, scaleY: 1 }, 100)
} }
dark() {
this.isBling = false
this.pinkStar.visible = false
}
} }
\ No newline at end of file
export const config = { export const config = {
//倒计时时间s //倒计时时间s
time: 120, time: 12,
//3关分数 //3关分数
first: 1000, first: 1000,
second: 2000, second: 2000,
third: 3000, third: 3000,
//5种每个球的分数 //5种每个球的分数
score: [10, 10, 10, 10, 10], score: [1000, 10, 10, 10, 10],
//游戏难度3,4,5 //游戏难度3,4,5
difficulty: 3, difficulty: 3,
//球的资源 //球的资源
......
...@@ -212,6 +212,9 @@ export class XxlScene extends Scene { ...@@ -212,6 +212,9 @@ export class XxlScene extends Scene {
//传入的用户信息 //传入的用户信息
userInfo: UserInfo userInfo: UserInfo
//返回按钮
backBtn: FYGE.Sprite
async initUi() { async initUi() {
...@@ -221,26 +224,27 @@ export class XxlScene extends Scene { ...@@ -221,26 +224,27 @@ export class XxlScene extends Scene {
const userInfoRes = await sendTbNet(TbNetName.getUserInfo, {}) const userInfoRes = await sendTbNet(TbNetName.getUserInfo, {})
// const prizeInfoRes = sendTbNet(TbNetName.getPrizeInfo, {}) // const prizeInfoRes = sendTbNet(TbNetName.getPrizeInfo, {})
this.userInfo = userInfoRes.data as UserInfo this.userInfo = userInfoRes.data as UserInfo
(function init() {
for (var i = 0; i < that.ROW_NUM; i++) {
for (var j = 0; j < that.COL_NUM; j++) {
that.rcToIndexMap["" + i + j] = i * that.COL_NUM + j;
// console.log(i * that.COL_NUM + j)
that.indexToRcMap[i * that.COL_NUM + j] = [i, j];
(function init() { var x = that.offsetX + (i & 1) * that.radiusX / 2 + j * that.radiusX;
for (var i = 0; i < that.ROW_NUM; i++) { var y = that.offsetY + i * that.halfSq3 * that.radiusY
for (var j = 0; j < that.COL_NUM; j++) {
that.rcToIndexMap["" + i + j] = i * that.COL_NUM + j;
// console.log(i * that.COL_NUM + j)
that.indexToRcMap[i * that.COL_NUM + j] = [i, j];
var x = that.offsetX + (i & 1) * that.radiusX / 2 + j * that.radiusX;
var y = that.offsetY + i * that.halfSq3 * that.radiusY
that.rowColPositions["" + i + j] = { x: x, y: y }; that.rowColPositions["" + i + j] = { x: x, y: y };
that.indexPositions[i * that.COL_NUM + j] = { x: x, y: y }; that.indexPositions[i * that.COL_NUM + j] = { x: x, y: y };
}
} }
} })()
})()
this.robot = new Robot(!this.userInfo.win) this.robot = new Robot(!this.userInfo.win)
...@@ -250,6 +254,12 @@ export class XxlScene extends Scene { ...@@ -250,6 +254,12 @@ export class XxlScene extends Scene {
this.x = (Ins.stageW - 750) >> 1; this.x = (Ins.stageW - 750) >> 1;
this.y = (Ins.stageH - 1624) >> 1; this.y = (Ins.stageH - 1624) >> 1;
this.backBtn = Tools.getSprite(resCanvasList['334aff33-1a9e-4277-aafe-3d9f22eab3d5'].url, 0, 40 + 1624 / 2 - this.stage.viewRect.height / 2)
this.backBtn.mouseEnable = true
this.backBtn.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, () => {
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
}, this)
this.addChild(this.backBtn)
//顶部分数 //顶部分数
this.topContainer = new FYGE.Container() this.topContainer = new FYGE.Container()
...@@ -661,8 +671,17 @@ export class XxlScene extends Scene { ...@@ -661,8 +671,17 @@ export class XxlScene extends Scene {
this.level = 3 this.level = 3
this.llevelText.text = "第" + this.level + "关" this.llevelText.text = "第" + this.level + "关"
this.difficulty = 5 this.difficulty = 5
if (!this.star1.isBling) {
this.star1.bling()
}
this.star2.bling() this.star2.bling()
} else if (this.userScore >= 3000) { } else if (this.userScore >= 3000) {
if (!this.star1.isBling) {
this.star1.bling()
}
if (!this.star2.isBling) {
this.star2.bling()
}
this.star3.bling() this.star3.bling()
this.gameOver() this.gameOver()
} }
...@@ -687,6 +706,7 @@ export class XxlScene extends Scene { ...@@ -687,6 +706,7 @@ export class XxlScene extends Scene {
this.isGameEnd = true this.isGameEnd = true
this.updateFakeScore(this.robot.getScore(this.userScore, this.timeNum)) this.updateFakeScore(this.robot.getScore(this.userScore, this.timeNum))
const prizeInfo = await sendTbNet(TbNetName.getPrizeInfo) const prizeInfo = await sendTbNet(TbNetName.getPrizeInfo)
GDispatcher.addEventListener("gameReset", this.reset, this)
if (this.userInfo.win) { if (this.userInfo.win) {
//胜利 //胜利
const prize = prizeInfo.data const prize = prizeInfo.data
...@@ -1058,6 +1078,8 @@ export class XxlScene extends Scene { ...@@ -1058,6 +1078,8 @@ export class XxlScene extends Scene {
//刷新 //刷新
refresh() { refresh() {
this.g.clear()
let circleItems = this.circleItems let circleItems = this.circleItems
circleItems.forEach(co => { circleItems.forEach(co => {
...@@ -1081,6 +1103,9 @@ export class XxlScene extends Scene { ...@@ -1081,6 +1103,9 @@ export class XxlScene extends Scene {
initEvents() { initEvents() {
var that = this; var that = this;
// console.log("主场景添加事件") // console.log("主场景添加事件")
...@@ -1097,12 +1122,54 @@ export class XxlScene extends Scene { ...@@ -1097,12 +1122,54 @@ export class XxlScene extends Scene {
gameStart() { gameStart() {
// console.log("游戏开始") // console.log("游戏开始")
this.rightUserContainer.visible = true this.rightUserContainer.visible = true
this.timeNum = config.time
this.lt = 0
this.tt = 0
this.isGameStart = true this.isGameStart = true
GDispatcher.removeEventListener("MatchCompelete", this.gameStart) GDispatcher.removeEventListener("MatchCompelete", this.gameStart)
} }
async reset() {
this.selectItems.splice(0)
this.refresh()
this.isGameEnd = false
this.isGameStart = false
this.userScore = 0
//先隐藏
this.rightUserContainer.visible = false
this.lscore.text = "0"
this.rscore.text = "0"
//进度条归0
this.rect.x = this.rectX
this.star1.dark()
this.star2.dark()
this.star3.dark()
//时间初始化
this.timeNum = config.time
this.time.text = this.timeNum + ""
if (config.time >= 100) {
this.time.textWidth = 80
} else if (config.time >= 10) {
this.time.textWidth = 65
} else {
this.time.textWidth = 50
}
const userInfoRes = await sendTbNet(TbNetName.getUserInfo, {})
this.userInfo = userInfoRes.data as UserInfo
//@ts-ignore
if (this.userInfo.noGameTime && this.userInfo.noGameTime === 1) {
console.log("没有游戏次数")
} else {
this.robot = new Robot(!this.userInfo.win)
showPanel(MatchingPanel, this.userInfo)
}
}
lt = 0 lt = 0
...@@ -1174,6 +1241,7 @@ export class XxlScene extends Scene { ...@@ -1174,6 +1241,7 @@ export class XxlScene extends Scene {
that.removeEventListener(FYGE.MouseEvent.MOUSE_DOWN, that.mouseDown, that) that.removeEventListener(FYGE.MouseEvent.MOUSE_DOWN, that.mouseDown, that)
that.removeEventListener(FYGE.MouseEvent.MOUSE_UP, that.mouseUp, that); that.removeEventListener(FYGE.MouseEvent.MOUSE_UP, that.mouseUp, that);
GDispatcher.removeEventListener("gameReset", this.reset)
} }
......
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