Commit e2b99b85 authored by 邱旭's avatar 邱旭

1

parent 9cef89f6
......@@ -11,6 +11,12 @@ export default class Scene extends ComponentBase {
this.playAnimation();
}
onLoad(){
return new Promise((resolve, reject)=>{
resolve();
})
}
updateScene(){
}
......
......@@ -48,8 +48,10 @@ export default class SceneCtrl {
scene.addEventListener(egret.Event.ADDED_TO_STAGE, () => {
scene.start(data);
}, this);
this.addToStage(scene);
onComplete && onComplete();
scene.onLoad().then(()=>{
this.addToStage(scene);
onComplete && onComplete();
});
}
addMask() {
......
......@@ -108,6 +108,15 @@ export default class MapScene extends Scene {
private inviteTimer: egret.Timer;
private cutTime: number;
onLoad() {
super.onLoad().then(()=>{});
return new Promise((resolve, reject) => {
NetManager.ins.hbRainBaseInfo(() => {
resolve();
});
});
}
async start(data?) {
super.start();
......@@ -334,7 +343,7 @@ export default class MapScene extends Scene {
if(item.parent) item.parent.addChild(item);
});
}
}
// 添加图标
......
......@@ -4,6 +4,8 @@ import { GDispatcher } from "../../../libs/tc/util/GDispatcher";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import { getlogItem } from "../../Main";
import CutTimer from "../../CutTimer";
import { DataManager } from "../../../libs/tw/manager/DataManager";
import { NetName } from "../../../libs/tw/enum/NetName";
export default class HbRainIcon extends IconBase {
......@@ -11,15 +13,18 @@ export default class HbRainIcon extends IconBase {
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
super(name, group, btn, tipsBg, tipsLabel);
this.cutTimer = new CutTimer();
this.cutTimer.callFun = () => {
this.updateIcon();
};
this.updateIcon();
}
protected start() {
super.start();
this.cutTimer = new CutTimer();
this.cutTimer.callFun = () => {
this.updateIcon();
};
let res = DataManager.ins.getData(NetName.HBRAIN_BASEINFO);
if(res) {
this.call(res.success, res);
}
}
public showLog() {
......@@ -28,37 +33,38 @@ export default class HbRainIcon extends IconBase {
}
private updateIcon() {
NetManager.ins.hbRainBaseInfo((success, res) => {
if(!success) {
if(res.code == "600054" || res.code == "600055") {
this.visible = false;
}
GDispatcher.dispatchEvent('updateActIcon');
return;
}
const data = res.data;
NetManager.ins.hbRainBaseInfo((success, res) => this.call(success, res));
}
let time: number;
const sysTime = res.timestamp; // 当前系统时间
if(data.currentSession) {
this.visible = true;
time = data.currentSession.endTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else if(data.nextSession) {
this.visible = true;
time = data.nextSession.startTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else {
private call(success, res) {
if(!success) {
if(res.code == "600054" || res.code == "600055") {
this.visible = false;
}
GDispatcher.dispatchEvent('updateActIcon');
});
return;
}
const data = res.data;
let time: number;
const sysTime = res.timestamp; // 当前系统时间
if(data.currentSession) {
this.visible = true;
time = data.currentSession.endTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else if(data.nextSession) {
this.visible = true;
time = data.nextSession.startTime - sysTime + 3000;
if(!this.cutTimer.start(time)) {
this.cutTimer.stop();
this.cutTimer.start(time);
}
} else {
this.visible = false;
}
GDispatcher.dispatchEvent('updateActIcon');
}
......
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