Example #1
0
        public void HandlePlayerInfo(PlayerInfoPacket pip)
        {
            Console.WriteLine("Received Player Info Packet");
            ClientPlayer player = new ClientPlayer(this) {
                Id = pip.PlayerId,
                Nickname = pip.Nickname,
                Health = pip.Health,
                Position = new WorldPosition(pip.X, pip.Y),
                SpeedMeterPerMillisecond = pip.Speed
            };
            // FIXME: ModelScaling should be dynamic, model depending and influencable by the server
            player.ModelScaling = 1f / 512f;

            if (GameScene.Entities.ContainsKey(player.Id))
            {
                Console.WriteLine("Tried to add new Player to Entity List, but already exists!");
            }
            else {
                GameScene.Entities.Add(player.Id, player);
            }
            // first PlayerInfoPacket is the Player
            if (GameScene.Player == null)
            {
                GameScene.Player = player;
            }
        }
Example #2
0
 public void HandleEntitySpawn(EntitySpawnPacket esp)
 {
     //FIXME: Entities must have more details
     IEntity entity;
     if (!GameScene.Entities.TryGetValue(esp.EntityId, out entity))
     {
         entity = new ClientPlayer(this)
         {
             Id = esp.EntityId,
             Health = esp.Health,
             Nickname = esp.Nickname,
             Position = new WorldPosition(esp.X, esp.Y)
         };
         GameScene.Entities.Add(entity.Id, entity);
     }
     else
     {
         // FIXME: update the entetie here
     }
 }