123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- import BasicView from "../../../Engine/Basic/BasicView";
- import { _EJsonRes } from "../../../Engine/Data/CommonDataType";
- import EventManager from "../../../Engine/Event/EventManager";
- import JsonResources from "../../../Engine/Resources/JsonResources";
- import LoadProgress from "../../../Engine/Component/View/LoadProgress";
- import { _EGameBehavior, ConstObject, _EGameJsonRes } from "../../Data/GameDataType";
- import { _IUserData } from "../../Data/User/UserConfig";
- import GameEventName from "../../Event/GameEventName";
- import { _IViewResConfig } from "../../../Engine/View/Data/ViewConfig";
- import GameAudioResData from "../../Game/Data/GameMusicResData";
- /**
- * 启动页
- */
- export default class InitLoadView extends BasicView {
- public static resPath: string = "InitLoadView";
- /**进度条 */
- private progress: fgui.GProgressBar;
- protected _initView(): void {
- this.progress = this.fgui.getChild("progress").asProgress;
- // 更新加载进度条
- EventManager.onEvent(GameEventName.Res.Res_LoadProgress, this, (_progress: number) => {
- this.progress.value = _progress*this.progress.max;
- });
- let load1 = false;
- let load2 = false;
- cc.assetManager.loadBundle("res/prefab", (err: Error, prefab: cc.AssetManager.Bundle) => {
- cc.assetManager.loadBundle("res/audio", (err: Error, audio: cc.AssetManager.Bundle) => {
- load1 = true;
- if (load1 == true && load2 == true) {
- this.laodComplete();
- }
- });
- });
- // 加载游戏资源
- {
- // 加载配置表
- let json: Array<string> = [];
- for (let name in _EJsonRes) {
- json.push(_EJsonRes[name]);
- }
- for (let name in _EGameJsonRes) {
- json.push(_EGameJsonRes[name]);
- }
- JsonResources.loadJsonResources(ConstObject.ResPath, json, 1/4, 0,
- () => {
- // 关闭事件监听
- EventManager.offEventByTarget(this);
-
- let viewResConfig: _IViewResConfig = JsonResources.getResources(_EJsonRes.ResGroup)["InitLoadView"];
- this.addComponentIntance(new LoadProgress(this.progress, (_progress: number) => {
- this.progress.getChild("progressText").asTextField.text = Math.round(_progress)+"%";
- }, () => {
- load2 = true;
- if (load1 == true && load2 == true) {
- this.laodComplete();
- }
- }, viewResConfig));
- }
- );
- }
- }
- protected _refreshView(): void {
-
- }
- protected _clearView(): void {
-
- }
- protected resize () {
-
- }
- private laodComplete (): void {
- EventManager.sendEvent(GameEventName.Audio.Audio_PlayMusic, GameAudioResData.BGM);
-
- EventManager.sendEvent(GameEventName.Behavior.Behavior_SetPreconditionData, _EGameBehavior.Hall, {initLoad: true});
- EventManager.sendEventByTargetID(GameEventName.Behavior.Behavior_EnterBehavior, ConstObject.GameFlowTreeID, _EGameBehavior.Gameing);
- }
- }
|