| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- import { WealthData } from "../datas/WealthData";
- import AdM from "../manager/AdM";
- import { GameController } from "../manager/GameController";
- import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM";
- import GuideMng from "../manager/GuideMng";
- import WealthMng from "../manager/WealthMng";
- import MyExtends from "../tools/MyExtends";
- import Time from "../tools/Time";
- import BasePanel from "../uiFrames/BasePanel";
- import Sciencen_M from "../utils/Sciencen_M";
- import EffectNode from "./EffectNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class WealthPanel extends BasePanel {
- @property(cc.Node)
- panelNode: cc.Node = null;
- @property(cc.Node)
- redrain: cc.Node = null;
- @property(sp.Skeleton)
- cloudSpine: sp.Skeleton = null;
- @property(sp.Skeleton)
- wealthSpine: sp.Skeleton = null;
- @property(sp.Skeleton)
- shield: sp.Skeleton = null;
- @property(cc.Node)
- qipao: cc.Node = null;
- @property(cc.Node)
- qipaoTxts: cc.Node[] = [];
- @property(cc.Node)
- stateReadyAndCool: cc.Node = null;
- @property(cc.Node)
- tipReady: cc.Node = null;
- @property(cc.Node)
- tipCool: cc.Node = null;
- @property(cc.Label)
- txtReady: cc.Label = null;
- @property(cc.Label)
- txtCoolTimer: cc.Label = null;
- @property(cc.Label)
- txtshieldQipao: cc.Label = null;
- @property(cc.Node)
- stateShield: cc.Node = null;
- @property(cc.Node)
- shieldTip: cc.Node = null;
- @property(cc.Label)
- txtShieldTimer: cc.Label = null;
- @property(cc.Label)
- txtLeaveTimer: cc.Label = null;
- @property(cc.Node)
- stateGift: cc.Node = null;
- @property(cc.Node)
- giftTitle: cc.Node = null;
- @property(cc.Node)
- giftBox: cc.Node = null;
- @property(cc.Node)
- giftBtn: cc.Node = null;
- @property(cc.Label)
- txtGift: cc.Label = null;
- @property(cc.Node)
- stateEnd: cc.Node = null;
- @property(cc.Node)
- stateWealthing: cc.Node = null;
- @property(cc.Label)
- txtWealthCoin: cc.Label = null;
- @property(cc.Label)
- txtWealthingTimer: cc.Label = null;
- @property(cc.Node)
- stateGifting: cc.Node = null;
- @property(cc.Label)
- txtGiftingCoin: cc.Label = null;
- @property(cc.Label)
- txtGiftingProgress: cc.Label = null;
- @property(cc.Node)
- btnClose: cc.Node = null;
- /**界面类型 1 ready 2 cool 3 shield 4 gift 5 end*/
- private type: number = 1;
- isCanClick: boolean = true;
- giftingUpdateTimer: number = 0;
- /**进入界面
- * @param type:界面类型 1 ready 2 cool 3 shield 4 gift 5 end 6 wealthing 降临中 7 gifting 献礼进度
- */
- OnEnter(type: number) {
- if (type != 4) {
- this.panelNode.scale = 0;
- cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" })
- .call(() => {
- if (GuideMng.Ins.CurGuideId == 18) {
- GuideMng.Ins.ResumeGuide();
- }
- })
- .start();
- } else {
- this.panelNode.scale = 1;
- }
- this.node.active = true;
- this.isCanClick = true;
- this.type = type;
- this.btnClose.active = true;
- this.cloudSpine.node.active = false;
- this.shield.node.active = false;
- this.stateReadyAndCool.active = false;
- this.stateShield.active = false;
- this.stateGift.active = false;
- this.stateEnd.active = false;
- this.stateWealthing.active = false;
- this.stateGifting.active = false;
- this.qipaoTxts.forEach(element => {
- element.active = false;
- });
- this.qipaoTxts[type - 1].active = true;
- this.redrain.active = false;
- switch (type) {
- case 1:
- this.stateReadyAndCool.active = true;
- this.tipReady.active = true;
- this.tipCool.active = false;
- this.txtReady.string = WealthData.Ins.GetBloodGold() + "+" + WealthData.Ins.GetGiftGold();// "888亿+122亿";
- break;
- case 2:
- this.stateReadyAndCool.active = true;
- this.tipReady.active = false;
- this.tipCool.active = true;
- this.txtReady.string = WealthData.Ins.GetBloodGold() + "+" + WealthData.Ins.GetGiftGold();// "888亿+122亿";
- break;
- case 3:
- this.stateShield.active = true;
- this.txtshieldQipao.string = WealthData.Ins.GetGiftGold(false);
- this.shield.node.active = true;
- this.shield.setAnimation(0, "animation", true);
- break;
- case 4:
- this.giftTitle.active = false;
- this.giftBox.active = false;
- this.giftBtn.active = false;
- this.redrain.active = false;
- this.stateGift.active = true;
- console.log("+++++++1");
- this.node.stopAllActions();
- let a1 = cc.delayTime(1);
- let a2 = cc.callFunc(() => { this.giftTitle.active = true; console.log("+++++++2"); });
- let a3 = cc.delayTime(0.1);
- let a4 = cc.callFunc(() => { this.giftBox.active = true; console.log("+++++++3"); });
- let a5 = cc.delayTime(0.1);
- let a6 = cc.callFunc(() => { this.giftBtn.active = true; console.log("+++++++4"); });
- let a7 = cc.delayTime(0.1);
- let a8 = cc.callFunc(() => { this.redrain.active = true; console.log("+++++++5"); });
- this.node.runAction(cc.sequence(a1, a2, a3, a4, a5, a6, a7, a8));
- //this.redrain.active = true;
- this.txtGift.string = WealthData.Ins.GetGiftGold(false);
- GameM.audioM.setPauseMusic();
- GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm);
- this.btnClose.active = false;
- AdM.onSendEvent('caishen_award', '财神献礼触发', 'caishen');
- break;
- case 5:
- this.stateEnd.active = true;
- this.cloudSpine.node.active = true;
- break;
- case 6:
- this.stateWealthing.active = true;
- this.txtWealthCoin.string = WealthData.Ins.GetBloodGold() + "+" + WealthData.Ins.GetGiftGold();
- break;
- case 7:
- this.stateGifting.active = true;
- this.txtGiftingCoin.string = WealthData.Ins.GetGiftGold(false);
- this.giftingUpdateTimer = 0;
- this.txtGiftingProgress.string = ((1 - Number(Sciencen_M.instance.accDiv(WealthData.Ins.blood, WealthData.Ins.bloodValue))) * 100).toFixed(2) + "%";
- break;
- }
- if (GuideMng.Ins.CurGuideId == 18) {
- this.scheduleOnce(() => {
- GuideMng.Ins.ResumeGuide()
- }, 0.6)
- } //this.unschedule(this.DisplayCloseBtn);
- //this.scheduleOnce(this.DisplayCloseBtn, 3);
- }
- OnExit() {
- this.node.active = false;
- if (this.type == 4) {
- GameController.Ins.SwitchAudio(1);
- }
- }
- DisplayCloseBtn() {
- this.btnClose.active = true;
- }
- update(dt) {
- if (this.type == 2) {
- this.StateCooling();
- } else if (this.type == 3) {
- this.StateShield();
- } else if (this.type == 6) {
- this.StateWealthing();
- } else if (this.type == 7) {
- this.StateGifting(dt);
- }
- }
- StateCooling() {
- if (WealthData.Ins.isCooling) {
- this.txtCoolTimer.string = MyExtends.TimeToFormat(WealthData.Ins.coolingTimer, 3);
- }
- else {
- this.txtCoolTimer.string = "";
- this.OnEnter(1);
- this.btnClose.active = true;
- }
- }
- StateShield() {
- if (WealthData.Ins.shieldTimer > 0) {
- if (!this.shieldTip.active) this.shieldTip.active = true;
- this.txtShieldTimer.string = Math.floor(WealthData.Ins.shieldTimer) + "s";
- }
- else {
- if (this.shieldTip.active) {
- this.shieldTip.active = false;
- this.CloseShield();
- }
- this.txtShieldTimer.string = "";
- }
- if (WealthData.Ins.lifeTimer > 0) {
- this.txtLeaveTimer.string = MyExtends.TimeToFormat(WealthData.Ins.lifeTimer) + "秒后财神离去";
- }
- else {
- this.txtLeaveTimer.string = ""
- }
- }
- StateWealthing() {
- if (WealthData.Ins.isTriggerWealth) {
- this.txtWealthingTimer.string = MyExtends.TimeToFormat(WealthData.Ins.lifeTimer, 3);
- }
- else {
- this.txtWealthingTimer.string = "";
- this.OnExit();
- this.btnClose.active = true;
- }
- }
- StateGifting(dt) {
- if (WealthData.Ins.isTriggerWealth) {
- this.giftingUpdateTimer += dt;
- if (this.giftingUpdateTimer > 1) {
- this.giftingUpdateTimer = 0;
- this.txtGiftingProgress.string = ((1 - Number(Sciencen_M.instance.accDiv(WealthData.Ins.blood, WealthData.Ins.bloodValue))) * 100).toFixed(2) + "%";
- }
- }
- else {
- this.txtGiftingProgress.string = "";
- this.OnExit();
- this.btnClose.active = true;
- }
- }
- Click_ClearShieldBtn() {
- if (!this.isCanClick) return;
- AdM.Instance.watchVideo(VIDEO_TYPE.clearShield);
- AdM.onSendEvent(`video_init_15`, `看视频清除金钟罩`, 'video_init');
- }
- AdEndClearShield() {
- this.isCanClick = false;
- WealthMng.Ins.ClearShield();
- this.CloseShield();
- AdM.onSendEvent(`video_end_15`, `看视频清除金钟罩`, 'video_end');
- AdM.onSendEvent('caishen_skill_over', '财神金钟罩技能消除', 'caishen');
- }
- async CloseShield() {
- this.shield.setAnimation(0, "animation2", false);
- await Time.WaitForSeconds(this.shield.findAnimation("animation2").duration);
- this.shield.node.active = false;
- this.isCanClick = true;
- this.OnExit();
- }
- Click_GetGiftBtn() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- GameM.commonData.updateGold(WealthData.Ins.giftValue);
- this.OnExit();
- EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
- EffectNode.instance.PlayScreenCoin();
- GuideMng.Ins.CheckWealthGiftGuide18();
- }
- Click_CloseBtn() {
- GameM.audioM.playEffect(AUDIO_TYPE.button);
- this.OnExit();
- }
- }
|