/// <summary> /// 初始化探索场景 /// </summary> /// <param name="from">From.</param> public void SetUpExploreView(MapSetUpFrom from) { // 标记探索场景 not ready exploreSceneReady = false; // 加载探索场景所需的游戏资源 GameManager.Instance.gameDataCenter.InitExplorePrepareGameData(); // 是否是最后一关 bool isFinalChapter = Player.mainPlayer.currentLevelIndex == CommonData.maxLevelIndex; // 垃圾回收 System.GC.Collect(); DisableExploreInteractivity(); // 生成地图 newMapGenerator.SetUpMap(from); // 清除人物身上的字母碎片 Player.mainPlayer.ClearCollectedCharacters(); // 记录人物的存档位置和存档朝向 //Player.mainPlayer.savePosition = battlePlayerCtr.transform.position; //Player.mainPlayer.saveTowards = battlePlayerCtr.towards; // 加载玩家数据 //PlayerData playerData = GameManager.Instance.persistDataManager.LoadPlayerData(); //// 初始化人物数据 //Player.mainPlayer.SetUpPlayerWithPlayerData(playerData); // 存档 SaveDataInExplore(null, false); // 初始化探索UI界面 expUICtr.SetUpExploreCanvas(); // 初始化玩家角色 battlePlayerCtr.InitBattlePlayer(); // 如果是终章 if (isFinalChapter) { // 隐藏底部bar expUICtr.HideUpAndBottomUIs(); // 加载终章画布 GameManager.Instance.UIManager.SetUpCanvasWith(CommonData.finalChapterCanvasBundleName, "FinalChapterCanvas", delegate { TransformManager.FindTransform("FinalChapterCanvas").GetComponent <FinalChapterViewControlller>().SetUpFinalChapterView(); }); } EnableExploreInteractivity(); // 探索场景ready exploreSceneReady = true; }
//Initializes the game for each level. public void SetUpExploreView(GameLevelData levelData) { // StartCoroutine ("SetUpExploreAfterDataReady",levelData); // // } // // private IEnumerator SetUpExploreAfterDataReady(GameLevelData levelData){ // // bool dataReady = false; // // while (!dataReady) { // // dataReady = GameManager.Instance.gameDataCenter.CheckDatasReady (new GameDataCenter.GameDataType[] { // GameDataCenter.GameDataType.UISprites, // GameDataCenter.GameDataType.GameLevelDatas, //// GameDataCenter.GameDataType.Monsters, // GameDataCenter.GameDataType.NPCs, // GameDataCenter.GameDataType.ItemModels, // GameDataCenter.GameDataType.ItemSprites, // GameDataCenter.GameDataType.MapSprites, // GameDataCenter.GameDataType.Skills, // GameDataCenter.GameDataType.SkillSprites, // }); // // yield return null; // } if (!SoundManager.Instance.bgmAS.isPlaying || SoundManager.Instance.bgmAS.clip.name != CommonData.exploreBgmName) { SoundManager.Instance.PlayBgmAudioClip(CommonData.exploreBgmName); } levelData.LoadAllData(); currentLevelIndex = levelData.gameLevelIndex; mapGenerator.SetUpMap(levelData); ExploreUICotroller expUICtr = TransformManager.FindTransform("ExploreCanvas").GetComponent <ExploreUICotroller> (); expUICtr.SetUpExploreCanvas(levelData.gameLevelIndex, levelData.chapterName); battlePlayerCtr.InitBattlePlayer(); EnableInteractivity(); }