Commit ebb238c9 authored by spc's avatar spc

modified: project/src/canvas/game/src/TaoBaoNet.ts

parent a7923cce
{
"code": "000000",
"data": {
},
"success": true,
"message": "成功"
}
{
"code": "000000",
"data": {
"fakeUserName": "cccccccccc",
"fakeUserImgUrl": "https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png",
"win": true,
"userName": "xxxxxxxxxxx",
"userImgUrl": "https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png",
"isNewUser": true
},
"success": true,
"message": "成功"
}
\ No newline at end of file
......@@ -268,6 +268,30 @@ const resCanvasList = {
ext: '.png',
url: '//yun.duiba.com.cn/spark-dev/assets/PK.f7e4bb9029bf786ff55396b5480213664f6451fd.png',
uuid: '5bc08e08-54d1-4b67-a146-679c4ce1984d'
},
'1aaad06e-0c83-4ce1-a34b-89e1827fdf6b': {
name: '引导2',
ext: '.png',
url: '//yun.duiba.com.cn/spark-dev/assets/引导2.73f43e52ed6e331c0f6f495c41e3133ef3ff166e.png',
uuid: '1aaad06e-0c83-4ce1-a34b-89e1827fdf6b'
},
'8ec95cad-73d7-4d81-8394-9ff688f8407b': {
name: '引导3',
ext: '.png',
url: '//yun.duiba.com.cn/spark-dev/assets/引导3.846cfb2168642f0c3ccc8e55aa5c254b60d22d66.png',
uuid: '8ec95cad-73d7-4d81-8394-9ff688f8407b'
},
'c6193d9b-bd32-4929-a5fe-90d3da65215e': {
name: '引导4',
ext: '.png',
url: '//yun.duiba.com.cn/spark-dev/assets/引导4.d4de05da4af15a51897475371dcd560e475ce332.png',
uuid: 'c6193d9b-bd32-4929-a5fe-90d3da65215e'
},
'427a3ff3-01b0-485c-8c65-b63e7139ef2f': {
name: '引导1',
ext: '.png',
url: '//yun.duiba.com.cn/spark-dev/assets/引导1.bee6160a10e790308c2f02b27374a62860fe43d2.png',
uuid: '427a3ff3-01b0-485c-8c65-b63e7139ef2f'
}
};
export default resCanvasList;
\ No newline at end of file
......@@ -125,7 +125,7 @@ export class Main {
this.loadImageTextures(resCanvasList).then(res => {
// changeScene(OpenAni)
changeScene(XxlScene, { fakeUserName: 'cccccccccc', fakeUserImgUrl: 'https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png', win: true, userName: 'xxxxxxxxxxx', userImgUrl: 'https://yun.duiba.com.cn/spark-dev/assets/白色.41dae4fd01f4750aea58f694b40d97a9da8f23ca.png' })
changeScene(XxlScene)
})
await InitLottie.initLottieList(resLottieList);
......
......@@ -76,7 +76,13 @@ export enum TbNetName {
reportAnalytics = "mine.reportAnalytics",
// 推出游戏 返回主页
backToPage = "mine.backToPage"
backToPage = "mine.backToPage",
// 获取用户信息
getUserInfo = "mine.getUserInfo",
// 获取奖品信息
getPrizeInfo = "mine.getPrizeInfo"
}
//返回数据类型,到时再调整
......
import { layers } from "../../module/views/layers"
import { Panel } from "../../module/views/Panel"
import { Ins } from "../Ins"
import { GDispatcher } from "../Main"
import { sendTbNet, TbNetName } from "../TaoBaoNet"
import { Tools } from "../Tools"
......@@ -31,6 +33,7 @@ export class MatchingPanel extends Panel {
this.matchImg.y = 300
this.addChild(this.matchImg)
this.matching()
}
matching() {
......@@ -62,7 +65,7 @@ export class MatchingPanel extends Panel {
leftAvatarBg.y = -25
lContainer.addChild(leftAvatarBg)
//头像
let leftAvatar = Ins.initSprite("")
let leftAvatar = FYGE.Sprite.fromUrl(this.data.userImgUrl)
leftAvatar.x = leftAvatarBg.x
leftAvatar.y = -25
lContainer.addChild(leftAvatar)
......@@ -74,7 +77,7 @@ export class MatchingPanel extends Panel {
leftAvatar.mask = lcircle
//昵称
let lnickName = Tools.getText("xxxxxxxxxx", 30, "#fff", FYGE.TEXT_ALIGN.RIGHT, 180)
let lnickName = Tools.getText(this.data.userName, 30, "#fff", FYGE.TEXT_ALIGN.RIGHT, 180)
lnickName.y = 40
lContainer.addChild(lnickName)
......@@ -95,7 +98,7 @@ export class MatchingPanel extends Panel {
rightAvatarBg.y = -25
rContainer.addChild(rightAvatarBg)
//头像
let rightAvatar = Ins.initSprite("")
let rightAvatar = FYGE.Sprite.fromUrl(this.data.fakeUserImgUrl)
rightAvatar.x = rightAvatarBg.x
rightAvatar.y = -25
rContainer.addChild(rightAvatar)
......@@ -107,7 +110,7 @@ export class MatchingPanel extends Panel {
rightAvatar.mask = rcircle
//昵称
let rnickName = Tools.getText("xxxxxxxxxx", 30, "#fff", FYGE.TEXT_ALIGN.LEFT, 180)
let rnickName = Tools.getText(this.data.fakeUserName, 30, "#fff", FYGE.TEXT_ALIGN.LEFT, 180)
rnickName.x = right.width - 180
rnickName.y = 40
rContainer.addChild(rnickName)
......@@ -121,7 +124,7 @@ export class MatchingPanel extends Panel {
pk.anchorY = pk.height >> 1
pk.y = (this.bg.height - pk.height >> 1) + 35
this.addChild(pk)
FYGE.Tween.get(pk).set({ scaleX: 5, scaleY: 5, alpha: 0 }).wait(100).to({ scaleX: 1, scaleY: 1, alpha: 1 }, 300)
FYGE.Tween.get(pk).set({ scaleX: 5, scaleY: 5, alpha: 0 }).wait(100).to({ scaleX: 1, scaleY: 1, alpha: 1 }, 200)
let sq = Ins.initSprite("c1875fdc-c1a1-491a-ba5b-1783f87e8d06")
sq.x = this.bg.width - sq.width >> 1
......@@ -129,5 +132,9 @@ export class MatchingPanel extends Panel {
FYGE.Tween.get(sq).set({ alpha: 0 }).to({ alpha: 1 }, 200)
this.addChild(sq)
setTimeout(() => {
this.hidePanel()
GDispatcher.dispatchEvent("MatchCompelete")
}, 1000)
}
}
\ No newline at end of file
export const config = {
//倒计时时间s
time: 103,
time: 120,
//3关分数
first: 1000,
second: 2000,
......
......@@ -12,6 +12,7 @@ import { Star } from "./Star";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { config } from "./XxlConfig";
import { MatchingPanel } from "../com/MatchingPanel";
import { GDispatcher } from "../Main";
declare interface point {
x: number;
......@@ -30,6 +31,15 @@ class noder {
}
}
interface UserInfo {
fakeUserName: string,
fakeUserImgUrl: string,
win: boolean,
userName: string,
userImgUrl: string,
isNewUser: boolean
}
export class XxlScene extends Scene {
bg: FYGE.Sprite
......@@ -41,7 +51,7 @@ export class XxlScene extends Scene {
//倒计时
time: FYGE.TextField
timeNum: number = 0
timeNum: number = config.time
//左边用户昵称
lnickname: FYGE.TextField
......@@ -87,6 +97,8 @@ export class XxlScene extends Scene {
//是否可以游戏
isGameStart: boolean = false
//游戏是否结束
isGameEnd: boolean = false
/**
* 右移偶数行
......@@ -149,8 +161,6 @@ export class XxlScene extends Scene {
*/
indexPositions: point[] = [];
/**
* circleItem数组
*/
......@@ -176,16 +186,22 @@ export class XxlScene extends Scene {
//是否正在消除
isRemove: boolean = false
//引导页
guideRes = ["427a3ff3-01b0-485c-8c65-b63e7139ef2f", "1aaad06e-0c83-4ce1-a34b-89e1827fdf6b", "8ec95cad-73d7-4d81-8394-9ff688f8407b", "c6193d9b-bd32-4929-a5fe-90d3da65215e"]
//传入的用户信息
userInfo: UserInfo
async initUi() {
this.objectPool = new ObjectPool()
initUi() {
let that = this;
const userInfoRes = await sendTbNet(TbNetName.getUserInfo, {})
this.isGameStart = true
// const prizeInfoRes = sendTbNet(TbNetName.getPrizeInfo, {})
this.objectPool = new ObjectPool()
this.userInfo = userInfoRes.data as UserInfo
let that = this;
(function init() {
for (var i = 0; i < that.ROW_NUM; i++) {
......@@ -203,7 +219,6 @@ export class XxlScene extends Scene {
}
})()
showPanel(MatchingPanel)
this.bg = Ins.initSprite("7fcd3fb3-57bd-436a-afca-989b68b6b311")
......@@ -254,7 +269,7 @@ export class XxlScene extends Scene {
circle.y = 77
leftUserContainer.addChild(circle)
this.lavatar = FYGE.Sprite.fromUrl(this.data.userImgUrl)
this.lavatar = FYGE.Sprite.fromUrl(this.userInfo.userImgUrl)
this.lavatar.mask = circle
this.lavatar.x = 60
......@@ -275,7 +290,7 @@ export class XxlScene extends Scene {
leftUserContainer.addChild(this.lscore)
//用户昵称
this.lnickname = Tools.getText(this.data.userName, 18, "#ffffff", FYGE.TEXT_ALIGN.LEFT)
this.lnickname = Tools.getText(this.userInfo.userName, 18, "#ffffff", FYGE.TEXT_ALIGN.LEFT)
this.lnickname.bold = true
this.lnickname.x = 175
this.lnickname.y = 35
......@@ -311,7 +326,7 @@ export class XxlScene extends Scene {
circle2.y = 77
rightUserContainer.addChild(circle2)
this.ravatar = FYGE.Sprite.fromUrl(this.data.fakeUserImgUrl)
this.ravatar = FYGE.Sprite.fromUrl(this.userInfo.fakeUserImgUrl)
this.ravatar.mask = circle2
this.ravatar.x = Ins.stageW - 50 - ravatarBg.width
......@@ -331,7 +346,7 @@ export class XxlScene extends Scene {
rightUserContainer.addChild(this.rscore)
//用户昵称
this.rnickname = Tools.getText(this.data.fakeUserName, 18, "#ffffff", FYGE.TEXT_ALIGN.RIGHT)
this.rnickname = Tools.getText(this.userInfo.fakeUserName, 18, "#ffffff", FYGE.TEXT_ALIGN.RIGHT)
this.rnickname.bold = true
this.rnickname.x = Ins.stageW - 175 - this.rnickname.textWidth
this.rnickname.y = 35
......@@ -499,6 +514,25 @@ export class XxlScene extends Scene {
}
// console.log(this.ItemMap)
if (this.userInfo.isNewUser) {
let i = 0
let guide = Ins.initSprite(this.guideRes[i])
guide.addEventListener(FYGE.MouseEvent.CLICK, () => {
i++
if (i > this.guideRes.length - 1) {
guide.visible = false
setTimeout(() => {
showPanel(MatchingPanel, this.userInfo)
}, 200)
} else {
guide.texture = Ins.getRes(this.guideRes[i])
}
}, this)
this.addChild(guide)
} else {
showPanel(MatchingPanel, this.userInfo)
}
}
......@@ -528,8 +562,8 @@ export class XxlScene extends Scene {
}
gameOver() {
this.isGameStart = false
if (this.data.win) {
this.isGameEnd = true
if (this.userInfo.win) {
//胜利
} else {
//失败
......@@ -548,7 +582,7 @@ export class XxlScene extends Scene {
}
updateFakeScore(userGetScore: number) {
if (this.data.win) {
if (this.userInfo.win) {
FYGE.Tween.get(this.rscore).to({ scaleX: 1.5, scaleY: 1.5 }, 200).call(() => {
this.rscore.text = "" + (this.userScore - ~Math.random() * 5)
this.rscore.x = Ins.stageW - 175 - this.rscore.textWidth
......@@ -560,8 +594,8 @@ export class XxlScene extends Scene {
mouseDown(e) {
if (this.isRemove || !this.isGameStart) {
console.log("游戏结束")
if (this.isRemove || !this.isGameStart || this.isGameEnd) {
console.log("游戏不可操作")
return
}
let p: point = { x: e.localX - this.container.x, y: e.localY - this.container.y }
......@@ -847,18 +881,34 @@ export class XxlScene extends Scene {
that.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, that.mouseDown, that)
that.addEventListener(FYGE.MouseEvent.MOUSE_UP, that.mouseUp, that);
that.addEventListener(FYGE.Event.ENTER_FRAME, that.updateFrame, this)
that.addEventListener(FYGE.Event.ENTER_FRAME, that.updateFrame, that)
GDispatcher.addEventListener("MatchCompelete", this.gameStart, that)
}
gameStart() {
console.log("游戏开始")
this.isGameStart = true
GDispatcher.removeEventListener("MatchCompelete", this.gameStart)
}
lt = 0
tt = 0
updateFrame() {
if (!this.isGameStart) {
console.log("游戏未开始")
return
}
if (this.isGameEnd) {
this.gameOver()
console.log("游戏结束")
return
}
if (this.tt >= config.time) {
this.time.text = "0"
this.gameOver()
return
}
if (this.lt) {
let nt = new Date().getTime()
let dt = nt - this.lt
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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