| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /** 富翁银行气泡 */
- 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;
- }
- }
|