觉醒时刻
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.
 
 
 
juexingshike/assets/Scripts/MainScene/NeedTaskMoney.ts

43 lines
1.4 KiB

import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import Common5 from "../../Platform/th/Common5";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import UserManager from "../Manager/UserManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class NeedTaskMoney extends cc.Component {
@property(cc.Label)
lab: cc.Label = null;
start() {
this.updateUI();
EventMgr.onEvent_custom(ryw_Event.updateMainTask, () => {
this.updateUI();
}, this);
EventMgr.onEvent_custom(ryw_Event.updateMoney, () => {
this.updateUI();
}, this);
}
updateUI() {
this.node.active = false;
let taskInfo: any = TaskManager.getCurUnLockMainTaskInfo();
if (taskInfo && taskInfo.Id != MainTaskIdEnum.MainTask_None) {
let config = TaskManager.getTaskConfigById(taskInfo.Id);
if (config && config.TaskNeedMoney && config.TaskNeedMoney > 0) {
this.node.active = true;
let money = config.TaskNeedMoney - UserManager.getCurMoney();
if (money > 0) {
this.lab.string = `${Common5.getNumberChangeHanzi(money, '2')}`;
} else {
this.lab.string = `0`;
}
}
}
}
// update (dt) {}
}