UIFreeDiamond.ts 1.55 KB
// 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

import { SaveDataManager } from "../../component/SaveDataManager";
import { ADID, tMgr, WindowName } from "../../Global";

import { GamePlayTable, TableName } from "../../kernel/table/TableDefine";
import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class UIFreeDiamond extends UIBase {
    @property(cc.Node)
    btn_ad: cc.Node = null;
    private _num: number = 0;

    protected onEnable(): void {
        this._num = (tMgr.getConfig(TableName.GAME_PLAY, 14) as GamePlayTable).Value;

        this.node.getChildByName('txtNum').getComponent(cc.Label).string = this._num.toString();

    }

    onBtnGetClick() {
        //AD 放广告,放完后调get
        // HeyGamePlatform.instance.showVideoAd(ADID.ADID_ADDCOIN, (_result) => {
        if (true) {
            this.get();
        } else {
            console.log('视频播放失败');
        }
        // });
    }

    onBtnAdClick() {
        //AD 纯放广告
    }

    onCloseClick() {
        this.close();
    }

    private get() {
        SaveDataManager.ins.adjustDiamond(this._num, true);
        this.close();
    }

    close(): void {
        UIManager.ins.closeWindow(WindowName.FREE_DIAMOND);

    }
}