Exemplo n.º 1
0
    public void FieldButtonClick(int position)
    {
        // return if position is already taken
        if (field[position] != 2)
        {
            return;
        }

        // make move
        MakeMove(player, position);

        // check end game
        CheckEndGame();

        // return if game ended
        if (!gameActive)
        {
            return;
        }

        // make AI move
        MakeMove(ai, TicTacToeAI.AImakeMove(field, ai, GameControl.aiLevel));

        // check end game
        CheckEndGame();
    }
Exemplo n.º 2
0
    private void LoadGameInit()
    {
        // decide who plays first
        switch (GameControl.lastGameResult)
        {
        case "draw": player = GameControl.lastGamePlayer == 0 ? 1 : 0; break;

        case "win": player = 0; break;

        case "loose": player = 1; break;
        }
        ai = player == 0 ? 1 : 0;

        // if AI first, let him do a move
        if (ai == 0)
        {
            MakeMove(ai, TicTacToeAI.AImakeMove(field, ai, GameControl.aiLevel));
        }

        // make texts show current data
        difficultyText.GetComponent <Text>().text = "Уровень ИИ: " + GameControl.GetAiLevelName();
        winsText.GetComponent <Text>().text       = "Победы: " + GameControl.wins.ToString();
        loosesText.GetComponent <Text>().text     = "Поражения: " + GameControl.looses.ToString();
        drawsText.GetComponent <Text>().text      = "Ничьи: " + GameControl.draws.ToString();
    }