e8915325-abf7-4a75-9269-20b0124131f3.js
6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"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();