示例#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
 void Start()
 {
     OnTitanSpawned += EventManager_OnTitanSpawned;
     OnTitanKilled  += EventManager_OnTitanKilled;
     OnRestart      += EventManager_OnRestart;
     OnUpdate       += EventManager_OnUpdate;
     OnGameWon      += EventManager_OnGameWon;
     OnGameLost     += EventManager_OnGameLost;
     OnPlayerKilled += EventManager_OnPlayerKilled;
 }
示例#4
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);
 }
示例#5
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;
 }
示例#6
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);
 }
示例#7
0
文件: Level.cs 项目: TheCoCe/COOL
 private void FixedUpdate()
 {
     if (currentTemp < winTemp)
     {
         if (OnGameWon != null)
         {
             OnGameWon.Invoke();
         }
     }
     if (currentTemp > maxTemp)
     {
         if (OnGameLost != null)
         {
             OnGameLost.Invoke();
         }
     }
 }
示例#8
0
 public void RaiseOnGameWon()
 {
     OnGameWon?.Invoke();
     RaiseOnGameEnded();
 }