import { _decorator, Component, Node, tween, v3 } from 'cc'; import platformSystem from '../platform/platformSystem'; import BasePanel from '../core/component/BasePanel'; import { audioMgr } from '../core/manager/AudioManager'; import WindowManager from '../core/manager/WindowManager'; import { Main } from '../game/Main'; import { GameConst } from '../core/common/GameConst'; const { ccclass, property } = _decorator; @ccclass('OutOfBoxLayer') export class OutOfBoxLayer extends BasePanel { start() { let btn_clear = this.GetGameObject("btn_clear"); tween(btn_clear).sequence(tween(btn_clear).to(1, { scale: v3(0.8, 0.8, 0.8) }), tween(btn_clear).to(1, { scale: v3(1, 1, 1) })).repeatForever().start() this.SetText("lbl_coll_star", Main.I._GameUI.star + ""); this.GetGameObject("one-more-chance-bg").active = false; Main.I._GameUI.pasue = true; audioMgr.playOneShot(GameConst.audios.softFail); } onDestroy() { super.onDestroy(); Main.I._GameUI.pasue = false; } onBtnClicked(event: any, customEventData: any) { audioMgr.playOneShot(GameConst.audios.btnclick); var btnName = event.target.name; switch (btnName) { case "btn_close": if (this.GetGameObject("one-more-chance-bg").active == false && Main.I._GameUI.star > 0) { this.GetGameObject("one-more-chance-bg").active = true; tween(this.GetGameObject("one-more-chance-bg")).to(1, { position: v3(0, 372, 0) }).start(); return } this.close(); WindowManager.ins.open("FailLayer"); break; case "btn_clear": platformSystem.platform.showRewardVideo((b) => { if (b == 0) { this.dispatch(GameConst.CLEAR_ALL_BOX); this.close(); } else if (b == -2) { platformSystem.platform.shareAppMessage((bol) => { if (bol) { this.dispatch(GameConst.CLEAR_ALL_BOX); this.close(); } }) } }) break; } } }