Пример #1
0
 public void GameWonTrigger()
 {
     if (OnGameWon != null)
     {
         OnGameWon.Invoke();
     }
 }
Пример #2
0
    private bool MovePlayer(Player player, IDiceRoll roll)
    {
        // check if the game is still playable
        if (!this.IsGameActive)
        {
            // TODO: do we throw an invalid move here?
            return(false);
        }

        // get the player's position
        var position = player.Position;
        // see if we can move him
        var newPosition = position.Location + roll.Roll;

        if (newPosition > BoardLength)
        {
            OnInvalidMove?.Invoke(player, roll.Roll, newPosition);
            return(false);
        }

        // and if we can, check for events
        if (newPosition == BoardLength)
        {
            OnGameWon?.Invoke(player);
            IsGameActive = false;
        }

        // update the player's position
        player.Position = new Position(newPosition);
        return(true);
    }
Пример #3
0
 private bool IsGameWon()
 {
     foreach (var cell in _cells)
     {
         if (cell.Status == CellStatus.Unknown ||
             cell.Status == CellStatus.QuestionMark ||
             cell.Status == CellStatus.Flag && cell.HasMine == false)
         {
             return(false);
         }
     }
     OnGameWon?.Invoke();
     return(true);
 }
Пример #4
0
 private void WinningStateCheck()
 {
     if (_isFinished)
     {
         return;
     }
     if (!gameCanFinish)
     {
         return;
     }
     if (EnemyManager.instance.Enemies.Count > 0 || WaveManager.instance.Waves.Count > 0)
     {
         return;
     }
     OnGameWon?.Invoke();
     _isFinished = true;
 }
Пример #5
0
 public void CheckGameState()
 {
     if (GameState != GameState.InProgress || !CheckGameWon())
     {
         return;
     }
     ShowMines();
     if (FieldSettings == GameConstants.BeginnerSettings ||
         FieldSettings == GameConstants.IntermediateSettings ||
         FieldSettings == GameConstants.ExpertSettings)
     {
         MoneyWon = (int)Math.Round(
             (_mineCells.Length + _mineCells.Length * 10 * ((double)_numberOfMines / 10) / TimeElapsed) *
             ((double)_numberOfMines / 10));
     }
     OnGameWon?.Invoke(this, EventArgs.Empty);
 }
Пример #6
0
 private void FixedUpdate()
 {
     if (currentTemp < winTemp)
     {
         if (OnGameWon != null)
         {
             OnGameWon.Invoke();
         }
     }
     if (currentTemp > maxTemp)
     {
         if (OnGameLost != null)
         {
             OnGameLost.Invoke();
         }
     }
 }
Пример #7
0
 public void RaiseOnGameWon()
 {
     OnGameWon?.Invoke();
     RaiseOnGameEnded();
 }