示例#1
0
 // Use this for initialization
 void Start()
 {
     MyTeam = 'b';
     //インスタンス化
     _selector       = GetComponent <Selector>();
     _tileData       = GetComponent <Tile_data>();
     _turnController = GetComponent <Turn_Controller>();
     StartCoroutine(Loop());
 }
示例#2
0
        //Issues orders and referees the game
        //Steps:
        /* -Preparation-
         * Create players - main_controller
         * Create units - unit_manager/action_manager/move_manager
         * Players assigned units   - main_controller
         * Sort units by initiative - turn_controller
         * -Gameplay-
         * Players deploy units - main_controller/input/graphics
         * -Control Phase-
         * Turn control loop start: highest initiatve unit goes first   - turn_controller
         * Calculate and attach action overlay - overlay_manager/main_controller
         * Calculate move overlay - overlay_manager/main_controller
         * Player gains control over unit   - main_controller/input/graphics
         * Unit chooses an action (movement, activation, attack)    - main_controller/input/graphics
         * -Action Phase-
         * Unit takes action/Affect Units take counteraction    - action_controller
         * Action consequences are calculated   - action_controller
         * Player ends turn or turn ends automatically upon unit exhaustion
         * Turn control end: check units left/main objectives
         * -Endgame-
         * Last unit falls for a player/objectives achieved by a player
         * Rewards generated, experience calculated
         */
        void initiationTest()
        {
            //Create two players  - TODO: use a builder for this?
            Player player1 = new Player("Player 1");
            Player player2 = new Player("Player 2");

            //Add players to array
            player_list = new Player[2]{player1, player2};

            //Create two units
            Unit unit1 = Unit_Builder.createTestUnit();
            Unit unit2 = Unit_Builder.createTestUnit();

            //Add units to players - TODO: use a builder for this?
            player1.unit_list.Add(unit1);
            unit1.owner = player1;
            player2.unit_list.Add(unit2);
            unit2.owner = player2;

            //Add units to turn list
            List<Unit> templist = new List<Unit>();
            templist.Add(unit1);
            templist.Add(unit2);
            turn_controller = new Turn_Controller(templist);
            templist.Clear();

            //Turn loop start
            bool game_over = false;
            while (!game_over)
            {
                Player current_player = turn_controller.currentPlayer;

                //Hand over turn to player

                //Calculate overlays for each unit

                //Display: board, units, menus

                //Input loop start

                //Wait for player input

                //Process input - update display, update board, update overlays

                //End unit action, back to loop

                //End unit turn, end input loop

                //End player turn, back to loop

                //End game, end turn loop

            }

            //Display winner
        }
    // Update is called once per frame
    void Update()
    {
        if(turn_controller == null) {
            turn_controller = (Turn_Controller) Turn_Controller.instance;
        }
        try {
            text.text = "";
            if(turn_controller.server_players != null && turn_controller.server_players.players != null && turn_controller.server_players.players.Count < 1)
                return;
            foreach(Client_Model player in turn_controller.server_players.players.ToArray()) {
                text.text += " ";
                text.text += player.id;
                text.text += " ";
                text.text += player.name;
                text.text += " ";
                text.text += player.team;
                text.text += " ";
                text.text += player.ip;
                text.text += " ";
                text.text += player.ready;
                if(turn_controller.server_players.MyPlayer != null && turn_controller.server_players.MyPlayer.id == player.id) {
                    text.text += " ";
                    text.text += "is me";
                }
                text.text += "\n";
            }
            text.text += "Active team " + turn_controller.server_players.active_team;
            text.text += " ";
            text.text += "Active phase " + turn_controller.server_players.active_phase;
            text.text += " ";
            //			foreach(string key in Networking.PrimarySocket.event){
            //				text.text += key;
            //				text.text += " ";
            //			}
            //			text.text += "Number of server keys " + Networking_Manager.instance.socket.Keys.Count;
        } catch(System.Exception ex) {

        }
    }
 void Awake()
 {
     instance = this;
 }
 // Use this for initialization
 void Start()
 {
     turn_controller = (Turn_Controller) Turn_Controller.instance;
     text = GetComponent<Text>();
 }