1cd6983c-bde8-4e8a-a626-caa9a17d3364.js 4.45 KB
"use strict";
cc._RF.push(module, '1cd69g8vehOiqYmyqmhfTNk', 'Starter');
// scripts/scenes/Starter.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 BattleConst_1 = require("../kernel/battle/BattleConst");
var GlobalNode_1 = require("../kernel/GlobalNode");
var TableDefine_1 = require("../kernel/table/TableDefine");
var UIManager_1 = require("../ui/UIManager");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Starter = /** @class */ (function (_super) {
    __extends(Starter, _super);
    function Starter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    // LIFE-CYCLE CALLBACKS:
    Starter.prototype.onLoad = function () {
        //#region 添加全局节点,UIRoot挂在全局节点下,位于Canvas上层,Canvas只显示场景
        var gl = BattleConst_1.getGlobalNode();
        // gl = new cc.Node(GLOBAL_NODE_NAME);
        cc.game.addPersistRootNode(gl);
        gl.addComponent(GlobalNode_1.default);
        var widget = gl.addComponent(cc.Widget);
        widget.isAlignLeft = true;
        widget.isAlignRight = true;
        widget.isAlignTop = true;
        widget.isAlignBottom = true;
        widget.left = 0;
        widget.right = 0;
        widget.top = 0;
        widget.bottom = 0;
        widget.updateAlignment();
        var uiNode = this.node.getChildByName('UIRoot');
        uiNode.removeFromParent(false);
        gl.addChild(uiNode);
        //#endregion
        UIManager_1.UIManager.ins.init(uiNode);
    };
    Starter.prototype.start = function () {
        SaveDataManager_1.SaveDataManager.ins.init();
        cc.resources.loadDir("data", cc.JsonAsset, this.onTableLoaded.bind(this));
    };
    Starter.prototype.onTableLoaded = function (error, data) {
        //#region 按钮添加音效
        cc.Button.prototype['touchEndClone'] = cc.Button.prototype['_onTouchEnded'];
        cc.Button.prototype['_onTouchEnded'] = function (event) {
            if (this.interactable && this.enabledInHierarchy && this._pressed) {
                // log('播放音效');
                SoundManager_1.SoundManager.ins.playEffect('Click');
            }
            this.touchEndClone(event);
        };
        //#endregion
        for (var i = 0; i < data.length; ++i) {
            Global_1.tMgr.setTable(data[i].name, data[i].json, TableDefine_1.TableMap[data[i].name]);
        }
        Global_1.tMgr.parse();
        if (SaveDataManager_1.SaveDataManager.ins.runtimeData.gender == -1) {
            // UIManager.ins.openWindow(WindowName.SELECT_GENDER);
            UIManager_1.UIManager.ins.openScene('Opening');
        }
        else {
            UIManager_1.UIManager.ins.openScene('Main');
        }
    };
    Starter = __decorate([
        ccclass
    ], Starter);
    return Starter;
}(cc.Component));
exports.default = Starter;

cc._RF.pop();