public UpdatePlayerStateMessage(Player player)
 {
     Id = player.Id;
     Position = player.SimulationState.Position;
     Velocity = player.SimulationState.Velocity;
     Rotation = player.SimulationState.Rotation;
     MessageTime = NetTime.Now;
 }
Esempio n. 2
0
        public Session(NetConnection connection, GameServer server, string username)
        {
            this.connection = connection;
            this.server = server;
            this.username = username;

            handler.OnUpdatePlayerState += HandleUpdatePlayerStateMessage;
            handler.OnChatTalk += HandleChatTalkMessage;

            player = server.World.AddPlayer();

            SendMessageOrdered(new ChatTalkMessage("Welcome to the servers, press right ctrl to chat !"));
            SendMessageOrdered(new ChatTalkMessage("Type /help to see a list of available commands."));
        }
Esempio n. 3
0
        public Player AddPlayer(long id, Vector3 position, Vector3 velocity, float rotation, bool isLocal)
        {
            if (players.ContainsKey(id))
            {
                return players[id];
            }

            var player = new Player(
                id,
                new EntityState {Position = position, Rotation = rotation, Velocity = velocity});

            players.Add(player.Id, player);

            if (isLocal)
            {
                localPlayer = player;
            }

            return player;
        }
 public PlayerStateChangedArgs(Player player)
 {
     Player = player;
 }
Esempio n. 5
0
 public bool PlayerIsLocal(Player player)
 {
     return localPlayer != null && localPlayer.Id == player.Id;
 }
Esempio n. 6
0
 protected void OnPlayerStateChanged(Player player)
 {
     EventHandler<PlayerStateChangedArgs> playerStateChanged = PlayerStateChanged;
     if (playerStateChanged != null)
     {
         playerStateChanged(this, new PlayerStateChangedArgs(player));
     }
 }