private void PostAwakeTryLoadFromFile() { if (DevLevelConfigData.configFromScene) { this.TryDestroyTypeAll <BaseMonoAvatar>(); this.TryDestroyTypeAll <BaseMonoMonster>(); this.TryDestroyTypeAll <MonoBasePerpStage>(); this.TryDestroyTypeAll <MonoStageEnv>(); Resources.UnloadUnusedAssets(); GC.Collect(); GC.WaitForPendingFinalizers(); StageEntry stageEntryByName = StageData.GetStageEntryByName(this.stageDevData.stageName); GameObject obj2 = UnityEngine.Object.Instantiate <GameObject>(Miscs.LoadResource <GameObject>(stageEntryByName.GetPerpStagePrefabPath(), BundleType.RESOURCE_FILE)); obj2.transform.position = Vector3.zero; Transform transform = obj2.transform; transform.position -= obj2.transform.Find(stageEntryByName.LocationPointName).position; StageManager.SetPerpstageNodeVisibility(obj2.GetComponent <MonoBasePerpStage>(), stageEntryByName, false, false); StageManager.SetPerpstageNodeVisibility(obj2.GetComponent <MonoBasePerpStage>(), stageEntryByName, true, true); UnityEngine.Object.Instantiate <GameObject>(Miscs.LoadResource <GameObject>(stageEntryByName.GetEnvPrefabPath(), BundleType.RESOURCE_FILE)); DevAvatarData data = this.avatarDevDatas[0]; UnityEngine.Object.Instantiate <GameObject>(Miscs.LoadResource <GameObject>(AvatarData.GetPrefabResPath(data.avatarType, false), BundleType.RESOURCE_FILE)); this.monsterInstanceIds = new List <int>(); foreach (DevMonsterData data2 in this.monsterDevDatas) { this.monsterInstanceIds.Add(UnityEngine.Object.Instantiate <GameObject>(Miscs.LoadResource <GameObject>(MonsterData.GetPrefabResPath(data2.monsterName, data2.typeName, false), BundleType.RESOURCE_FILE)).GetInstanceID()); } } }
public uint CreateMonster(string monsterName, string typeName, int level, bool isLocal, Vector3 initPos, uint runtimeID, bool isElite = false, uint uniqueMonsterID = 0, bool checkOutsideWall = true, bool disableBehaviorWhenInit = false, int tagID = 0) { BaseMonoMonster component = null; GameObject gameObj = null; if (uniqueMonsterID != 0) { UniqueMonsterMetaData uniqueMonsterMetaData = MonsterData.GetUniqueMonsterMetaData(uniqueMonsterID); monsterName = uniqueMonsterMetaData.monsterName; typeName = uniqueMonsterMetaData.typeName; } string str = monsterName + typeName + uniqueMonsterID.ToString() + disableBehaviorWhenInit.ToString(); int index = 0; int num2 = 0; int count = this._preloadedMonsters.Count; while (num2 < count) { if (this._preloadedMonsters[num2].name == str) { gameObj = this._preloadedMonsters[num2].gameObj; index = num2; break; } num2++; } if (gameObj != null) { gameObj.SetActive(true); this._preloadedMonsters.RemoveAt(index); } else { gameObj = (GameObject)UnityEngine.Object.Instantiate(Miscs.LoadResource <GameObject>(MonsterData.GetPrefabResPath(monsterName, typeName, !GlobalVars.MONSTER_USE_DYNAMIC_BONE || (Singleton <LevelManager> .Instance.levelActor.levelMode == LevelActor.Mode.Multi)), BundleType.RESOURCE_FILE), InLevelData.CREATE_INIT_POS, Quaternion.identity); } component = gameObj.GetComponent <BaseMonoMonster>(); if (runtimeID == 0) { runtimeID = Singleton <RuntimeIDManager> .Instance.GetNextRuntimeID(4); } bool flag = checkOutsideWall; component.Init(monsterName, typeName, runtimeID, initPos, uniqueMonsterID, null, flag, isElite, disableBehaviorWhenInit, tagID); this.RegisterMonster(component); MonsterActor actor = Singleton <EventManager> .Instance.CreateActor <MonsterActor>(component); actor.InitLevelData(level, isElite); actor.PostInit(); int num4 = 0; int length = component.config.CommonArguments.RequestSoundBankNames.Length; while (num4 < length) { Singleton <WwiseAudioManager> .Instance.ManualPrepareBank(component.config.CommonArguments.RequestSoundBankNames[num4]); num4++; } return(component.GetRuntimeID()); }
public uint CreateMonsterMirror(BaseMonoMonster owner, Vector3 initPos, Vector3 initDir, string AIName, float hpRatio, bool disableBehaviorWhenInit = false) { BaseMonoMonster component = ((GameObject)UnityEngine.Object.Instantiate(Miscs.LoadResource <GameObject>(MonsterData.GetPrefabResPath(owner.MonsterName, owner.TypeName, false), BundleType.RESOURCE_FILE), initPos, Quaternion.LookRotation(initDir))).GetComponent <BaseMonoMonster>(); bool flag = disableBehaviorWhenInit; component.Init(owner.MonsterName, owner.TypeName, Singleton <RuntimeIDManager> .Instance.GetNextRuntimeID(4), initPos, owner.uniqueMonsterID, AIName, true, false, flag, 0); this.RegisterMonster(component); MonsterMirrorActor actor = Singleton <EventManager> .Instance.CreateActor <MonsterMirrorActor>(component); actor.InitFromMonsterActor(Singleton <EventManager> .Instance.GetActor <MonsterActor>(owner.GetRuntimeID()), hpRatio); actor.PostInit(); int index = 0; int length = component.config.CommonArguments.RequestSoundBankNames.Length; while (index < length) { Singleton <WwiseAudioManager> .Instance.ManualPrepareBank(component.config.CommonArguments.RequestSoundBankNames[index]); index++; } return(component.GetRuntimeID()); }
public void PreloadMonster(string monsterName, string typeName, uint uniqueMonsterID = 0, bool disableBehaviorWhenInit = false) { string name = monsterName + typeName + uniqueMonsterID.ToString() + disableBehaviorWhenInit.ToString(); for (int i = 0; i < this._preloadedMonsters.Count; i++) { if ((this._preloadedMonsters[i].name == name) && !this._preloadedMonsters[i].occupied) { this._preloadedMonsters[i].occupied = true; return; } } GameObject gameObj = (GameObject)UnityEngine.Object.Instantiate(Miscs.LoadResource <GameObject>(MonsterData.GetPrefabResPath(monsterName, typeName, !GlobalVars.MONSTER_USE_DYNAMIC_BONE || (Singleton <LevelManager> .Instance.levelActor.levelMode == LevelActor.Mode.Multi)), BundleType.RESOURCE_FILE), InLevelData.CREATE_INIT_POS, Quaternion.identity); BaseMonoMonster component = gameObj.GetComponent <BaseMonoMonster>(); component.PreInit(monsterName, typeName, uniqueMonsterID, disableBehaviorWhenInit); gameObj.SetActive(false); PreloadMonsterItem item = new PreloadMonsterItem(name, gameObj, component.config); this._preloadedMonsters.Add(item); ConfigMonster monster2 = MonsterData.GetMonsterConfig(monsterName, typeName, string.Empty); for (int j = 0; j < monster2.CommonArguments.PreloadEffectPatternGroups.Length; j++) { Singleton <EffectManager> .Instance.PreloadEffectGroup(monster2.CommonArguments.PreloadEffectPatternGroups[j], false); } for (int k = 0; k < monster2.CommonArguments.RequestSoundBankNames.Length; k++) { Singleton <WwiseAudioManager> .Instance.ManualPrepareBank(component.config.CommonArguments.RequestSoundBankNames[k]); } }