Exemple #1
0
    void update_vsIA()
    {
        //http://answers.unity3d.com/questions/357033/unity3d-and-c-coroutines-vs-threading.html
        //Debug.Log("!!" + gameboard.board[28]);
        switch (gameState)
        {
        case GAME_STATE.w82start:
            break;

        case GAME_STATE.startIA:
            //start IA couroutine
            iaThread           = new AI_thread(ia);
            iaThread.gameboard = gameboard.Clone();
            iaThread.Start();
            StartCoroutine("IA_COUROUTINE");
            break;

        case GAME_STATE.IAw8:
            break;

        case GAME_STATE.IAplacepiece:
            IA_place_piece();
            break;

        case GAME_STATE.IArotatequare:
            if (ApplyRotation())
            {
                if (gameboard.game_ended(out winning_player))
                {
                    gameState = GAME_STATE.ended;
                }
                else
                {
                    gameState = GAME_STATE.playerselecthole;
                };
            }
            break;

        case GAME_STATE.playerselecthole:
            PlayerPlacingPiece();
            break;

        case GAME_STATE.playerselectrotation:
            if (ApplyRotation())
            {
                HideRotationGUI();
                if (gameboard.game_ended(out winning_player))
                {
                    gameState = GAME_STATE.ended;
                }
                else
                {
                    gameState = GAME_STATE.startIA;
                }
            }
            break;

        case GAME_STATE.ended:
            displayEndGame();
            this.enabled = false;
            break;

        default:
            break;
        }
    }