예제 #1
0
        //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);
        }
예제 #2
0
        public ServerLogic(ServerGame game, Lobby lobby, Vector2 worldSize)
        {
            RemotePlayer player1 = null;
            RemotePlayer player2 = null;

            foreach (RemotePlayer player in lobby.Clients)
            {
                player.CreatPlayerGameObject(game);
            }

            if (lobby.Clients.Count > 0)
            {
                player1 = lobby.Clients[0];
            }

            if (lobby.Clients.Count > 1)
            {
                player2 = lobby.Clients[1];
            }

            Base player2Base = Base.BaseFactory(game, new Vector2((float)(0.84 * worldSize.X), (float)(0.5 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.84 * worldSize.X), (float)(0.25 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.84 * worldSize.X), (float)(0.75 * worldSize.Y)));

            Base.BaseFactory(game, new Vector2((float)(0.67 * worldSize.X), (float)(0.11 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.67 * worldSize.X), (float)(0.37 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.67 * worldSize.X), (float)(0.63 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.67 * worldSize.X), (float)(0.89 * worldSize.Y)));

            Base.BaseFactory(game, new Vector2((float)(0.5 * worldSize.X), (float)(0.5 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.5 * worldSize.X), (float)(0.25 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.5 * worldSize.X), (float)(0.75 * worldSize.Y)));

            Base.BaseFactory(game, new Vector2((float)(0.33 * worldSize.X), (float)(0.11 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.33 * worldSize.X), (float)(0.37 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.33 * worldSize.X), (float)(0.63 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.33 * worldSize.X), (float)(0.89 * worldSize.Y)));

            Base player1Base = Base.BaseFactory(game, new Vector2((float)(0.16 * worldSize.X), (float)(0.5 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.16 * worldSize.X), (float)(0.25 * worldSize.Y)));
            Base.BaseFactory(game, new Vector2((float)(0.16 * worldSize.X), (float)(0.75 * worldSize.Y)));

            player1Base.SetPlayerInControll(player1);
            Company.Factory(game, player1.GameObject);

            for(int i = 0; i < 5; i++)
            {
                CombatVehicle.CombatVehicleFactory(game.GameObjectCollection, player1.GameObject, player1Base.Position + new Vector2(i * 20, 100));
                Transport.TransportFactory(game.GameObjectCollection, player1.GameObject, player1Base.Position + new Vector2(i * 20, 200));
            }


            player2Base.SetPlayerInControll(player2);
        }
예제 #3
0
 //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;
     }
 }
예제 #4
0
 public static void ServerMain()
 {
     Lobby lobby = new Lobby();
     lobby.Run();
 }