/** 富翁银行气泡 */ const { ccclass, property } = cc._decorator; @ccclass export default class BankQipaoTip extends cc.Component { @property(cc.Node) node_cunru: cc.Node = null; @property(cc.Node) node_tixian: cc.Node = null; @property(cc.Label) lab_money: cc.Label = null; @property(cc.Label) lab_dian: cc.Label = null; private itemP: cc.Prefab = null async onLoad() { this.node.opacity = 0; } onEnable() { this.node.opacity = 0; gData.safeDepositBoxData.updateQipao(); } init(data = null) { this.node.opacity = 0; if (gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0) { this.node.opacity = 255; this.node_tixian.active = true; this.node_cunru.active = false; let index = 0; this.schedule(() => { if (index == 0) { this.lab_dian.string = "。" index = 1 } else if (index == 1) { this.lab_dian.string = "。。" index = 2 } else if (index == 2) { this.lab_dian.string = "。。。" index = 0 } }, 1); } else { if (data && data.length > 0) { this.node.opacity = 255; this.node_tixian.active = false; this.node_cunru.active = true; let money = 0 for (let entry of data) { money += entry.amount } this.lab_money.string = (money * 0.01).toFixed(2) + "元"; } else { this.node.opacity = 0; } } } async creatPacketAnim(type: number) { this.itemP = await mk.loader.load('module/safeDepositBox/prefabs/MoneySaveItem', cc.Prefab); let node = cc.instantiate(this.itemP) node.parent = cc.find("Canvas") node.scale = 1 if (type == 1) { node.position = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(-145, 337))) } else { node.position = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(0, -324))) } let targetPos = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(0, -92))) node.runAction(cc.sequence(cc.spawn(cc.moveTo(1, cc.v2(targetPos)), cc.scaleTo(1, 0.4)), cc.callFunc(() => { node.destroy() }))) } update() { if (gData.safeDepositBoxData.qipaoType != -1) { let type = gData.safeDepositBoxData.qipaoType; gData.safeDepositBoxData.qipaoType = -1; this.creatPacketAnim(type); } if (gData.safeDepositBoxData.freshQipao) { this.init(gData.safeDepositBoxData.cashRecordData); } } lateUpdate() { gData.safeDepositBoxData.freshQipao = false; } }