Commit b973aeff authored by spc's avatar spc

modified: project/src/canvas/game/src/com/FailedPanel.ts

parent 9299fc02
{
"code": "000000",
"data": {
"name": "一碗热翔",
"image": "//yun.duiba.com.cn/spark/assets/赚门票.21d8c2fd01dffd454116bb6c1189ba6bb74306f4.png",
"type": 1
},
"success": true,
"message": "成功"
}
}
\ No newline at end of file
......@@ -3,10 +3,10 @@
"data": {
"fakeUserName": "cccccccccc",
"fakeUserImgUrl": "https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png",
"win": true,
"win": false,
"userName": "xxxxxxxxxxx",
"userImgUrl": "https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png",
"isNewUser": true
"isNewUser": false
},
"success": true,
"message": "成功"
......
......@@ -82,7 +82,10 @@ export enum TbNetName {
getUserInfo = "mine.getUserInfo",
// 获取奖品信息
getPrizeInfo = "mine.getPrizeInfo"
getPrizeInfo = "mine.getPrizeInfo",
//查看奖品
seePrize = "mine.seePrize"
}
//返回数据类型,到时再调整
......@@ -164,7 +167,7 @@ export function sendTbNet(
//记录数据
dataRecord[netName] = d;
//统一错误信息提示,d.data为了区分网络超时
if (!hideMsg && !d.success) showToast(d.message || "网络超时")
if (!hideMsg && !d.success && netName != "mine.getPrizeInfo" && netName != "mine.getUserInfo") showToast(d.message || "网络超时")
//执行回调
callback && callback(d.success, d);
resolve(d)
......
import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
export class FailedPanel extends Panel {
initUi() {
let bg = Ins.initSprite("f45dff96-8004-4fc8-bb74-20af177cd5f3")
this.addChild(bg)
this.x = Ins.stageW - this.width >> 1
this.y = (Ins.stageH - this.height >> 1) + layers.stageOffsetY
//不显示动画
this.isShowing = true
let closeBtn = Ins.initSprite("5b61fddb-b1f8-4e24-bc2a-e356b540d70c")
closeBtn.x = this.width - closeBtn.width + 20
closeBtn.y = -20
this.addChild(closeBtn)
closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
let playAgainBtn = Ins.initSprite("77c6c9c9-5855-4b90-977e-27a2ffb8cd66")
playAgainBtn.x = bg.width - playAgainBtn.width >> 1
playAgainBtn.y = 350
this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
}
// 退出游戏 返回主页
back() {
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
}
}
\ No newline at end of file
import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { Tools } from "../Tools";
export class SuccessNoAwardPanel extends Panel {
initUi() {
let bg = Ins.initSprite("1b34f12b-ba72-41ec-848f-9e0de49403ee")
this.addChild(bg)
this.x = Ins.stageW - this.width >> 1
this.y = (Ins.stageH - this.height >> 1) + layers.stageOffsetY
//不显示动画
this.isShowing = true
let closeBtn = Ins.initSprite("647ae09a-7d11-4e03-96a2-ec8355e44a04")
closeBtn.x = this.width - closeBtn.width + 20
closeBtn.y = -20
this.addChild(closeBtn)
closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
let text = Tools.getText(this.data && this.data.type == 6 ? "抽奖次数+1" : "奖品与你擦肩而过,\n再接再励哦~", 30,"#fff",FYGE.TEXT_ALIGN.CENTER)
text.x = bg.width - text.textWidth >> 1
text.y = bg.height - text.textHeight >> 1
this.addChild(text)
let playAgainBtn = Ins.initSprite("77c6c9c9-5855-4b90-977e-27a2ffb8cd66")
playAgainBtn.x = bg.width - playAgainBtn.width >> 1
playAgainBtn.y = 350
this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
}
// 退出游戏 返回主页
back() {
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
}
}
\ No newline at end of file
import { layers } from "../../module/views/layers";
import { Panel } from "../../module/views/Panel";
import { Ins } from "../Ins";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { Tools } from "../Tools";
export class SuccessPanel extends Panel {
initUi() {
let bg = Ins.initSprite("024b1ca1-1da7-4279-8bfd-1826e440525d")
this.addChild(bg)
this.x = Ins.stageW - this.width >> 1
this.y = (Ins.stageH - this.height >> 1) + layers.stageOffsetY
//不显示动画
this.isShowing = true
let closeBtn = Ins.initSprite("647ae09a-7d11-4e03-96a2-ec8355e44a04")
closeBtn.x = this.width - closeBtn.width + 20
closeBtn.y = -20
this.addChild(closeBtn)
closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
let text = Tools.getText(this.data.name, 30, "#fff", FYGE.TEXT_ALIGN.CENTER)
text.x = bg.width - text.textWidth >> 1
text.y = (bg.height - text.textHeight >> 1) - 90
this.addChild(text)
let awardImg = this.data.image ? FYGE.Sprite.fromUrl(this.data.image) : Ins.initSprite("652675b5-b20f-4069-9568-f4ae633a0b7d")
awardImg.width = awardImg.height = 200
awardImg.x = bg.width - awardImg.width >> 1
awardImg.y = (bg.height - awardImg.height >> 1) + 40
this.addChild(awardImg)
let playAgainBtn = Ins.initSprite("5c1a2887-809b-4443-80cd-6f5526ebb540")
playAgainBtn.x = (bg.width - playAgainBtn.width >> 1) + bg.width / 4
playAgainBtn.y = 490
this.addChild(playAgainBtn)
playAgainBtn.addEventListener(FYGE.MouseEvent.CLICK, this.back, this)
let seePrizeBtn = Ins.initSprite("9152efa4-2647-4354-9aec-7e23eb02bc22")
seePrizeBtn.x = (bg.width - seePrizeBtn.width >> 1) - bg.width / 4
seePrizeBtn.y = 490
this.addChild(seePrizeBtn)
seePrizeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.seePrize, this)
}
// 退出游戏 返回主页
back() {
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
}
// 查看奖品
seePrize() {
sendTbNet(TbNetName.seePrize, {}, (s, res) => { console.log('backToPage') })
}
}
\ No newline at end of file
import { config } from "./XxlConfig"
export class Robot {
......@@ -10,12 +11,13 @@ export class Robot {
getScore(userScore: number, gameLeftTime: number): number {
if (this._time < 0) {
this._time = 120 + Math.random() * 60
if (this._needWin) {
//机器人赢
if (userScore > 2600) {
this._score = 3000 + (Math.floor(Math.random() * 8) + 2) * 10
} else {
if (gameLeftTime > 60) {
if (gameLeftTime > config.time / 2) {
if (this._score > userScore) {
this._score += (Math.floor(Math.random() * 6) + 2) * 10
} else {
......@@ -32,19 +34,19 @@ export class Robot {
} else {
//机器人输
console.log("進來了")
if (this._score >= userScore) {
return this._score
} else {
//应该的分数
let gapScore = userScore - this._score
let randomScore = (Math.floor(Math.random() * 3) + 2) * 10
let randomScore = (Math.floor(Math.random() * 2) + 2) * 10
if (randomScore < gapScore) {
this._score += randomScore
return this._score
}
}
}
this._time = 120 + Math.random() * 60
}
this._time--
return this._score
......
......@@ -14,6 +14,9 @@ import { config } from "./XxlConfig";
import { MatchingPanel } from "../com/MatchingPanel";
import { GDispatcher } from "../Main";
import { Robot } from "./Robot";
import { FailedPanel } from "../com/FailedPanel";
import { SuccessNoAwardPanel } from "../com/SuccessNoAwardPanel";
import { SuccessPanel } from "../com/SuccessPanel";
declare interface point {
x: number;
......@@ -210,6 +213,8 @@ export class XxlScene extends Scene {
userInfo: UserInfo
async initUi() {
this.objectPool = new ObjectPool()
let that = this;
......@@ -331,7 +336,6 @@ export class XxlScene extends Scene {
this.topContainer.addChild(leftUserContainer)
console.log(this.width,)
//右边用户信息
......@@ -667,20 +671,26 @@ export class XxlScene extends Scene {
}).to({ scaleX: 1.5, scaleY: 1.5 }, 200).to({ scaleX: 1, scaleY: 1 }, 200)
}
gameOver() {
async gameOver() {
this.isGameEnd = true
if (this.userInfo.win) {
//胜利
const prizeInfo = await sendTbNet(TbNetName.getPrizeInfo)
const prize = prizeInfo.data
if (prize.type > 3) {
showPanel(SuccessPanel, prize)
} else {
showPanel(SuccessNoAwardPanel, prize)
}
} else {
//失败
showPanel(FailedPanel)
}
}
// 退出游戏 返回主页
backToPage() {
sendTbNet(TbNetName.backToPage, {}, (s, res) => { console.log('backToPage') })
}
updateProgress(per: number) {
......
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