Ejemplo n.º 1
0
        /// <summary>
        /// Decide what happens when a cell is selected
        /// </summary>
        /// <param name="a_cellIndex">Index of selected cell.</param>
        void HandleSelection(int a_cellIndex)
        {
            m_audioSource.PlayOneShot(m_selectSound);
            m_player2.Remove(a_cellIndex);

            m_cells[a_cellIndex].Select(m_currentPlayer.m_overlaySprite);
            m_moveCount++;
            m_cells[a_cellIndex].Status = m_currentPlayer.m_statusToSet;
            if (CheckCompletion())
            {
                m_gameOver = true;
                if (m_currentPlayer.IsHuman())
                {
                    m_audioSource.PlayOneShot(m_winSound);
                }
                else
                {
                    m_audioSource.PlayOneShot(m_loseSound);
                }
                FlowController.SetHudText(m_currentPlayer.m_playerName + " Wins!!");
                FlowController.OnGameOver();
                return;
            }
            if (m_moveCount >= 9)
            {
                m_audioSource.PlayOneShot(m_drawSound);
                m_gameOver = true;
                FlowController.SetHudText("Draw!!");
                FlowController.OnGameOver();
                return;
            }
            SetNextPlayer();
        }
Ejemplo n.º 2
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     OnMenuPressed();
 }
Ejemplo n.º 3
0
        public void StartNewGame()
        {
            m_player1.m_playerName = FlowController.GetPlayerName();
            m_player1.Reset();

            m_player2.m_playerName = FlowController.GetAIName();
            m_player2.Reset();
            SetNextPlayer();
            m_gameOver  = false;
            m_moveCount = 0;
            ResetSelection();
        }
Ejemplo n.º 4
0
 // Simple switch to next player
 void SetNextPlayer()
 {
     if (m_currentPlayer == m_player1)
     {
         m_currentPlayer = m_player2;
     }
     else
     {
         m_currentPlayer = m_player1;
     }
     FlowController.SetTurnText(m_currentPlayer.m_playerName);
     if (!m_currentPlayer.IsHuman())
     {
         StartCoroutine(GetAIInputCor());
     }
 }