public void BubbleMissed(BubbleState state) { if (++missedBubbles >= MaxBubblesMissed) { LevelState = ELevelState.Failed; } }
private void LevelComplete() { //mWinRepulsive.enabled = true; UI_WinPanel.SetActive(true); levelState = ELevelState.Success; mAudio.clip = musTadaa; mAudio.pitch = 1.0f; mAudio.loop = false; mAudio.Play(); }
public void Reset() { LevelNumber = 0; missedBubbles = 0; levelScore = 0; BubblesInstantiationPeriod = BubblesInstantiationPeriodRange.y; LevelState = ELevelState.Loading; }
// Update is called once per frame void Update() { // count the number of cats inside int howmanyin = 0; bool allIn = true; // check that all repulsives are touching trigger foreach (Repulsive item in Repulsive.SpawnedRepulsives) { if (!item.mCollider.IsTouching(mCollider)) { allIn = false; } else { howmanyin++; } } howManyInText.text = "Cats in: " + howmanyin + "/" + Repulsive.SpawnedRepulsives.Count; if (levelState != ELevelState.Success) { if (allIn) { levelState = ELevelState.AllIn; } else { levelState = ELevelState.Idle; } } switch (levelState) { case ELevelState.Idle: tTimerCurrentHold = Time.time + holdTime; mAudio.pitch = musTempoIdle; currentHoldTimeText.text = "Hold for: " + (tTimerCurrentHold - Time.time).ToString("N1") + " Seconds"; //mAudio.pitch = Mathf.Lerp(mAudio.pitch, musTempoIdle, 0.001f); mRenderer.sprite = spriteIncomplete; break; case ELevelState.AllIn: currentHoldTimeText.text = "Hold for: " + (tTimerCurrentHold - Time.time).ToString("N1") + " Seconds"; // lerp between the two pitches using current hold time mAudio.pitch = Mathf.Lerp(musTempoIdle, musTempoFinish, (holdTime - (tTimerCurrentHold - Time.time)) / holdTime); mRenderer.sprite = spriteComplete; if (Time.time > tTimerCurrentHold) { LevelComplete(); } break; case ELevelState.Success: mRenderer.sprite = spriteComplete; break; default: break; } }
private void LevelComplete() { //mWinRepulsive.enabled = true; UI_WinPanel.SetActive(true); levelState = ELevelState.Success; mAudio.clip = musTadaa; mAudio.pitch = 1.0f; mAudio.loop = false; if (mAudio.enabled) { mAudio.Play(); } string levelName = LevelManager.Instance.levels.levels[LevelManager.Instance.currentLevelID]; float playTime = Time.time - levelStartTime; GameSaveData data = GameData.LoadData(); float bestTime; // has this level got an entry in the save data? // (has the player done this level before) if (data.levelData.ContainsKey(levelName)) { // current best time bestTime = data.levelData[levelName].completionTime; } else { // player has not done this level; best time is really long bestTime = Mathf.Infinity; } if (playTime < bestTime) { yayEffect.Play(); // player Beat preveous high score UI_WinScreenTime.text = "Hi Score!\n" + playTime.ToString("N2"); // Currently dont cate about the highest level completed GameData.SaveLevel(levelName, new LevelSaveData(playTime)); } else { UI_WinScreenTime.text = playTime.ToString("N2"); } // display medals for the time //int numMedals = 0; //if (playTime < targetTime1) //{ // numMedals = 1; //} //if (playTime < targetTime2) //{ // numMedals = 2; //} //if (playTime < targetTime3) //{ // numMedals = 3; //} //medalDisplay.ShowMedals(numMedals); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.F12)) { LevelComplete(); } // determine how many of the cats are in int howManyIn = 0; foreach (Cat cat in cats) { bool wasCatIn = false; // is the cat in a zone foreach (Zone zone in zones) { if (wasCatIn) { continue; } if (cat.catCollider.IsTouching(zone.zoneCollider)) { howManyIn++; wasCatIn = true; } } } UI_Progress.CurrentCatsIn = howManyIn; if (levelState != ELevelState.Success) { if (howManyIn == cats.Length) { levelState = ELevelState.AllIn; } else { levelState = ELevelState.Idle; } } switch (levelState) { case ELevelState.Idle: tTimerCurrentHold = Time.time + holdTime; mAudio.pitch = musTempoIdle; currentHoldTimeText.text = "" + (tTimerCurrentHold - Time.time).ToString("N1") + ""; break; case ELevelState.AllIn: currentHoldTimeText.text = "" + (tTimerCurrentHold - Time.time).ToString("N1") + ""; // lerp between the two pitches using current hold time mAudio.pitch = Mathf.Lerp(musTempoIdle, musTempoFinish, (holdTime - (tTimerCurrentHold - Time.time)) / holdTime); if (Time.time > tTimerCurrentHold) { LevelComplete(); } break; case ELevelState.Success: break; default: break; } }