Ejemplo n.º 1
0
    void selectTarget()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hitInfo = new RaycastHit();
            bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);
            if (hit)
            {
                if (hitInfo.transform.gameObject.tag == "Column")
                {
                    Column from  = columns[getColumnOfChecker(checkerselected)].GetComponent <Column>();
                    Column to    = hitInfo.transform.GetComponent <Column>();
                    Column onHit = columns[PlayerB.turn ? 25 : 24].GetComponent <Column>();
                    bool   moved = move(from, to, onHit);

                    if (moved)
                    {
                        movesTaken++;
                        checkerselected = null;
                    }
                    //check if with the current move taken the player won
                    if (PlayerB.turn && PlayerB.won)
                    {
                        gameStatusText.text = winMsg;
                        Invoke("GoToScene", 5);
                    }
                    else if (PlayerA.turn && PlayerA.won)
                    {
                        gameStatusText.text = loseMsg;
                        Invoke("GoToScene", 5);
                    }

                    if (movesTaken == Moves)
                    {
                        setUnavailableToMove();
                        state = GameState.Finalizing;
                    }
                    else
                    {
                        setUnavailableToMove();
                        SetAvailableToMove();
                        state = GameState.SelectingChecker;
                    }
                }
            }

            MaterialUtilities.DisableColumnColliders(ref collidersSet, ref columns);
            MaterialUtilities.DisableMeshRenderers(ref columns);
        }
    }
Ejemplo n.º 2
0
    IEnumerator selectTargetAfterSeconds(float x)
    {
        yield return(new WaitForSeconds(x));

        if (checkerselected != null)
        {
            Column from  = columns[getColumnOfChecker(checkerselected)].GetComponent <Column>();
            Column to    = AI.getTargetColumn(ref columns);
            Column onHit = columns[PlayerB.turn ? 25 : 24].GetComponent <Column>();
            bool   moved = move(from, to, onHit);

            if (moved)
            {
                checkerselected = null;
                movesTaken++;
            }
            if (PlayerA.won)
            {
                gameStatusText.text = loseMsg;
                Invoke("GoToScene", 5);
            }
            if (movesTaken == Moves)
            {
                setUnavailableToMove();
                state = GameState.Finalizing;
            }
            else
            {
                setUnavailableToMove();
                SetAvailableToMove();
                state = GameState.SelectingChecker;
            }
            MaterialUtilities.DisableColumnColliders(ref collidersSet, ref columns);
            MaterialUtilities.DisableMeshRenderers(ref columns);
        }
    }