Commit 39ac0990 authored by 王勇霞's avatar 王勇霞

接口接入活动页

parent 5bd7925a
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>畅玩欢乐城</title> <title>21天"云"健身</title>
<meta name="viewport" <meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /> content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
......
{
"success": true,
"message": "",
"code": "",
"data": {
"ruleIdList": [
"ru_1",
"ru_2",
"ru_3",
"ru_4"
],
"drawStatus": 12,
"prizeId": "aa",
"gameCounts": 1
}
}
\ No newline at end of file
{
"success": true,
"desc": "labore amet laboris sit",
"data": {
"dataInfo": [
{
"num": 1,
"context": "闲看云",
"ifComplete": false,
"count": 74413176.81524068
},
{
"num": 2,
"context": "卷",
"ifComplete": false,
"count": 10
},
{
"num": 3,
"context": null,
"ifComplete": false,
"count": 10
},
{
"num": 5,
"context": "自在休闲",
"ifComplete": true,
"count": 10
},
{
"num": 4,
"context": "自在休闲",
"ifComplete": false,
"count": 10
}
],
"collectCount": 1,
"ifFirstPlay": true
},
"code": "ipsum est tempor qui",
"timestamp": 3627649.9094133973
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": 1234
}
\ No newline at end of file
{
"success": true,
"message": "",
"code": "",
"data": {
"type": 1,
"status": 1,
"prize": {
"prizeId": "sp_1",
"prizeType": 1,
"optionId": "sdhjfhjhjjj",
"optionName": "10元话费",
"optionImg": "https://www.baidu.com/xxoo2.png",
"userRecordId": 1235,
"url": "https://www.baidu.com/order/1235"
}
}
}
\ No newline at end of file
{
"success": true,
"desc": "tempor et pariatur id",
"data": {
"startId": 72322899
},
"code": "ipsum quis nulla",
"timestamp": 29586841
}
\ No newline at end of file
{
"success": true,
"desc": "elit ipsum magna est",
"data": {
"point": -34090916
},
"code": "ut",
"timestamp": 1032620
}
\ No newline at end of file
...@@ -509,45 +509,23 @@ ...@@ -509,45 +509,23 @@
} }
}, },
{ {
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png", "keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene", "name": "StartScene",
"atlas": { "atlas": {
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": { "titile.png": {
"x": 754, "x": 2,
"y": 2, "y": 2,
"w": 574, "w": 574,
"h": 177, "h": 126,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 574, "sw": 574,
"sh": 177, "sh": 177,
"ro": true "ro": false
}, },
"startbtn.png": { "startbtn.png": {
"x": 2, "x": 2,
"y": 911, "y": 130,
"w": 350, "w": 350,
"h": 99, "h": 99,
"ox": 0, "ox": 0,
...@@ -556,31 +534,31 @@ ...@@ -556,31 +534,31 @@
"sh": 99, "sh": 99,
"ro": false "ro": false
}, },
"startop.png": { "collect.png": {
"x": 754, "x": 2,
"y": 578, "y": 231,
"w": 117, "w": 308,
"h": 196, "h": 50,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 117, "sw": 308,
"sh": 196, "sh": 50,
"ro": false "ro": false
}, },
"backbtn.png": { "backbtn.png": {
"x": 754, "x": 354,
"y": 776, "y": 130,
"w": 145, "w": 145,
"h": 62, "h": 62,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 145, "sw": 145,
"sh": 62, "sh": 62,
"ro": false "ro": true
}, },
"rulebtn.png": { "rulebtn.png": {
"x": 754, "x": 418,
"y": 840, "y": 130,
"w": 138, "w": 138,
"h": 62, "h": 62,
"ox": 0, "ox": 0,
......
resource/StartScene/titile.png

90.9 KB | W: | H:

resource/StartScene/titile.png

83.9 KB | W: | H:

resource/StartScene/titile.png
resource/StartScene/titile.png
resource/StartScene/titile.png
resource/StartScene/titile.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"name": "RulePanel" "name": "RulePanel"
}, },
{ {
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png", "keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene" "name": "StartScene"
}, },
{ {
......
...@@ -24,7 +24,12 @@ export class Main { ...@@ -24,7 +24,12 @@ export class Main {
private requestID; private requestID;
private _pause: boolean; private _pause: boolean;
private canvas: HTMLCanvasElement private canvas: HTMLCanvasElement
constructor(canvas: HTMLCanvasElement) { constructor(canvas: HTMLCanvasElement, data = {
time: 60,
longitude: "",
latitude: ""
}) {
Tools.configInfo = data;
var sysInfo; var sysInfo;
//淘宝小程序环境就用canvas初始化 //淘宝小程序环境就用canvas初始化
if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window if (!window) {//自行处理吧,这么判断也不保险,万一淘宝小程序加进了window
......
...@@ -509,45 +509,23 @@ export const ResJson = { ...@@ -509,45 +509,23 @@ export const ResJson = {
} }
}, },
{ {
"keys": "backbtn.png,midbuild.png,mifcloud.png,rulebtn.png,startbg.jpg,startbtn.png,startop.png,titile.png", "keys": "backbtn.png,collect.png,rulebtn.png,startbg.jpg,startbtn.png,titile.png",
"name": "StartScene", "name": "StartScene",
"atlas": { "atlas": {
"midbuild.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 493,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 493,
"ro": false
},
"mifcloud.png": {
"x": 2,
"y": 497,
"w": 750,
"h": 412,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 412,
"ro": false
},
"titile.png": { "titile.png": {
"x": 754, "x": 2,
"y": 2, "y": 2,
"w": 574, "w": 574,
"h": 177, "h": 126,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 574, "sw": 574,
"sh": 177, "sh": 177,
"ro": true "ro": false
}, },
"startbtn.png": { "startbtn.png": {
"x": 2, "x": 2,
"y": 911, "y": 130,
"w": 350, "w": 350,
"h": 99, "h": 99,
"ox": 0, "ox": 0,
...@@ -556,31 +534,31 @@ export const ResJson = { ...@@ -556,31 +534,31 @@ export const ResJson = {
"sh": 99, "sh": 99,
"ro": false "ro": false
}, },
"startop.png": { "collect.png": {
"x": 754, "x": 2,
"y": 578, "y": 231,
"w": 117, "w": 308,
"h": 196, "h": 50,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 117, "sw": 308,
"sh": 196, "sh": 50,
"ro": false "ro": false
}, },
"backbtn.png": { "backbtn.png": {
"x": 754, "x": 354,
"y": 776, "y": 130,
"w": 145, "w": 145,
"h": 62, "h": 62,
"ox": 0, "ox": 0,
"oy": 0, "oy": 0,
"sw": 145, "sw": 145,
"sh": 62, "sh": 62,
"ro": false "ro": true
}, },
"rulebtn.png": { "rulebtn.png": {
"x": 754, "x": 418,
"y": 840, "y": 130,
"w": 138, "w": 138,
"h": 62, "h": 62,
"ox": 0, "ox": 0,
...@@ -755,5 +733,5 @@ export const ResJson = { ...@@ -755,5 +733,5 @@ export const ResJson = {
"name": "svga" "name": "svga"
} }
], ],
"path": "https://yun.duiba.com.cn/db_games/activity/template/1678380297/resource/" "path": "https://yun.duiba.com.cn/db_games/activity/template/1678450122/resource/"
} }
\ No newline at end of file
...@@ -403,6 +403,16 @@ export const SkinJson = { ...@@ -403,6 +403,16 @@ export const SkinJson = {
}, },
"id": "title" "id": "title"
}, },
{
"name": "collect",
"x": 224,
"y": 236,
"type": "sprite",
"props": {
"source": "collect.png"
},
"id": "collect"
},
{ {
"name": "titlelab", "name": "titlelab",
"x": 0, "x": 0,
...@@ -413,7 +423,9 @@ export const SkinJson = { ...@@ -413,7 +423,9 @@ export const SkinJson = {
"size": 20, "size": 20,
"fillColor": "#ab4a17", "fillColor": "#ab4a17",
"textAlpha": 1, "textAlpha": 1,
"lineHeight": 20 "lineHeight": 20,
"textWidth": 750,
"textAlign": "center"
}, },
"id": "titlelab" "id": "titlelab"
}, },
......
...@@ -7,6 +7,13 @@ import Ease = FYGE.Ease; ...@@ -7,6 +7,13 @@ import Ease = FYGE.Ease;
* 定制,记录一些全局量和通用方法 * 定制,记录一些全局量和通用方法
*/ */
export class Tools { export class Tools {
// public static indexInfo;
// public static startId;
public static configInfo: {
longitude: string,
latitude: string,
time: number
}
/** /**
* 缓存key * 缓存key
......
...@@ -14,39 +14,39 @@ let mergeData = { ...@@ -14,39 +14,39 @@ let mergeData = {
* web接口枚举,mock 文件名类似aaa/homeInfo.do * web接口枚举,mock 文件名类似aaa/homeInfo.do
*/ */
export enum WebNetName { export enum WebNetName {
/** // /**
* 首页 // * 首页
* 参数a 参数b // * 参数a 参数b
*/ // */
index = "/projectx/{projectId}/game/index.do", // index = "/projectx/{projectId}/game/index.do",
/** // /**
* 参与 // * 参与
*/ // */
join = "/projectx/{projectId}/game/join.do", // join = "/projectx/{projectId}/game/join.do",
/** // /**
* 获取结果 // * 获取结果
*/ // */
queryResult = "/projectx/{projectId}/game/queryResult.do", // queryResult = "/projectx/{projectId}/game/queryResult.do",
/** // /**
* 获取规则 // * 获取规则
*/ // */
projectRule = "/projectx/{projectId}/projectRule.query", // projectRule = "/projectx/{projectId}/projectRule.query",
/**
* 开始游戏
*/
startGame = "/projectx/{projectId}/happyCityScore/start.do",
/** /**
* 游戏首页 * 游戏首页
*/ */
indexInfo = "/projectx/{projectId}/happyCityScore/gameIndex.do", indexInfo = "/zy-activity/game/index",
/** /**
* 提交游戏 * 开始游戏
*/ */
submitGame = "/projectx/{projectId}/happyCityScore/submit.do", startGame = "/zy-activity/game/start",
/** /**
* 通用埋点 * 提交游戏
*/ */
buriedPoint = "/projectx/{projectId}/buriedPoint" submitGame = "/zy-activity/game/submit",
// /**
// * 通用埋点
// */
// buriedPoint = "/projectx/{projectId}/buriedPoint"
} }
//返回数据类型 //返回数据类型
...@@ -54,7 +54,8 @@ interface dataOut { ...@@ -54,7 +54,8 @@ interface dataOut {
success: boolean, success: boolean,
data?: any data?: any
code?: string, code?: string,
message?: string message?: string,
desc?: string,
} }
//记录数据 //记录数据
...@@ -74,7 +75,7 @@ export function sendWebNet( ...@@ -74,7 +75,7 @@ export function sendWebNet(
parameter?: any, parameter?: any,
callback?: (success: boolean, res?: dataOut) => void, callback?: (success: boolean, res?: dataOut) => void,
hideMsg: boolean = false, hideMsg: boolean = false,
isGet: boolean = true,//这两个参数基本不设置,放后面吧 isGet: boolean = false,//这两个参数基本不设置,放后面吧
headers?: any, headers?: any,
): Promise<dataOut> { ): Promise<dataOut> {
//处理下参数 //处理下参数
...@@ -85,8 +86,8 @@ export function sendWebNet( ...@@ -85,8 +86,8 @@ export function sendWebNet(
if (/*window["development"]*/window.location.port == "8080") {//window.location.port == "8080";考虑按端口判断TODO if (/*window["development"]*/window.location.port == "8080") {//window.location.port == "8080";考虑按端口判断TODO
// var jname = netName.substring(netName.lastIndexOf("/") + 1);//待修改,TODO,部分接口后缀名字一致 // var jname = netName.substring(netName.lastIndexOf("/") + 1);//待修改,TODO,部分接口后缀名字一致
// var url = "../../mock/miniTb/" + jname + ".json"; // var url = "../../mock/miniTb/" + jname + ".json";
let path = netName.split('{projectId}/')[1];//后缀名字之前的是文件夹,mock里结构 let path = netName.split('zy-activity/')[1];//后缀名字之前的是文件夹,mock里结构
if (path.indexOf('/') <= -1) path = `projectX/${path}`; if (path.indexOf('/') <= -1) path = `zy-activity/${path}`;
const url = "../../mock/webNet/" + path + ".json"; const url = "../../mock/webNet/" + path + ".json";
fetchAsync(url) fetchAsync(url)
.then((data) => { .then((data) => {
......
...@@ -43,7 +43,7 @@ export class FailPanel extends Panel { ...@@ -43,7 +43,7 @@ export class FailPanel extends Panel {
const { success, data, message } = await sendWebNet(WebNetName.startGame, { token: token }) const { success, data, message } = await sendWebNet(WebNetName.startGame, { token: token })
if (!success) { if (!success) {
this.isOpen = false this.isOpen = false
showToast(message || "网络异常,请重试~") showToast(message || "网络开小差了,稍后再试~")
return return
} }
this.isOpen = false this.isOpen = false
......
...@@ -35,11 +35,12 @@ export class GuidePanel extends Panel { ...@@ -35,11 +35,12 @@ export class GuidePanel extends Panel {
if (this.guideStep < 4) { if (this.guideStep < 4) {
this.guideStep++ this.guideStep++
this.guideUI(); this.guideUI();
} else { } else if((this.guideStep == 4)) {
this.guideStep++
this.showCount(); this.showCount();
} }
}, this) }, this)
if(getWebData(WebNetName.startGame).data.firstGame){ if(getWebData(WebNetName.indexInfo).data.ifFirstPlay){
this.guideUI(); this.guideUI();
} else { } else {
this.showCount(); this.showCount();
......
...@@ -13,7 +13,10 @@ import { duiba_md5 } from "../../module/tools/security"; ...@@ -13,7 +13,10 @@ import { duiba_md5 } from "../../module/tools/security";
import { Tools } from "../Tools"; import { Tools } from "../Tools";
import { layers } from "../../module/views/layers"; import { layers } from "../../module/views/layers";
import UI from "../UI"; import UI from "../UI";
import { getUrlParams } from "../../module/web/webTools";
import { GDispatcher } from "../Main";
const allWords:any = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']
export class GameScene extends Scene { export class GameScene extends Scene {
get groupNames() { return ["GameScene"] }; get groupNames() { return ["GameScene"] };
get skinName() { return "GameScene" }; get skinName() { return "GameScene" };
...@@ -25,47 +28,20 @@ export class GameScene extends Scene { ...@@ -25,47 +28,20 @@ export class GameScene extends Scene {
bgCon; //背景移动 bgCon; //背景移动
_role; //人物 _role; //人物
wordList = ['闲', '看', '晴', '云', '自', '卷', '舒', '静', '水', '流', '深', '心', '无', '意', '在', '休']; // 待随机出现的列表 wordList = this.getWordList(); // 待随机出现的列表
collectList: any = []; // 已收集列表 collectList: any = []; // 已收集列表
mapList = []; mapList = [];
reset;
time = Tools.configInfo.time;
startLen = 12
cdnum: FYGE.TextField;
cloud: FYGE.Sprite;
peo: FYGE.Sprite;
tianpop: FYGE.Sprite;
xiangpop: FYGE.Sprite;
monster: FYGE.Sprite;
scorebg: FYGE.Sprite;
scorenum: FYGE.TextField;
close: FYGE.Sprite;
open: FYGE.Sprite;
jumpLock = false;
isonce = false;
score;
public static instance: GameScene; public static instance: GameScene;
initUi() { initUi() {
} }
async start(data) { async start() {
super.start(); super.start();
GameScene.instance = this GameScene.instance = this
this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga")) this.left = new FYGE.SvgaAni(await RES.getResAsync("left.svga"))
this.left = this.addChild(this.left) this.left = this.addChild(this.left)
this.left.position.set(8, 979); this.left.position.set(8, 979);
...@@ -79,16 +55,23 @@ export class GameScene extends Scene { ...@@ -79,16 +55,23 @@ export class GameScene extends Scene {
// 创建模型, 云层 // 创建模型, 云层
this.bgCon = this.addChild(new FYGE.Container()); this.bgCon = this.addChild(new FYGE.Container());
this.setChildIndex(this.bgCon, 2) this.setChildIndex(this.bgCon, 2)
this.setChildIndex(this.reset, 3)
this.initCloud(); this.initCloud();
console.log("新手引导") console.log("新手引导")
showPanel(GuidePanel); showPanel(GuidePanel);
// this.upDateInfo(); // 用于开始游戏 ----test // this.upDateInfo(); // 用于开始游戏 ----test
this.reset.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.reset)
this.onReset()
}, this)
// 添加指向的事件 // 添加指向的事件
this.left.addEventListener(FYGE.MouseEvent.CLICK, () => { this.left.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.left)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0] let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 0){ if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex % 2 == 0) {
this.left.startAniRange(1, undefined, 1, () => { this.left.startAniRange(1, undefined, 1, () => {
console.log('this._role.currentIndex', this._role.currentIndex) console.log('this._role.currentIndex', this._role.currentIndex)
this._role.leftMove({ this._role.leftMove({
...@@ -96,10 +79,11 @@ export class GameScene extends Scene { ...@@ -96,10 +79,11 @@ export class GameScene extends Scene {
}, this.collectWordTx.bind(this, item)) }, this.collectWordTx.bind(this, item))
}) })
} }
}) }, this)
this.right.addEventListener(FYGE.MouseEvent.CLICK, () => { this.right.addEventListener(FYGE.MouseEvent.CLICK, () => {
this.btnDelay(this.right)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0] let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex%2 == 1){ if (item.y + this.bgCon.y - 200 > 0 && !this._role.isMove && this._role.currentIndex % 2 == 1) {
this.right.startAniRange(1, undefined, 1, () => { this.right.startAniRange(1, undefined, 1, () => {
console.log('this._role.currentIndex', this._role.currentIndex) console.log('this._role.currentIndex', this._role.currentIndex)
let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0] let item = this._role.currentIndex < 0 ? this.mapList[0][0] : this.mapList[this._role.currentIndex][0]
...@@ -109,17 +93,53 @@ export class GameScene extends Scene { ...@@ -109,17 +93,53 @@ export class GameScene extends Scene {
}, this.collectWordTx.bind(this, item)) }, this.collectWordTx.bind(this, item))
}) })
} }
}, this)
}
getWordList() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
let hasWordList:any = [];
let noWordList:any = [];
dataInfo.forEach(item => {
if (item.context) {
hasWordList = hasWordList.concat(item.context.split(""))
}
}) })
allWords.forEach(item => {
if (!hasWordList.includes(item) && !noWordList.includes(item)) {
noWordList.push(item)
}
})
return noWordList
} }
upDateInfo() { upDateInfo() {
this.cdUIRender(this.time) this.cdUIRender(this.time)
this.startGame() this.startGame()
this.countDown(this.time) this.countDown(this.time)
} }
// 数据重置
onReset() {
changeScene(StartScene)
// this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
// this.wordList = this.getWordList();
// this.collectList = [];
// this.mapList = [];
// this.time = Tools.configInfo.time;
// this.outIndex = 0;
// this.removeChild(this.bgCon);
// clearTimeout(this.timer);
// this.bgCon = this.addChild(new FYGE.Container());
// this.setChildIndex(this.bgCon, 2)
// this.initCloud();
// this.upDateInfo()
}
startGame() { startGame() {
this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this); this.addEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
} }
time=60;
timer = null; timer = null;
countDown(time) { countDown(time) {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
...@@ -134,16 +154,16 @@ export class GameScene extends Scene { ...@@ -134,16 +154,16 @@ export class GameScene extends Scene {
}, 1000) }, 1000)
} }
cdUIRender(num=60) { cdUIRender(num = 60) {
// 先清除所有节点 // 先清除所有节点
this.cdbg.removeChildren(); this.cdbg.removeChildren();
let str = num + 's'; let str = num + 's';
let arr = str.split(""); let arr = str.split("");
let startPos = (130 - (30*arr.length))/2 let startPos = (130 - (30 * arr.length)) / 2
arr.forEach((item, index) => { arr.forEach((item, index) => {
UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index*30), 38) UI.Sp(this.cdbg, `num_${item}.png`, startPos + (index * 30), 38)
}) })
} }
firstCoud; firstCoud;
initCloud() { initCloud() {
...@@ -151,15 +171,15 @@ export class GameScene extends Scene { ...@@ -151,15 +171,15 @@ export class GameScene extends Scene {
let offset = (1624 - this.stage.viewRect.height) / 2; let offset = (1624 - this.stage.viewRect.height) / 2;
// 渲染人物脚下的一朵云层 // 渲染人物脚下的一朵云层
this.firstCoud = UI.Sp(this.bgCon, 'cloud2.png', 190, 1150 - offset ) this.firstCoud = UI.Sp(this.bgCon, 'cloud2.png', 190, 1150 - offset)
// 创建角色 // 创建角色
this.addRole() this.addRole()
// 开始循环添加 // 开始循环添加
for (let i=0; i<15; i++) { for (let i = 0; i < this.startLen; i++) {
this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right'); this.createCloudItem(stageHeight - (500 + 150 * i), i + 1, i % 2 == 0 ? 'left' : 'right');
} }
} }
...@@ -174,18 +194,18 @@ export class GameScene extends Scene { ...@@ -174,18 +194,18 @@ export class GameScene extends Scene {
let len = this.wordList.length let len = this.wordList.length
let randomIndex; let randomIndex;
if (len > 0) { if (len > 0) {
randomIndex = Math.floor(Math.random()*len); randomIndex = Math.floor(Math.random() * len);
} }
let wordItem = new Word({ let wordItem = new Word({
wordTx: len == 0 ? '' : this.wordList[randomIndex], wordTx: len == 0 ? '' : this.wordList[randomIndex],
index: index index: index
}) })
// 偏差值 // 偏差值
let deviation = Math.floor(Math.random()*200) - 100; let deviation = Math.floor(Math.random() * 200) - 100;
wordItem.fx = (direction === 'left' ? 88 : 440) + deviation + 100; wordItem.fx = (direction === 'left' ? 88 : 440) + deviation + 100;
wordItem.fy = h + 5 wordItem.fy = h + 5
this.bgCon.addChildAt(wordItem, 0) this.bgCon.addChildAt(wordItem, 0)
let cloudItem = new Cloud({ let cloudItem = new Cloud({
direction direction
}); });
...@@ -205,14 +225,14 @@ export class GameScene extends Scene { ...@@ -205,14 +225,14 @@ export class GameScene extends Scene {
this.bgCon.addChild(role); this.bgCon.addChild(role);
} }
outIndex=0; outIndex = 0;
onFarm() { onFarm() {
this.moveMap(); this.moveMap();
// 判断是否超出屏幕 // 判断是否超出屏幕
let stageHeight = this.stage.stageHeight; let stageHeight = this.stage.stageHeight;
// console.log('this.mapList[0]', this.mapList[0].y + this.bgCon.y, this.stage.stageHeight) // console.log('this.mapList[0]', this.mapList[0].y + this.bgCon.y, this.stage.stageHeight)
if (this.mapList[this.outIndex][0].y + this.bgCon.y - 200 > stageHeight) { if (this.mapList[this.outIndex][0].y + this.bgCon.y - 200 > stageHeight) {
if (this.firstCoud) { if (this.firstCoud) {
this.bgCon.removeChild(this.firstCoud) this.bgCon.removeChild(this.firstCoud)
} }
...@@ -221,20 +241,20 @@ export class GameScene extends Scene { ...@@ -221,20 +241,20 @@ export class GameScene extends Scene {
// console.log("超出屏幕") // console.log("超出屏幕")
this.bgCon.removeChild(this.mapList[_index][0]) this.bgCon.removeChild(this.mapList[_index][0])
this.bgCon.removeChild(this.mapList[_index][1]) this.bgCon.removeChild(this.mapList[_index][1])
let i = this.mapList[this.mapList.length - 1][0].index let i = this.mapList[this.mapList.length - 1][0].index
// console.log(this.mapList[this.mapList.length - 1][0].index) // console.log(this.mapList[this.mapList.length - 1][0].index)
this.createCloudItem(stageHeight - (500 + 150*i), i + 1, i%2 == 0 ? 'left' : 'right') this.createCloudItem(stageHeight - (500 + 150 * i), i + 1, i % 2 == 0 ? 'left' : 'right')
} }
// 判断人物是否超出 // 判断人物是否超出
if (this._role.y + this.bgCon.y - 305 > stageHeight) { if (this._role.y + this.bgCon.y - 305 > stageHeight) {
let item = this.mapList[this.outIndex + 7][0] let item = this.mapList[this.outIndex + 7][0]
this._role.onFreeFall({ this._role.onFreeFall({
x: item.x, x: item.x,
y: item.y y: item.y
}, { }, {
item:item item: item
}, this.collectWordTx.bind(this, item)) }, this.collectWordTx.bind(this, item))
} }
...@@ -243,29 +263,75 @@ export class GameScene extends Scene { ...@@ -243,29 +263,75 @@ export class GameScene extends Scene {
this.bgCon.y = this.bgCon.y + 2 this.bgCon.y = this.bgCon.y + 2
} }
collectWordTx(item) { collectWordTx(item) {
this.bgCon.removeChild(item) this.bgCon.removeChild(item)
if (item.wordTx && !this.collectList.includes(item.wordTx)) { if (item.wordTx && !this.collectList.includes(item.wordTx)) {
this.collectList.push(item.wordTx); this.collectList.push(item.wordTx);
let _i = this.wordList.indexOf(item.wordTx); let _i = this.wordList.indexOf(item.wordTx);
if (_i > -1) { if (_i > -1) {
this.wordList.splice(_i, 1) this.wordList.splice(_i, 1)
}
} }
}
} }
async gameOver() { async gameOver() {
this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this); this.removeEventListener(FYGE.Event.ENTER_FRAME, this.onFarm, this);
let startInfo = getWebData(WebNetName.startGame).data.currInfo; let activityId = getUrlParams('activityId')
let startId = getWebData(WebNetName.startGame).data.startId;
let timestamp = new Date().getTime(); let timestamp = new Date().getTime();
let sign = duiba_md5(`score=${this.score}&startId=${startInfo.startId}&timestamp=${timestamp}&key=${startInfo.key + "9ef16b33920749fb26e8fc2f2913150a"}`) let type = 3
const { success, data, message } = await sendWebNet(WebNetName.submitGame, { score: this.score, sign: sign, code: startInfo.code, timestamp: timestamp ,startId:startInfo.startId}) let sign = duiba_md5(String(activityId) + String(timestamp) + String(startId) + String(type) + 'posf3usrjjnd9sd4w21ln3p');
let dataArr = this.getDataArr();
const { success, data, desc } = await sendWebNet(WebNetName.submitGame, {
activityId,
type,
startId,
timestamp,
sign,
longitude: Tools.configInfo.longitude,
latitude: Tools.configInfo.latitude,
data: dataArr
})
if (success) {
GDispatcher.dispatchEvent("openGameEnd", {
isFillUp: data.point ? true : false,
point: data.point || 0
});
} else {
showToast(desc || "网络开小差了,稍后再试")
}
}
getDataArr() {
console.log('this.collectList', this.collectList)
let arr = ["闲看晴云自卷舒", "静水流深", "云卷舒", "心无意", "自在休闲"];
let tempData = []
arr.forEach((item, index) => {
let words = [];
item.split("").forEach(val => {
if (this.collectList.includes(val)) {
if (words.indexOf(val) == -1) {
words.push(val)
}
}
})
tempData.push({
num: index + 1,
context: words.join(',')
})
})
console.log('tempData', tempData)
return tempData
}
closeGame() {
changeScene(StartScene)
} }
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
GDispatcher.addEventListener("closeGame", this.closeGame, this);
} }
removeEvents() { removeEvents() {
super.removeEvents(); super.removeEvents();
GDispatcher.addEventListener("closeGame", this.closeGame, this);
} }
} }
import { Scene } from "../../module/views/Scene"; import { Scene } from "../../module/views/Scene";
import { changeScene, showPanel, showToast, hideWaiting } from "../../module/ctrls"; import { changeScene, showPanel, showToast } from "../../module/ctrls";
import { GameScene } from "./GameScene"; import { GameScene } from "./GameScene";
import { RES } from "../../module/RES"; import { RES } from "../../module/RES";
import { RulePanel } from "../panels/RulePanel"; import { RulePanel } from "../panels/RulePanel";
import { sendWebNet, WebNetName, getPxTokenSave } from "../webNet"; import { sendWebNet, WebNetName, getPxTokenSave, getWebData } from "../webNet";
import { GDispatcher } from "../Main"; import { GDispatcher } from "../Main";
import { getGameIndex } from "../hdTool/Hdtool"; import { getUrlParams } from "../../module/web/webTools";
export class StartScene extends Scene { export class StartScene extends Scene {
get groupNames() { return ["StartScene"] }; get groupNames() { return ["StartScene"] };
get skinName() { return "StartScene" }; get skinName() { return "StartScene" };
startbtn; startbtn;
startbg: FYGE.Sprite; startbg: FYGE.Sprite;
collect: FYGE.Sprite;
titlelab: FYGE.TextField; titlelab: FYGE.TextField;
backbrn: FYGE.Sprite; backbrn: FYGE.Sprite;
rulebtn: FYGE.Sprite; rulebtn: FYGE.Sprite;
indexInfo;
gameInfo;
public static instance: StartScene public static instance: StartScene
indexInfo;
initUi() { initUi() {
} }
async start(data) { async start(data) {
...@@ -41,59 +38,52 @@ export class StartScene extends Scene { ...@@ -41,59 +38,52 @@ export class StartScene extends Scene {
this.getIndexInfo() this.getIndexInfo()
} }
async getIndexInfo() { async getIndexInfo() {
getGameIndex().then((r) => { const { success, data, desc } = await sendWebNet(WebNetName.indexInfo, {
hideWaiting() activityId: getUrlParams('activityId'),
if (r.success) { type: 3
this.indexInfo = r.data;
this.titlelab.text = "今日收集字数( " + r.data.collectCount + " / 16 )"
}
}) })
if (!success) {
showToast(desc || "网络开小差了,稍后再试")
return
}
this.indexInfo = data
this.titlelab.text = "今日收集字数( " + data.collectCount + " / 16 )"
// this.openGame() // this.openGame()
} }
openRule() { openRule() {
// showPanel(RulePanel)
GDispatcher.dispatchEvent("openRule"); GDispatcher.dispatchEvent("openRule");
} }
isOpen = false startId;
async openGame() { async openGame() {
this.btnDelay(this.startbtn) this.btnDelay(this.startbtn)
if (this.indexInfo) { const { success, code, data, desc } = await sendWebNet(WebNetName.startGame, {
if (!this.indexInfo.dailyPass) { activityId: getUrlParams('activityId'),
if (!this.isOpen) { type: 3
this.isOpen = true })
let token = await getPxTokenSave() if (success) {
const { success, code, data, message } = await sendWebNet(WebNetName.startGame, { token: token }) this.startId = data.startId;
if (!success) { changeScene(GameScene)
this.isOpen = false } else {
if (code == "20004") { showToast(desc || "网络开小差了,稍后再试")
showToast("今日已过关,明日再来~")
} else {
showToast(message || "网络异常,请重试~")
}
return
}
this.isOpen = false
// changeScene(GameScene)
}
} else {
showToast("今日已过关,明日再来~")
}
}else{
showToast( "网络异常,请重试~")
} }
} }
goback() { goback() {
GDispatcher.dispatchEvent("backIndex"); GDispatcher.dispatchEvent("backIndex");
} }
async openCollect() {
let dataInfo = getWebData(WebNetName.indexInfo).data.dataInfo;
if (!dataInfo) {
await this.getIndexInfo()
}
GDispatcher.dispatchEvent("openCollect", getWebData(WebNetName.indexInfo).data.dataInfo);
}
initEvents() { initEvents() {
super.initEvents(); super.initEvents();
this.rulebtn.addEventListener(FYGE.MouseEvent.CLICK, this.openRule, this) this.rulebtn.addEventListener(FYGE.MouseEvent.CLICK, this.openRule, this)
this.backbrn.addEventListener(FYGE.MouseEvent.CLICK, this.goback, this) this.backbrn.addEventListener(FYGE.MouseEvent.CLICK, this.goback, this)
this.collect.addEventListener(FYGE.MouseEvent.CLICK, this.openCollect, this)
} }
removeEvents() { removeEvents() {
...@@ -101,6 +91,7 @@ export class StartScene extends Scene { ...@@ -101,6 +91,7 @@ export class StartScene extends Scene {
this.startbtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openGame, this) this.startbtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openGame, this)
this.rulebtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openRule, this) this.rulebtn.removeEventListener(FYGE.MouseEvent.CLICK, this.openRule, this)
this.backbrn.removeEventListener(FYGE.MouseEvent.CLICK, this.goback, this) this.backbrn.removeEventListener(FYGE.MouseEvent.CLICK, this.goback, this)
this.collect.removeEventListener(FYGE.MouseEvent.CLICK, this.openCollect, this)
} }
} }
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