Example #1
0
        public World(int tick, double width, double height, Player[] players, Obstacle[] obstacles, Tank[] tanks, Shell[] shells, Bonus[] bonuses)
        {
            this.tick = tick;
            this.width = width;
            this.height = height;

            this.players = new Player[players.Length];
            Array.Copy(players, this.players, players.Length);

            this.obstacles = new Obstacle[obstacles.Length];
            Array.Copy(obstacles, this.obstacles, obstacles.Length);

            this.tanks = new Tank[tanks.Length];
            Array.Copy(tanks, this.tanks, tanks.Length);

            this.shells = new Shell[shells.Length];
            Array.Copy(shells, this.shells, shells.Length);

            this.bonuses = new Bonus[bonuses.Length];
            Array.Copy(bonuses, this.bonuses, bonuses.Length);
        }
        private Player[] ReadPlayers()
        {
            int playerCount = ReadInt();
            if (playerCount < 0)
            {
                return null;
            }

            Player[] players = new Player[playerCount];

            for (int playerIndex = 0; playerIndex < playerCount; ++playerIndex)
            {
                if (ReadBoolean())
                {
                    players[playerIndex] = new Player(ReadString(), ReadInt(), ReadBoolean());
                }
            }

            return players;
        }