e8915325-abf7-4a75-9269-20b0124131f3.js 6.26 KB
"use strict";
cc._RF.push(module, 'e8915Mlq/dKdZJpILASQTHz', 'CCGameCenterComponent');
// script/cooperation/script/CCGameCenterComponent.ts

"use strict";
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 });
const EventCenter_1 = require("../event/EventCenter");
const EventKit_1 = require("../event/EventKit");
const CooperationDataCenter_1 = require("./CooperationDataCenter");
const CCGameCenterNodeFactory_1 = require("./CCGameCenterNodeFactory");
const GameCenter_1 = require("./GameCenter");
const CCDummyObjects_1 = require("../../common/CCDummyObjects");
/**
 * 游戏盒子组件
 */
const { ccclass, property } = cc._decorator;
let CCGameCenterComponent = /** @class */ (() => {
    let CCGameCenterComponent = class CCGameCenterComponent extends cc.Component {
        constructor() {
            super(...arguments);
            this.gameCenterBtnPrefab = CCDummyObjects_1.DummyPrefab;
            this.gameCenterViewPrefab = CCDummyObjects_1.DummyPrefab;
            this.gameCenterItemPrefab = CCDummyObjects_1.DummyPrefab;
            this.gameCenterMomentPrefab = CCDummyObjects_1.DummyPrefab;
            this.gameCenterParentNode = CCDummyObjects_1.DummyNode;
            this.mainUISubGameNode = CCDummyObjects_1.DummyNode;
            this.isRelease = false;
            this.appID = "";
            this.gameID = "";
            this.gameChannel = "wechat";
            this._disposable = new EventKit_1.CompositeDisposable;
            this._gameCenterViewNode = CCDummyObjects_1.DummyNode;
            this.onDownloadCooperationDataSucceed = () => {
                EventCenter_1.EventCenter.REFRESH_SUB_GAME_LIST.emit();
            };
            /**控制游戏列表是否展示 */
            this.onShowGameCenterListView = (isShow) => {
                if (!this._gameCenterViewNode) {
                    return;
                }
                this._gameCenterViewNode.active = isShow;
            };
        }
        onLoad() {
        }
        init() {
            this.registerEventListener();
            this.createNode();
            this.onShowGameCenterListView(false);
            CooperationDataCenter_1.default.getInstance().setCurGameID(this.gameID);
            CooperationDataCenter_1.default.getInstance().setCurGameAppID(this.appID);
            CooperationDataCenter_1.default.getInstance().setCurGameChannel(this.gameChannel);
            GameCenter_1.default.getInstance().init();
            CCGameCenterNodeFactory_1.default.getInstance().init();
            CCGameCenterNodeFactory_1.default.getInstance().registerMomentPrefab(this.gameCenterMomentPrefab);
            CCGameCenterNodeFactory_1.default.getInstance().registerSubGamePrefab(this.gameCenterItemPrefab);
            CCGameCenterNodeFactory_1.default.getInstance().registerMainUISubGameNode(this.mainUISubGameNode);
            EventCenter_1.EventCenter.REQUEST_COOPERATION_DATA_FROM_OSS.emit(this.isRelease);
        }
        registerEventListener() {
            this._disposable.add(EventCenter_1.EventCenter.COOPERATION_DATA_DOWNLOAD_SUCCEED.on(this.onDownloadCooperationDataSucceed));
            this._disposable.add(EventCenter_1.EventCenter.SHOW_GAME_CENTER_LIST_VIEW.on(this.onShowGameCenterListView));
        }
        /**创建prefab对应的节点 */
        createNode() {
            if (!this.gameCenterViewPrefab) {
                cc.error("gameCenterViewPrefab is not set , please check it over");
            }
            else {
                this._gameCenterViewNode = cc.instantiate(this.gameCenterViewPrefab);
            }
            let parentNode = cc.director.getScene();
            if (this.gameCenterParentNode) {
                parentNode = this.gameCenterParentNode;
            }
            this._gameCenterViewNode.parent = parentNode;
            this._gameCenterViewNode.position = cc.v3(cc.winSize.width / 2, cc.winSize.height / 2, 0);
        }
        start() {
        }
        update(dt) {
        }
    };
    __decorate([
        property({ type: cc.Prefab, tooltip: "游戏盒子按钮prefab", displayName: "gameCenterBtnPrefab" })
    ], CCGameCenterComponent.prototype, "gameCenterBtnPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "游戏列表prefab", displayName: "gameCenterViewPrefab" })
    ], CCGameCenterComponent.prototype, "gameCenterViewPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "子游戏prefab", displayName: "gameCenterItemPrefab" })
    ], CCGameCenterComponent.prototype, "gameCenterItemPrefab", void 0);
    __decorate([
        property({ type: cc.Prefab, tooltip: "游戏朋友圈prefab", displayName: "gameCenterMomentPrefab" })
    ], CCGameCenterComponent.prototype, "gameCenterMomentPrefab", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "游戏中心列表的父节点" })
    ], CCGameCenterComponent.prototype, "gameCenterParentNode", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "在外面展示的子游戏" })
    ], CCGameCenterComponent.prototype, "mainUISubGameNode", void 0);
    __decorate([
        property({ tooltip: "是否是release环境" })
    ], CCGameCenterComponent.prototype, "isRelease", void 0);
    __decorate([
        property({ tooltip: "当前游戏的微信APPID" })
    ], CCGameCenterComponent.prototype, "appID", void 0);
    __decorate([
        property({ tooltip: "当前游戏的GameID:" })
    ], CCGameCenterComponent.prototype, "gameID", void 0);
    __decorate([
        property({ tooltip: "当前游戏的渠道" })
    ], CCGameCenterComponent.prototype, "gameChannel", void 0);
    CCGameCenterComponent = __decorate([
        ccclass
    ], CCGameCenterComponent);
    return CCGameCenterComponent;
})();
exports.default = CCGameCenterComponent;

cc._RF.pop();