public void CheckGameWon() { if (_current == _finish) { GameWon?.Invoke(_count); } }
public void Reveal(TileProperty tile) { if (tile.IsFlagged || tile.IsRevealed || GameOver) { return; } tile.IsRevealed = true; if (tile.IsBomb) { OnGameLose(); return; } RevealedSuccess++; if (tile.SurroundingCount == 0) { RevealAllSurrounding(tile); } if (RevealedSuccess == RevealToWin) { GameOver = true; GameWon.Invoke(this, EventArgs.Empty); } }
private void CheckForVictory() { if (IsGameRunning && NumRevealedCells == cells.Count - model.NumBombs) { IsGameRunning = false; GameWon.Invoke(); } }
void VictorySequence() { GameWon.Invoke(); musicPlayer.clip = victoryMusic; musicPlayer.Play(); // Show the victory text victoryText.enabled = true; Application.Quit(); //FadeIntoTitleScreen(); }
private void OnZombiDied(Zombi zombi) { zombi.Died -= OnZombiDied; _waveSize--; if (_waveSize == 0 && _currentWaveIndex >= _waves.Count) { GameWon?.Invoke(); } else if (_waveSize == 0) { WaveEnded?.Invoke(); } }
internal void IncreaseScore() { _score++; ScoreChanged?.Invoke(_score); if (_score == _scoreForVictory - 1) { GameWining?.Invoke(); } if (_score == _scoreForVictory) { GameWon?.Invoke(); StartCoroutine(DelayedColliderReactivation()); } }
/// <summary> /// Controls if the player wins or if the quota text will flash red /// </summary> private void OnGoalEntered() { if (quota <= 0) { GameWon?.Invoke(); quotaText.text = "You Win! Press here to go to the main menu!"; button.enabled = true; quotaImage.enabled = true; } else { if (!isAlreadyFlashing) { StartCoroutine(FlashRedCoroutine()); } } }
protected void OnWin() { if (_gameOver) { return; } GameController.Instance.TimeElapsing = true; _gameOver = true; Debug.Log("Gagné"); Close(); if (OnWinEvent != null) { OnWinEvent(); } GameWon?.Invoke(); //FindObjectOfType<GameMusicInit> ().PlayGameMusic (); }
public bool EnterNumber(int pos, byte num) { if (Valid(pos, num)) { currentBoard[pos] = num; bool finished = true; for (int i = 0; i < 81; i++) { if (currentBoard[i] == 0) { finished = false; break; } } if (finished) { GameWon?.Invoke(this, new GameWonEventArgs(currentBoard, dif)); } return(true); } return(false); }
public bool Move(int row, int col, string movedPiece) { if (PlayablePieces.Contains(movedPiece) && GameBoard[row, col] == "[]") { Debug.Log("Setting move in model - " + movedPiece); GameBoard[row, col] = movedPiece; PlayablePieces.Remove(movedPiece); GameOver = HasWon(row, col); CheckTieGame(); if (GameOver) { Debug.Log(Environment.NewLine + "GAME OVER" + Environment.NewLine); GameWon?.Invoke(); } return(true); } else { return(false); } }
private void OnGameWon(EventData eventData) { GameWon?.Invoke(eventData); }
private void HandleMovingSquareStateChangedEvent(ISquare sq) { var ms = sq as MovingSquare; if (ms.IsMoving == true) { return; } var dir = new MoveDirection(ms.Direction); var dest = ms.Destination; var lastIndex = _matrixField.GetLastIndexInDirection(ms.Direction); if (dest == lastIndex) { var side = ms.Direction switch { Direction.Down => Side.Bottom, Direction.Up => Side.Top, Direction.Left => Side.Left, Direction.Right => Side.Right, _ => throw new InvalidEnumArgumentException($"{ms.Direction} is invalid argument") }; var lineIdx = dir.IsHorzOrient() ? ms.Y : ms.X; _sideFields[side].Push(lineIdx, ms.Color); } else { (uint x, uint y) = dir.IsHorzOrient() ? (dest, ms.Y) : (ms.X, dest); _matrixField.SetSquareState(x, y, ms.Color, ms.Direction); var combinations = _matrixField.GetSquareCombinations(); foreach (var combination in combinations) { _score.Add(combination.Count()); CombinationDestroyed?.Invoke(combination); foreach (var item in combination) { _matrixField.ResetSquareState(item.X, item.Y); } } } var(square, destination) = _matrixField.FindSquareWithDestinationToMove(); if (destination != -1) { _movingSquare.Start((square.X, square.Y), square.Color, square.State.Direction.Value, (uint)destination); _matrixField.ResetSquareState(square.X, square.Y); } if (!_movingSquare.IsMoving) { if (!_matrixField.HasActiveSquares()) { _score.AddWinScore(); _matrixField.Reset(); GameWon?.Invoke(); //ClearStateHistory(); } else if (_matrixField.IsMoveDeadlock()) { GameOver?.Invoke(); } } }
public static void WinGame() => GameWon?.Invoke();
protected virtual void OnGameWon() { GameWon?.Invoke(this, EventArgs.Empty); }
public void OnGameWin(object sender, EventArgs e) { GameWon?.Invoke(sender, e); }
private IEnumerator EndGame(int enemySelection) { Selections selection = (Selections)enemySelection; bool gameWon = false; yield return(new WaitForSeconds(2)); if (PlayerSelection == selection) { DrawTextUI.SetActive(true); WinTextUI.SetActive(false); LoseTextUI.SetActive(false); } else if (PlayerSelection == Selections.Rock && selection == Selections.Scissors) { gameWon = true; DrawTextUI.SetActive(false); WinTextUI.SetActive(true); LoseTextUI.SetActive(false); } else if (PlayerSelection == Selections.Paper && selection == Selections.Rock) { gameWon = true; DrawTextUI.SetActive(false); WinTextUI.SetActive(true); LoseTextUI.SetActive(false); } else if (PlayerSelection == Selections.Scissors && selection == Selections.Paper) { gameWon = true; DrawTextUI.SetActive(false); WinTextUI.SetActive(true); LoseTextUI.SetActive(false); } else if (selection == Selections.Rock && PlayerSelection == Selections.Scissors) { DrawTextUI.SetActive(false); WinTextUI.SetActive(false); LoseTextUI.SetActive(true); } else if (selection == Selections.Paper && PlayerSelection == Selections.Rock) { DrawTextUI.SetActive(false); WinTextUI.SetActive(false); LoseTextUI.SetActive(true); } else if (selection == Selections.Scissors && PlayerSelection == Selections.Paper) { DrawTextUI.SetActive(false); WinTextUI.SetActive(false); LoseTextUI.SetActive(true); } if (gameWon && gameMode == Gamemodes.Multi) { GameWon?.Invoke(); } if (gameMode == Gamemodes.Multi) { RetryButton.SetActive(false); } else { RetryButton.SetActive(true); } if (DrawTextUI.activeInHierarchy) { EndGamePanel.SetActive(false); EnableDisableButtons(true); if (gameMode == Gamemodes.Single) { SceneManager.LoadScene(1); } } else { EndGamePanel.SetActive(true); } }
private void DeclareWinner(TicTacToePlayerTurn whoWon) { Winner = whoWon == TicTacToePlayerTurn.X ? TicTacToeWinner.X : TicTacToeWinner.O; GameWon?.Invoke(this, new TicTacToeWinEventArgs(Winner)); }
private void DeclareStalemate() { Winner = TicTacToeWinner.Stalemate; GameWon?.Invoke(this, new TicTacToeWinEventArgs(TicTacToeWinner.Stalemate)); }