private void Check() { if (destroyedButtons == buttonList.Count) { OnPlayerSuccess?.Invoke(); } }
private void CountDeadEnemies() { stateOfTheGame.RemainingEnemies--; stateOfTheGame.DeadEnemyCount++; OnRemainingEnemiesUpdate?.Invoke(stateOfTheGame.RemainingEnemies); if (stateOfTheGame.RemainingEnemies == 0 && stateOfTheGame.CurrentState == GameState.State.OnPlay) { if ((int)stateOfTheGame.CurrentScene == 2) { Time.timeScale = 0f; stateOfTheGame.CurrentState = GameState.State.Success; OnPlayerSuccess?.Invoke(stateOfTheGame.DeadEnemyCount); } else { int currentSceneIndex = (int)stateOfTheGame.CurrentScene; Destroy(GameObject.Find("GameBox").gameObject); Destroy(GameObject.Find("Main Camera").gameObject); SceneManager.LoadScene(currentSceneIndex + 1, LoadSceneMode.Additive); stateOfTheGame.CurrentScene++; stateOfTheGame.RemainingEnemies = 4; OnLoadingNextLevel?.Invoke(stateOfTheGame.RemainingEnemies, (int)stateOfTheGame.CurrentScene + 1); } } }
/// <summary> /// Check if the attempt corresponds to the captcha /// </summary> /// <param name="attempt"></param> private void Check(string attempt) { // Remove spaces attempt = attempt.Replace(" ", ""); if (attempt == captcha) { OnPlayerSuccess?.Invoke(); PlayerTextInput.OnTextInput -= Check; } else { captcha = GenerateCaptcha(); captchaText.text = captcha; } }
/// <summary> /// Checks if the player is sorting the number correctly /// </summary> /// <param name="s"></param> private void CheckOrder(string s) { if (char.Parse(s) == alphabeticOrder[index]) { index++; // Successfully finishes the mini challenge if (index >= 6) { OnPlayerSuccess?.Invoke(); ButtonBehaviour.OnButtonPressed -= CheckOrder; index = 0; } } else { index = 0; OnPlayerMiss?.Invoke(); } }
/// <summary> /// Checks if the player is sorting the number correctly /// </summary> /// <param name="num"></param> private void CheckOrder(string num) { if (int.Parse(num) == numArray[index]) { index++; // Successfully finishes the mini challenge if (index >= 10) { OnPlayerSuccess?.Invoke(); ButtonBehaviour.OnButtonPressed -= CheckOrder; index = 0; } } else { index = 0; OnPlayerMiss?.Invoke(); } }