Example #1
0
    IEnumerator GameLoop()
    {
        gsm.BeginGame();

        ui_manager.ShowMulliganScreen(true);
        while (!Input.GetKeyDown(KeyCode.Escape))
        {
            yield return(null);
        }
        ui_manager.HideTurnScreen();

        yield return(gsm.Mulligan(players[0], 3));

        ui_manager.ShowMulliganScreen(false);
        while (!Input.GetKeyDown(KeyCode.Escape))
        {
            yield return(null);
        }
        Flip();
        ui_manager.HideTurnScreen();

        yield return(gsm.Mulligan(players[1], 4));

        ui_manager.ShowTurnScreen(true);
        while (!Input.GetKeyDown(KeyCode.Escape))
        {
            yield return(null);
        }
        Flip();
        ui_manager.HideTurnScreen();

        while (!game_over)
        {
            active_player = _players[current_position];
            active_player.GetComponent <Renderer>().material.color = Color.blue;
            gsm.BeginTurn(active_player);
            yield return(null);

            ui_manager.HideTurnScreen();
            active_player.command_manager.Clear();
            while (!active_player.command_manager.end_turn || !gsm.can_process_command)
            {
                if (active_player.command_manager.commands.Count > 0 && gsm.can_process_command)
                {
                    Command command = active_player.command_manager.PopCommand();
                    if (command.ValidateCommand())
                    {
                        command.ResolveCommand();
                    }
                    else
                    {
                        command.OnFail();
                    }
                }
                yield return(null);
            }
            yield return(null);

            active_player.GetComponent <Renderer>().material.color = Color.red;
            gsm.EndTurn(active_player);
            current_position = (current_position + 1) % _players.Count;
            ui_manager.ShowTurnScreen(current_position == 0);
            Flip();
            while (!Input.GetKeyDown(KeyCode.Escape))
            {
                yield return(null);
            }
            yield return(null);
        }
    }