private void LoadLevel(int index) { while (transform.childCount > 1) { DestroyImmediate(transform.GetChild(transform.GetChild(0).name == "static" ? 1 : 0).gameObject); } if (TimeCtrl) { DestroyImmediate(TimeCtrl); } TimeCtrl = gameObject.AddComponent <TimeController>(); Config = new FizzleJson(sceneInfos[index].Key); LevelName = Config.GetOrDefault("level-name", "untitled"); LevelDestTime = Config.GetOrDefault("level-dest-time", 20.0F); FizzleView.ShowLevelName(); ForkCtrl = Spawn(m_FizzleDefination.m_ForkPrefab, transform).GetComponent <ForkCharacterController>(); ForkCharAction = ForkCtrl.GetComponent <ForkCharacterAction>(); coroutineReceiver = Spawn <CoroutineReceiver>(transform, "coroutine"); FirstPersonCtrl = Spawn(m_FizzleDefination.m_PlayerPrefab, transform); FirstPersonCharAction = FirstPersonCtrl.GetComponent <FirstPersonCharacterAction>(); Camera = FirstPersonCtrl.transform.GetComponentInChildren <Camera>(); TimeCtrl.timeControllerEnabled = false; FirstPersonCtrl.controllerEnabled = false; generate = new MapGenerate(m_FizzleDefination.m_GeneratableItemPrefabs, sceneInfos[index].Key, sceneInfos[index].Value); sceneSetting = new FizzleSceneSetting(m_FizzleDefination.m_LightPrefab); item = Spawn(transform, "container").transform; item.localPosition = Vector3.zero; item.localRotation = Quaternion.identity; wall = Spawn(transform, "wall").transform; wall.localPosition = Vector3.zero; wall.localRotation = Quaternion.identity; }
private static IEnumerator InternalLoadLevel(int index) { TimeCtrl.timeControllerEnabled = false; FirstPersonCtrl.controllerEnabled = false; yield return(FizzleView.FadeOut()); FizzleScene scene = GetInstance(); scene.index = index % scene.sceneInfos.Count; scene.LoadLevel(scene.index); scene.Start(); yield return(FizzleView.FadeIn()); TimeCtrl.timeControllerEnabled = true; FirstPersonCtrl.controllerEnabled = true; }