Commit 968badc5 authored by wildfirecode's avatar wildfirecode

1

parent cf3426ce
......@@ -277,6 +277,7 @@ export default class MainBase extends eui.UILayer {
const result = DataManager.ins.getData('getShareInfo');
window['registerWX'](result);
});
updateMainTimer();
}
}
......@@ -302,7 +303,7 @@ export default class MainBase extends eui.UILayer {
playGameBg();
}
if(timerInit) {
// if(timerInit) {
NetManager.ins.hc_home(() => {
updateMainTimer();
//更新bloodpanel和mapscene
......@@ -313,7 +314,7 @@ export default class MainBase extends eui.UILayer {
if (current && current['updateTimerView'])
current['updateTimerView']();
}, window['collectRuleId']);
}
// }
}
......@@ -325,17 +326,16 @@ export default class MainBase extends eui.UILayer {
}
}
let timerInit=false;
export const initTimer = ()=>{
if(timerInit) return;
timerInit=true;
const data = getHomeData();
if(data.refectionCountdown==0) data.refectionCountdown = 2;
data.refectionCountdown += Math.floor(new Date().getTime()/1000);
updateMainTimer();
}
const timer = new egret.Timer(1000);
timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, () => {
// let timerInit=false;
// export const initTimer = ()=>{
// if(timerInit) return;
// timerInit=true;
// const data = getHomeData();
// if(data.refectionCountdown==0) data.refectionCountdown = 2;
// data.refectionCountdown += Math.floor(new Date().getTime()/1000);
// updateMainTimer();
// }
const updateTimerAndView = ()=>{
NetManager.ins.hc_home(() => {
updateMainTimer();
//更新bloodpanel和mapscene
......@@ -346,6 +346,11 @@ timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, () => {
if (current && current['updateTimerView'])
current['updateTimerView']();
}, window['collectRuleId']);
}
const timer = new egret.Timer(1000);
timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, () => {
updateTimerAndView();
}, this)
export const mainTimer = timer;
export const updateMainTimer = () => {
......@@ -356,8 +361,11 @@ export const updateMainTimer = () => {
mainTimer.reset();
const left = data.refectionCountdown - Math.floor(new Date().getTime() / 1000);
mainTimer.repeatCount = left;
if (left >= 0)
if (left > 0)
mainTimer.start();
else if(left ==0) {
updateTimerAndView();
}
else
console.error('data error')
}
......
......@@ -1780,9 +1780,11 @@ export class NetManager extends ABNetManager {
* @param result 结果
*/
protected onResponse(net: INetData, result: any): void {
// if(net.name == 'hc_home') {
// result.data.refectionCountdown += Math.floor(new Date().getTime()/1000);
// }
if(net.name == 'hc_home') {
if(result.data.refectionCountdown==0)
result.data.refectionCountdown=5;
result.data.refectionCountdown += Math.floor(new Date().getTime()/1000);
}
//数据处理
const data: Data = DataManager.ins.updateData(net.name, result, net.param);
//接口成功
......
......@@ -18,7 +18,7 @@ import setGray from "../setGray";
import { loadSvga } from "../loadSvga";
import getResPath from "../../libs/new_tc/getResPath";
import CountDown from "./CountDown";
import { initTimer } from "../../libs/new_wx/MainBase";
export default class MapScene extends Scene {
scrollGroup: eui.Group;
......@@ -32,7 +32,7 @@ export default class MapScene extends Scene {
async start(data?) {
super.start();
initTimer();
if (getBgOn() && MapScene['firstPlayBgTag'] == true) {
playBg();
}
......
......@@ -103,7 +103,9 @@ export default class StartPanel extends Panel {
// Loading.instace.hide();
this.touchChildren = true;
this.touchEnabled = true;
updateMainTimerAfterGetData();
wait(2000).then(()=>{
updateMainTimerAfterGetData();
});
if (success) {
// Loading.instace.show();
try {
......
......@@ -5,7 +5,7 @@
"timestamp": 1566885811001,
"data": {
"refectionCountdown": 0,
"remainEnargy": 5,
"remainEnargy": 4,
"isGetAllTreasureBox": 0,
"wealth": 7960,
"totalStars": 145,
......
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