void Awake() { instance = this; GameObject newGameObj = GameObject.FindGameObjectWithTag("NewGameMessage"); GameObject completedLevelObj = GameObject.FindGameObjectWithTag("CompletedLevelMessage"); if (newGameObj != null) { SeedLevelGenerator(); Destroy(newGameObj); } if (completedLevelObj != null) { SeedLevelGenerator(); CompletedLevelMessage message = completedLevelObj.GetComponent <CompletedLevelMessage>(); completedCaves = message.completedCaves; Destroy(completedLevelObj); } }
IEnumerator AnimateCompleteLevel() { float t = 0; float lastTime = playerWinScaling.keys[playerWinScaling.length - 1].time; Vector3 startPos = player.transform.position; Vector3 startScale = player.transform.localScale; while (t < lastTime) { float s = playerWinScaling.Evaluate(t); player.localScale = startScale * s; player.transform.position = Vector3.Lerp(startPos, goal.transform.position, t); t += Time.deltaTime; yield return(0); } player.gameObject.SetActive(false); GameObject obj = new GameObject("CompletedLevelMessage"); obj.tag = "CompletedLevelMessage"; DontDestroyOnLoad(obj); CompletedLevelMessage message = obj.AddComponent <CompletedLevelMessage>(); message.completedCaves = this.completedCaves + 1; Application.LoadLevel(Application.loadedLevelName); }