Example #1
0
 /// <summary>
 /// Used to clear everyting before the game start
 /// </summary>
 public void Init()
 {
     MatchStatsManager.Instance.ResetStats();
     m_matchHasEnded = false;
     DestroyAllUnits();
     PlayerMoney   = 40;
     OpponentMoney = 40;
     foreach (Transform t in m_PlayerSpawnPoints)
     {
         t.gameObject.SetActive(true);
     }
     foreach (Transform t in m_OpponentSpawnPoints)
     {
         t.gameObject.SetActive(true);
     }
     foreach (UnitController uc in m_EndObjects)
     {
         uc.gameObject.SetActive(true);
         uc.life = 50;
     }
     GameStatus = MatchGameStatus.inProgress;
     InitLines();
     m_opponent.Init();
     m_player.Init();
     StartCoroutine(IncrementMoney());
 }
Example #2
0
    /// <summary>
    /// Check if two lines or more are over
    /// if true the game end
    /// </summary>
    public void CheckForGameEnd()
    {
        if (MatchLines.FindAll(x => x.Status != MatchLineModel.LineState.inProgress).Count >= 2)
        {
            int playerLines   = MatchLines.FindAll(x => x.Status == MatchLineModel.LineState.playerWon).Count;
            int opponentLines = MatchLines.FindAll(x => x.Status == MatchLineModel.LineState.OpponentWon).Count;

            this.GameStatus = playerLines > opponentLines ? MatchGameStatus.playerWon : MatchGameStatus.opponentWon;

            foreach (MatchLineModel m in MatchLines)
            {
                m.Status = MatchLineModel.LineState.playerWon;
            }
            DisplayMatchEnd();
        }
    }