觉醒时刻
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.
 
 
 

139 lines
5.5 KiB

import EventMgr from "../../FrameWork/Event/EventMgr";
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import Common5 from "../../Platform/th/Common5";
import User from "../../FrameWork/User/User";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import InterfaceManager from "../Manager/InterfaceManager";
import UserManager from "../Manager/UserManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class YuanBao extends cc.Component {
onLoad() {
this.showMoney();
EventMgr.onEvent_custom(ryw_Event.updateMoney, (money) => {
this.showMoney();
if (money == 0) {
return
}
if (isNaN(money)) {
} else {
let changeLabel_1 = this.node.getChildByName('金币').getChildByName('changeLabel')
this.changeLabelAni(changeLabel_1, money)
}
}, this);
// this.showIQ()
// EventMgr.onEvent_custom(ryw_Event.updatePeopleIQ,(iq)=>{
// this.showIQ();
// if(iq == 0){
// return
// }
// if(isNaN(iq)){
// }else{
// let changeLabel_1 = this.node.getChildByName('智商').getChildByName('changeLabel')
// this.changeLabelAni(changeLabel_1,iq)
// }
// },this)
// this.showYuanBao()
// EventMgr.onEvent_custom(ryw_Event.updateYuanBao,(yuanBao)=>{
// this.showYuanBao();
// if(yuanBao == 0){
// return
// }
// if(isNaN(yuanBao)){
// }else{
// let changeLabel_1 = this.node.getChildByName('statusNode1').getChildByName('元宝').getChildByName('changeLabel')
// this.changeLabelAni(changeLabel_1,yuanBao)
// let changeLabel_2 = this.node.getChildByName('statusNode2').getChildByName('元宝').getChildByName('changeLabel')
// this.changeLabelAni(changeLabel_2,yuanBao)
// }
// },this)
}
start() { }
showMoney() {
let numStr_1 = this.node.getChildByName('金币').getChildByName('numStr')
let numStr_2 = this.node.getChildByName('金币').getChildByName('numStr')
let aaa = Common5.getNumberChangeHanzi(User.getMoney(), '2')
aaa = aaa as string
numStr_1.getComponent(cc.Label).string = aaa;
numStr_2.getComponent(cc.Label).string = aaa;
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_707 && User.getMoney() >= 2000000) {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_707)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_708)
} else if (mainId == MainTaskIdEnum.MainTask_907 && User.getMoney() >= 10000000) {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_907)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_908)
} else if (mainId == MainTaskIdEnum.MainTask_1602 && User.getMoney() >= 1000000000) {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1602)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1603)
} else if (mainId == MainTaskIdEnum.MainTask_2004 && User.getMoney() >= 10000000000) {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_2004)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_2005)
} else if (mainId == MainTaskIdEnum.MainTask_2702) {
EventMgr.emitEvent_custom(ryw_Event.refreshButton)
} else if (mainId == MainTaskIdEnum.MainTask_2802 && InterfaceManager.getDaoyeList().length == 0 && User.getMoney() >= 500000000000) {
UserManager.subMoney(500000000000)
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_2802)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_2803)
}
}
// showIQ() {
// let numStr_1 = this.node.getChildByName('智商').getChildByName('numStr')
// let numStr_2 = this.node.getChildByName('智商').getChildByName('numStr')
// let aaa = Common5.getNumberChangeHanzi(User.getUserIQ(), '1')
// aaa = aaa as string
// numStr_1.getComponent(cc.Label).string = aaa;
// numStr_2.getComponent(cc.Label).string = aaa;
// }
// showYuanBao() {
// let numStr_1 = this.node.getChildByName('statusNode1').getChildByName('元宝').getChildByName('numStr')
// let numStr_2 = this.node.getChildByName('statusNode2').getChildByName('元宝').getChildByName('numStr')
// let aaa = Common5.getNumberChangeHanzi(User.getYuanBao(),'2')
// aaa = aaa as string
// numStr_1.getComponent(cc.Label).string = aaa;
// numStr_2.getComponent(cc.Label).string = aaa;
// }
changeLabelAni(labelNode, num) {
let label = cc.instantiate(labelNode)
label.active = true
label.parent = labelNode.parent
if (num > 0) {
label.getComponent(cc.Label).string = "+" + Common5.getNumberChangeHanzi(num, '1', 1)
} else if (num < 0) {
label.getComponent(cc.Label).string = Common5.getNumberChangeHanzi(num, '1', 1) + ''
}
cc.tween(label)
.delay(0.2)
.by(2, { y: 20, opacity: 0 })
.call(() => {
label.removeFromParent()
})
.start()
}
}