Exemplo n.º 1
0
    /// <summary>
    /// This method detect when a n other gameobject enter in the collision area.
    /// </summary>
    /// <param name="other">Collided GameObject</param>
    void OnTriggerEnter(Collider other)
    {
        GameObject collidedObj = other.gameObject;

        if (collidedObj.tag == "TicTacToeCell")
        {
            if (!grid)
            {
                grid = GameObject.FindGameObjectWithTag("TicTacToe").GetComponent <TicTacToeCtrl>();
            }
            else
            {
                if (grid.IsGameOver())
                {
                    CanDraw = false;
                    return;
                }
            }
            CanDraw = collidedObj.GetComponent <TicTacToeCell>().CellValue == 0;
            if (CanDraw && PlayerTurn)
            {
                LongControllerVibration(500, 1);
            }
        }
    }
Exemplo n.º 2
0
    private void MenuClicked(object sender, ClickedEventArgs e)
    {
        if (AreBothMenuButtonPressed())
        {
            foreach (Transform child in lineA.transform)
            {
                GameObject.Destroy(child.gameObject);
            }
            foreach (Transform child in lineB.transform)
            {
                GameObject.Destroy(child.gameObject);
            }
            GameObject wLine = GameObject.FindGameObjectWithTag("TicTacToeWinnerLine");
            if (wLine)
            {
                GameObject.Destroy(wLine);
            }
            GameObject ticTacToeGrid = GameObject.FindGameObjectWithTag("TicTacToe");
            if (ticTacToeGrid)
            {
                TicTacToeCtrl   controller = ticTacToeGrid.GetComponent <TicTacToeCtrl>();
                TicTacToeCell[] cells      = controller.cells;
                foreach (TicTacToeCell cell in cells)
                {
                    cell.CellValue = 0;
                }
                controller.gameOver = false;
            }
            playerAController.GetComponent <AllowToDraw>().HideArrow();
            playerBController.GetComponent <AllowToDraw>().HideArrow();

            playerAController.GetComponent <AllowToDraw>().PlayerTurn = true;
            playerBController.GetComponent <AllowToDraw>().PlayerTurn = true;
        }
    }
Exemplo n.º 3
0
 public void SetTicTacToeCtrl(TicTacToeCtrl ctrl)
 {
     TicTacToeController            = ctrl;
     TicTacToeController.PlayerWin += TicTacToeController_PlayerWin;
 }