| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import CommonData, { HTTP_TYPE } from "../datas/CommonData";
- import GameM from "../manager/GameM";
- import UiM from "../manager/UiM";
- import LogUtil from "../utils/LogUtil";
- import { Utils } from "../utils/Utils";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class BankQipaoTip extends cc.Component {
- // LIFE-CYCLE CALLBACKS:
- private itemP: cc.Prefab = null
- onLoad() {
- LogUtil.logV("BankQipaoTip", "onLoad()")
- GameM.httpM.sendDatas(HTTP_TYPE.bankCashRecord, null, GameM.commonData.updateBankPacket.bind(GameM.commonData))
- // }
- // let packet = [{
- // "amount": 30,
- // "isSaveBank": 0,
- // "partnerTradeNo": "a",
- // "cashType": 1
- // },{
- // "amount": 500,
- // "isSaveBank": 0,
- // "partnerTradeNo": "a",
- // "cashType": 1
- // },{
- // "amount": 600,
- // "isSaveBank": 0,
- // "partnerTradeNo": "a",
- // "cashType": 1
- // }]
- // this.showAlreadyMoney(packet)
- }
- start() {
- LogUtil.logV("BankQipaoTip", "start()")
- }
- showAlreadyMoney(data) {
- LogUtil.logV("BankQipaoTip", "showAlreadyMoney()")
- this.unscheduleAllCallbacks()
- this.node.stopAllActions()
- this.node.skewX = 0
- this.node.skewY = 0
- this.node.active = true
- if (GameM.commonData.currentRichBankCashTaskIndex > 0) {
- this.node.getChildByName("tixianNode").active = true
- this.node.getChildByName("qipaoBg").active = false
- this.node.getChildByName("tipLabel").active = false
- this.node.getChildByName("moneyLabel").active = false
- let lable = this.node.getChildByName("tixianNode").getChildByName("animlabel").getComponent(cc.Label)
- let index = 0
- this.schedule(() => {
- if (cc.isValid(lable)) {
- if (index == 0) {
- lable.string = "。"
- index = 1
- } else if (index == 1) {
- lable.string = "。。"
- index = 2
- } else if (index == 2) {
- lable.string = "。。。"
- index = 0
- }
- }
- }, 1)
- return
- }
- if (data == null || data == undefined) {
- this.node.getChildByName("qipaoBg").active = false
- this.node.getChildByName("tipLabel").active = false
- this.node.getChildByName("moneyLabel").active = false
- this.node.getChildByName("tixianNode").active = false
- return
- }
- if (!(data.length > 0)) {
- this.node.getChildByName("qipaoBg").active = false
- this.node.getChildByName("tipLabel").active = false
- this.node.getChildByName("moneyLabel").active = false
- this.node.getChildByName("tixianNode").active = false
- return
- }
- let money = 0
- for (let entry of data) {
- money += entry.amount
- }
- this.node.getChildByName("qipaoBg").active = true
- this.node.getChildByName("tipLabel").active = true
- this.node.getChildByName("moneyLabel").active = true
- this.node.getChildByName("tixianNode").active = false
- this.node.getChildByName("moneyLabel").getComponent(cc.Label).string = (money * 0.01).toFixed(2) + "元"
- let action =
- cc.sequence(
- cc.skewTo(0.125, 18.6, -18.6),
- cc.skewTo(0.125, 0, 0),
- cc.skewTo(0.125, -18.6, +18.6),
- cc.skewTo(0.125, 18.6, -18.6),
- cc.skewTo(0.125, 0, 0),
- cc.skewTo(0.125, -18.6, +18.6),
- cc.skewTo(0.125, 18.6, -18.6),
- cc.skewTo(0.125, 0, 0),
- cc.skewTo(0.125, -18.6, +18.6),
- cc.skewTo(0.125, 0, 0)
- )
- this.node.runAction(cc.repeatForever(cc.sequence(action, cc.delayTime(5))))
- }
- async creatPacketAnim(type: number) {
- this.itemP = await Utils.loadResPromise('prefabs/MoneySaveItem')
- 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()
- })))
- }
- clickPacket() {
- this.creatPacketAnim(Math.random() - 0.5 > 0 ? 1 : 2)
- }
- // update (dt) {}
- }
|