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);
                }
            }
        }
        //TODO: there needs to be a better way to set up game-mode-ish parameters
        public ServerGame(Lobby lobby)
            : base()
        {
            this.lobby = lobby;

            lobby.BroadcastTCP(new SetWorldSize(worldSize));
            this.SetWorldSize(worldSize);
        }
        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);
            }
        }
 //sends an update message
 public void SendUpdateMessage(Lobby lobby, GameTime gameTime)
 {
     float secondsElapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
     this.secondsUntilUpdateMessage = this.secondsUntilUpdateMessage - secondsElapsed;
     if (this.IsDestroyed || this.secondsUntilUpdateMessage <= 0)
     {
         GameObjectUpdate message = new GameObjectUpdate(gameTime, this);
         lobby.BroadcastUDP(message);
         this.secondsUntilUpdateMessage = this.SecondsBetweenUpdateMessage;
     }
 }
Exemplo n.º 5
0
 public static void ServerMain()
 {
     Lobby lobby = new Lobby();
     lobby.Run();
 }
        public void ServerUpdate(Lobby lobby, GameTime gameTime)
        {
            float secondsElapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
            foreach (GameObject obj in this.listManager.GetList<GameObject>())
            {
                obj.ServerUpdate(secondsElapsed);
            }

            foreach (GameObject obj in this.listManager.GetList<GameObject>())
            {
                obj.SendUpdateMessage(lobby, gameTime);
                if (obj.IsDestroyed)
                {
                    this.Remove(obj);
                }
            }
        }