cce32cc6-46d6-42b8-9164-3116e5933137.js 7.17 KB
"use strict";
cc._RF.push(module, 'cce32zGRtZCuJFkMRblkzE3', 'UIRevive');
// scripts/ui/uiView/UIRevive.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var SaveDataManager_1 = require("../../component/SaveDataManager");
var SoundManager_1 = require("../../component/SoundManager");
var Global_1 = require("../../Global");
var BattleManager_1 = require("../../kernel/battle/BattleManager");
var UserSkillShuriken_1 = require("../../kernel/battle/userSkill/UserSkillShuriken");
var UIBase_1 = require("../UIBase");
var UIManager_1 = require("../UIManager");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var UIRevive = /** @class */ (function (_super) {
    __extends(UIRevive, _super);
    function UIRevive() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._reviveCount = 0;
        _this._diamondCount = 0;
        _this._countDown = 5;
        _this._countDownNodeList = [];
        _this.btn_ad = null;
        _this.btn_start = null;
        _this.btn_bonus = null;
        //#region  LIFE-CYCLE CALLBACKS:
        _this.openCount = 0;
        return _this;
        //#endregion
    }
    UIRevive.prototype.onLoad = function () {
        for (var i = 0; i < 6; ++i) {
            this._countDownNodeList.push(this.node.getChildByName('countdownNode').getChildByName('imgCount' + i.toString()));
        }
    };
    UIRevive.prototype.onEnable = function () {
        this._reviveCount = BattleManager_1.BattleManager.ins.curBattle.reviveCount;
        this._diamondCount = (this._reviveCount + 1) * 100;
        this.node.getChildByName('btnDelete3').getComponentInChildren(cc.Label).string = this._diamondCount.toString();
        this.node.getChildByName('btnDelete3').getComponent(cc.Button).interactable = (SaveDataManager_1.SaveDataManager.ins.runtimeData.diamond >= this._diamondCount);
        this._countDown = 5;
        this.startCountDown();
        this.onCountDown();
        SoundManager_1.SoundManager.ins.playEffect(Global_1.SoundName.CONTINUE);
        this.btn_ad.getChildByName('Background').getChildByName('UI_General_Btn_yellow_ckgg').active = true;
        this.btn_ad.getChildByName('Background').getChildByName('UI_Finish_kxsx').active = false;
        this.openCount++;
        if (this.openCount > 1) {
            this.BtnPos_Change();
        }
    };
    //按钮位置轮换
    UIRevive.prototype.BtnPos_Change = function () {
        var tempPos = this.btn_start.position;
        this.btn_start.position = this.btn_bonus.position;
        this.btn_bonus.position = this.btn_ad.position;
        this.btn_ad.position = tempPos;
    };
    UIRevive.prototype.onDisable = function () {
        this.unschedule(this.onCountDown);
    };
    // update (dt) {}
    //#endregion
    //#region public method
    //#endregion
    //#region event
    UIRevive.prototype.onDelete3Click = function () {
        if (SaveDataManager_1.SaveDataManager.ins.adjustDiamond(-this._diamondCount)) {
            //删除3行
            for (var i = 0; i < 3; ++i) {
                new UserSkillShuriken_1.UserSkillShuriken(BattleManager_1.BattleManager.ins.curBattle).doSkillRevive();
            }
            BattleManager_1.BattleManager.ins.curBattle.reviveCount++;
            BattleManager_1.BattleManager.ins.shootTouchEnable = true; //弹出此界面表示已经输了,操作被锁定,用技能后解锁
            this.leave();
        }
        else {
            //钻石不足
        }
    };
    UIRevive.prototype.onReviveClick = function () {
        this.unschedule(this.onCountDown); //暂停倒计时
        //AD 放广告, 然后调用 doRevive
        // HeyGamePlatform.instance.showVideoAd(ADID.ADID_ADDCOIN, (_result) => {
        if (true) {
            this.doRevive();
        }
        else {
            console.log('视频播放失败');
        }
        // });
    };
    UIRevive.prototype.onAdClick = function () {
        this.unschedule(this.onCountDown); //暂停倒计时
        //AD 放广告 放完后调 this.startCountDown
    };
    UIRevive.prototype.onCloseClick = function () {
        this.leave();
        // UIManager.ins.openWindow(WindowName.BATTLE_RESULT, false);//弹出失败窗口
        BattleManager_1.BattleManager.ins.curBattle.finishBattle(false, false);
    };
    UIRevive.prototype.onCountDown = function () {
        if (this._countDown <= 0) {
            this.unschedule(this.onCountDown);
            this.onCloseClick();
        }
        this._countDown--;
        this.updateCountDown(this._countDown);
    };
    //#endregion
    //#region private method
    UIRevive.prototype.startCountDown = function () {
        this.schedule(this.onCountDown, 1, 5);
    };
    UIRevive.prototype.doRevive = function () {
        new UserSkillShuriken_1.UserSkillShuriken(BattleManager_1.BattleManager.ins.curBattle).doSkillRevive();
        BattleManager_1.BattleManager.ins.shootTouchEnable = true; //弹出此界面表示已经输了,操作被锁定,用技能后解锁
        this.leave();
    };
    UIRevive.prototype.leave = function () {
        UIManager_1.UIManager.ins.closeWindow(Global_1.WindowName.REVIVE);
    };
    UIRevive.prototype.updateCountDown = function (num) {
        for (var i = 0; i < this._countDownNodeList.length; ++i) {
            this._countDownNodeList[i].active = (i == num);
        }
    };
    __decorate([
        property(cc.Node)
    ], UIRevive.prototype, "btn_ad", void 0);
    __decorate([
        property(cc.Node)
    ], UIRevive.prototype, "btn_start", void 0);
    __decorate([
        property(cc.Node)
    ], UIRevive.prototype, "btn_bonus", void 0);
    UIRevive = __decorate([
        ccclass
    ], UIRevive);
    return UIRevive;
}(UIBase_1.UIBase));
exports.default = UIRevive;

cc._RF.pop();