예제 #1
0
파일: AI.cs 프로젝트: dragonscry/testTicTac
    void AIChoice()
    {
        if (win.Count < 9)
        {
            int arg = Random.Range(1, 9);
            if (win.smth[arg] == "")
            {
                win.array[arg].GetComponent <OnClick>().spr.sprite = o;
                win.array[arg].GetComponent <OnClick>().choice     = "o";
                BoxCollider2D col = win.array[arg].GetComponent <BoxCollider2D>();
                col.enabled = !col.enabled;
                gameController.ChangeTurn();
                win.Obj();
                win.wining();
            }
            else
            {
                AIChoice();
            }
        }

        else if (win.Count == 9)
        {
            return;
        }
    }
예제 #2
0
    private void OnMouseDown()
    {
        playerTurn = gameController.Turn;
        win.buttonActive(false);

        if (playerTurn == 1)
        {
            spr.sprite = x;
            choice     = "x";
        }
        else if (playerTurn == 0)
        {
            spr.sprite = o;
            choice     = "o";
        }
        BoxCollider2D col = GetComponent <BoxCollider2D>();

        col.enabled = !col.enabled;
        gameController.ChangeTurn();
        win.Obj();
        win.wining();
        aiScript.aiInGame();
    }