b38d0e9a-8ece-4e7e-a77a-168b740c3e37.js
11.1 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
"use strict";
cc._RF.push(module, 'b38d06ajs5Ofqd6Fot0DD43', 'MainScene');
// scripts/scenes/MainScene.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 GuideManager_1 = require("../component/GuideManager");
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 GameSceneObjTableMgr_1 = require("../kernel/table/GameSceneObjTableMgr");
var TableDefine_1 = require("../kernel/table/TableDefine");
var GameSceneControl_1 = require("../ui/gameScene/GameSceneControl");
var UIManager_1 = require("../ui/UIManager");
var ResWidget_1 = require("../ui/uiView/widget/ResWidget");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var MainScene = /** @class */ (function (_super) {
__extends(MainScene, _super);
function MainScene() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._sceneEffectAudioId = -1;
return _this;
//#endregion
}
//#region LIFE-CYCLE CALLBACKS:
MainScene.prototype.onLoad = function () {
BattleConst_1.getGlobalNode().on(Global_1.GlobalEvent.OBJ_UNLOCK_ANI_FINISH, this.onObjUnlock, this);
BattleConst_1.getGlobalNode().on(Global_1.GlobalEvent.SOUND_MUSIC_CONFIG_CHANGE, this.onSoundConfigChange, this);
var guideNode = this.node.getChildByName('guideNode');
if (guideNode.childrenCount > 0) {
GuideManager_1.GuideManager.ins.init(guideNode);
}
};
MainScene.prototype.start = function () {
this.node.getChildByName('widgetStar').getComponent(ResWidget_1.default).setType(Global_1.ResType.STAR);
this.node.getChildByName('widgetDiamond').getComponent(ResWidget_1.default).setType(Global_1.ResType.DIAMOND);
this._pageView = cc.find('gameSceneRoot/pageView', this.node).getComponent(cc.PageView);
this._buildScenePrefab = cc.find('gameSceneRoot/container', this.node);
this._charNode = cc.find('gameSceneRoot/' + (SaveDataManager_1.SaveDataManager.ins.runtimeData.gender == 0 ? 'girl' : 'boy'), this.node);
this._tipNode = cc.find('gameSceneRoot/unlockTip', this.node);
this._parGreenNode = cc.find('gameSceneRoot/parGreen', this.node);
this._bgLightNode = cc.find('gameSceneRoot/bg', this.node);
this._unlockSpineNode = cc.find('gameSceneRoot/unlockSpine', this.node);
var curScene = SaveDataManager_1.SaveDataManager.ins.runtimeData.curGameScene;
for (var i = 1; i < 4; ++i) {
if (i <= curScene) {
this.addScene(i);
}
}
if (this._pageView.getPages().length == 1) {
//只有一页,手动刷新
this._pageView.getPages()[0].getComponent(GameSceneControl_1.default).onSlideShow();
}
else {
this._pageView.setCurrentPageIndex(this._pageView.getPages().length - 1);
}
this.scheduleOnce(this.checkGuide.bind(this), 0); //等待自适应布局完毕后再检查
};
MainScene.prototype.onEnable = function () {
UIManager_1.UIManager.ins.widgetLayer.active = true;
if (SaveDataManager_1.SaveDataManager.ins.mainSceneAddStar > 0) {
SaveDataManager_1.SaveDataManager.ins.adjustStar(SaveDataManager_1.SaveDataManager.ins.mainSceneAddStar, true);
SaveDataManager_1.SaveDataManager.ins.mainSceneAddStar = 0;
}
//预加载地图
var maxLevel = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 22).Value;
var nextLevelId = SaveDataManager_1.SaveDataManager.ins.runtimeData.curLevel + 1;
if (nextLevelId > maxLevel) {
nextLevelId = maxLevel;
}
cc.resources.preload('map/map-' + nextLevelId.toString(), cc.TiledMapAsset);
this.onSoundConfigChange(SaveDataManager_1.SaveDataManager.ins.runtimeData.musicMute);
};
MainScene.prototype.onDisable = function () {
this._sceneEffectAudioId > -1 && cc.audioEngine.stopEffect(this._sceneEffectAudioId);
};
MainScene.prototype.onDestroy = function () {
// getGlobalNode().off(GlobalEvent.OBJ_UNLOCK_ANI_FINISH, this.onObjUnlock, this);
BattleConst_1.getGlobalNode().targetOff(this);
};
MainScene.prototype.update = function (dt) {
var backNode = cc.find('gameSceneRoot/pageView/backImgContainer', this.node);
var contentNode = cc.find('gameSceneRoot/pageView/content', this.node);
backNode.setPosition(contentNode.position);
var lightNode = cc.find('gameSceneRoot/pageView/effectLayer', this.node);
lightNode.setPosition(contentNode.position);
};
//#endregion
//#region event
MainScene.prototype.onPageSlide = function (view) {
var page = view.getCurrentPageIndex();
var pages = view.getPages();
for (var i = 0; i < pages.length; ++i) {
pages[i].getComponent(GameSceneControl_1.default).onSlideLeave();
}
pages[page].getComponent(GameSceneControl_1.default).onSlideShow();
};
MainScene.prototype.onToolClick = function (e) {
var curPage = this._pageView.getCurrentPageIndex();
this._pageView.getPages()[curPage].getComponent(GameSceneControl_1.default).onToolClick(e);
};
MainScene.prototype.onObjUnlock = function (objId) {
var obj = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_SCENE_OBJ, objId);
var sceneList = GameSceneObjTableMgr_1.GameSceneObjTableMgr.ins.getByScene(obj.SceneId);
var allUnlock = true;
for (var i = 0; i < sceneList.length; ++i) {
//判断此场景内的每个物件是否解锁
if (!SaveDataManager_1.SaveDataManager.ins.runtimeData.unlockObj.includes(sceneList[i].ID)) {
allUnlock = false;
break;
}
}
if (allUnlock && obj.SceneId < 3) {
//添加下一场景
SaveDataManager_1.SaveDataManager.ins.runtimeData.curGameScene++;
SaveDataManager_1.SaveDataManager.ins.saveData();
this.addScene(obj.SceneId + 1);
this._pageView.setCurrentPageIndex(obj.SceneId);
}
};
MainScene.prototype.onSoundConfigChange = function (mute) {
var sceneEffect = cc.resources.get('soundEffect/Scene', cc.AudioClip);
if (!mute) {
SoundManager_1.SoundManager.ins.playMusic();
this._sceneEffectAudioId = cc.audioEngine.playEffect(sceneEffect, true);
}
else {
SoundManager_1.SoundManager.ins.stopMusic();
this._sceneEffectAudioId > -1 && cc.audioEngine.stopEffect(this._sceneEffectAudioId);
}
};
//#endregion
//#region public
MainScene.prototype.onGuideClick = function () {
this.node.getChildByName('mask').active = false;
GuideManager_1.GuideManager.ins.hideTalk();
GuideManager_1.GuideManager.ins.hideHand();
// SaveDataManager.ins.runtimeData.guideStep++;
// SaveDataManager.ins.saveData();
};
//#endregion
//#region private
MainScene.prototype.addScene = function (sceneId) {
var buidScene = cc.instantiate(this._buildScenePrefab);
buidScene.active = true;
buidScene.getComponent(GameSceneControl_1.default).init(sceneId - 1, this._charNode, this._tipNode, this._parGreenNode, this._bgLightNode, this._unlockSpineNode);
buidScene.getComponent(GameSceneControl_1.default).loadScene(sceneId);
this._pageView.addPage(buidScene);
};
MainScene.prototype.checkGuide = function () {
var _this = this;
//引导
if (SaveDataManager_1.SaveDataManager.ins.runtimeData.guideStep == 0) {
var wpos = this._charNode.convertToWorldSpaceAR(cc.v2(0, 380));
var txt = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 25).Comment;
GuideManager_1.GuideManager.ins.showTalk(wpos, txt);
this.scheduleOnce(function () {
GuideManager_1.GuideManager.ins.hideTalk();
SaveDataManager_1.SaveDataManager.ins.runtimeData.guideStep++;
SaveDataManager_1.SaveDataManager.ins.saveData();
_this.checkGuide();
}, 3);
}
else if (SaveDataManager_1.SaveDataManager.ins.runtimeData.guideStep == 1) {
var wpos = this.node.getChildByName('UITitle').getChildByName('bottom').convertToWorldSpaceAR(cc.v2(0, 120));
GuideManager_1.GuideManager.ins.showHand(wpos, true);
wpos = this.node.getChildByName('UITitle').getChildByName('bottom').convertToWorldSpaceAR(cc.v2(0, 100));
wpos.y += 200;
var txt = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 26).Comment;
txt = txt.replace('{0}', Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, SaveDataManager_1.SaveDataManager.ins.runtimeData.gender == 0 ? 24 : 23).Comment);
GuideManager_1.GuideManager.ins.showTalk(wpos, txt);
var btn = cc.find('UITitle/bottom/naviBar/btnLayer/btn3', this.node);
wpos = btn.convertToWorldSpaceAR(cc.Vec2.ZERO);
UIManager_1.UIManager.ins.widgetLayer.convertToNodeSpaceAR(wpos, wpos);
var newBtn = cc.instantiate(btn);
newBtn.setPosition(wpos);
newBtn.getComponent(cc.Button).clickEvents[0].customEventData = '99';
UIManager_1.UIManager.ins.widgetLayer.addChild(newBtn);
this.node.getChildByName('mask').active = true;
}
};
MainScene = __decorate([
ccclass
], MainScene);
return MainScene;
}(cc.Component));
exports.default = MainScene;
cc._RF.pop();