Exemplo n.º 1
0
        public void Update(ServerGame game, Lobby lobby)
        {
            foreach (BigShip ship in aiBigShips.ToArray())
            {
                if (ship.IsDestroyed)
                {
                    aiBigShips.Remove(ship);
                }
            }

            while (game.GameObjectCollection.GetMasterList().GetList <SmallShip>().Count < 20)
            {
                SmallShip.SmallShipFactory(game);
            }

            while (game.GameObjectCollection.GetMasterList().GetList <BigShip>().Count < 5)
            {
                aiBigShips.Add(BigShip.BigShipFactory(game));
            }

            ControllerFocusObject controllerFocusObject = game.GameObjectCollection.GetMasterList().GetList <ControllerFocusObject>()[0];

            foreach (Player player in lobby.Clients)
            {
                if (controllerFocusObject.GetFocus(player.Id) == null || controllerFocusObject.GetFocus(player.Id).IsDestroyed)
                {
                    BigShip playerShip = BigShip.BigShipFactory(game, player);
                    CircleBigShips(playerShip.Position);
                }
            }
        }
Exemplo n.º 2
0
        public static void SmallShipFactory(ServerGame game, Player player)
        {
            SmallShip ship = new SmallShip(game);

            SmallShip.ServerInitialize(ship, game.WorldSize / 2, new Vector2(0, 0), player.Controller, player.Controller);
            ControllerFocusObject controllerFocusObject = game.GameObjectCollection.GetMasterList().GetList <ControllerFocusObject>()[0];

            controllerFocusObject.SetFocus(player, ship);
            game.GameObjectCollection.Add(ship);
        }
Exemplo n.º 3
0
        public Ship GetLocalPlayerFocus()
        {
            Ship focus = null;
            List <ControllerFocusObject> controllerFocusList = this.GameObjectCollection.GetMasterList().GetList <ControllerFocusObject>();

            if (controllerFocusList.Count > 0)
            {
                ControllerFocusObject controllerFocus = controllerFocusList[0];
                focus = controllerFocus.GetFocus(serverConnection.Id);
            }
            return(focus);
        }
Exemplo n.º 4
0
        public ServerLogic(ServerGame game, Lobby lobby, Vector2 worldSize)
        {
            ControllerFocusObject controllerFocusObject = new ControllerFocusObject(game);

            ControllerFocusObject.ServerInitialize(controllerFocusObject, lobby.Clients.Count);
            game.GameObjectCollection.Add(controllerFocusObject);

            for (int j = 0; j < 4; j++)
            {
                Tower.TowerFactory(game);
            }
        }