// Update is called once per frame void Update() { if (newlyEnabled) { newlyEnabled = false; // Initialize camera. UpdateCameraTransform(mainCameraTransform); // Initialize roads. for (int i = 0; i < maxExistRoad; i++) { GameObject newRoad = roadPrefabArray[Random.Range(0, roadPrefabArray.Length)]; // Randomly choose a prefab newRoad = Instantiate(newRoad, new Vector3(0, 0, (i * roadDistance)), this.transform.rotation); int isRotate = Random.value > 0.5 ? 1 : 0; newRoad.transform.Rotate(0, isRotate * 180, 0); curSky = newRoad.GetComponent <ObstacleInitializer>().sky = GetNewSky(); roadQueue.Enqueue(newRoad); } // Initialize background music. SetBackgroundMusicPath(backgroundMusicPath[(int)MySky.Morning]); // Initialize MoveController. moveController = character.GetComponent <MoveController>(); moveController.runStatus = GetRunStatus(); moveController.SetLastTouchedRoad(null); moveController.modeSpeed = GetModeSpeed(); moveController.SetIsFailed(false); moveController.enabled = true; // Initialize Sky. curSky = (int)MySky.Morning; } if (moveController.GetNeedNewSky()) { moveController.SetNeedNewSky(false); // Skybox. int newSky = moveController.GetCurTouchedSky(); RenderSettings.skybox = skyBox[newSky]; DynamicGI.UpdateEnvironment(); // Particle system. if (newSky == (int)RunController.MySky.Rain) { rainSky.SetActive(true); snowSky.SetActive(false); } else if (newSky == (int)RunController.MySky.Snow) { rainSky.SetActive(false); snowSky.SetActive(true); } else { snowSky.SetActive(false); rainSky.SetActive(false); } // Background Music. SetBackgroundMusicPath(backgroundMusicPath[newSky]); } UpdateBackgroundMusic(); if (moveController.GetNeedNewRoad()) { moveController.SetNeedNewRoad(false); CreateNewRoad(); } if (moveController.GetIsFailed()) { SetGameState((int)GameManager.GameState.Stop); } }