You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.1 KiB
79 lines
3.1 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { ryw_Event } from "../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../FrameWork/Event/EventMgr";
|
|
import Common5 from "../Platform/th/Common5";
|
|
import PhysicalPowerManger from "../ttFrame/manager/PhysicalPowerManger";
|
|
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class EnergyShow extends cc.Component {
|
|
|
|
/**体力的内容 */
|
|
private labelPhysical: cc.Label = null;
|
|
/**体力普通恢复的时间 */
|
|
private labelPhysicalTime: cc.Label = null;
|
|
/**无限体力的时间 */
|
|
private labelTimeAll: cc.Label = null;
|
|
|
|
start () {
|
|
this.labelPhysical = this.node.getChildByName("val_lab").getComponent(cc.Label);
|
|
this.labelPhysicalTime = this.node.getChildByName("tiliTime_lab").getComponent(cc.Label);
|
|
this.labelTimeAll = this.node.getChildByName("wuxiantiliTime_lab").getComponent(cc.Label);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.updatePhysicalPower, (tab) => {
|
|
this.updatePhysicalPower();
|
|
}, this);
|
|
this.updatePhysicalPower();
|
|
Common5.btnRegister_custom(this.node,()=>{
|
|
if (PhysicalPowerManger.getPhyVideoAllTime()>0){
|
|
|
|
}
|
|
else{
|
|
Common5.getPrefabFromBundle("ZoomGame", "Prefabs/UI/WxtlUI", null, (prefab) => {
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
private updatePhysicalPower() {
|
|
if (PhysicalPowerManger.getPhyVideoAllTime() > 0) {//无限体力中
|
|
this.labelPhysicalTime.string = ""
|
|
this.labelPhysical.string = "无限体力";
|
|
// this.node.getChildByName("wxtl").active = true;
|
|
let time = PhysicalPowerManger.getPhyVideoAllTime();
|
|
let ntime = new Date().getTime();
|
|
let cctime = time - ntime;
|
|
this.labelTimeAll.string = PhysicalPowerManger.formatTime(cctime / 1000);
|
|
} else {//普通体力
|
|
this.node.getChildByName("wxtl").active = false;
|
|
this.labelTimeAll.string = "";
|
|
this.labelPhysical.string = PhysicalPowerManger.getPhysicalNum() + "/" + Math.max(PhysicalPowerManger.MaxPhysical,PhysicalPowerManger.getPhysicalNum());
|
|
|
|
if (PhysicalPowerManger.getPhysicalNum() < PhysicalPowerManger.MaxPhysical) {
|
|
|
|
let time = PhysicalPowerManger.getPhyVideoTime();
|
|
let ntime = new Date().getTime();
|
|
let maxTime = PhysicalPowerManger.RecoverPhysicalTime * 1000
|
|
let cctime = maxTime - (ntime - time);
|
|
if (cctime > 0) {
|
|
this.labelPhysicalTime.string = PhysicalPowerManger.formatTime3(cctime / 1000);
|
|
} else {
|
|
this.labelPhysicalTime.string = "00:00"
|
|
}
|
|
} else {
|
|
this.labelPhysicalTime.string = "00:00"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|