Пример #1
0
 internal void InformClients(IEnumerable<Client> clients)
 {
     PlayerInfoPacket pip = new PlayerInfoPacket(Player);
     Server.SendPacketToClientList(pip, clients.ToArray(), this);
 }
Пример #2
0
        public static void ReadPlayerInfo(Client client, PacketReader reader)
        {
            PlayerInfoPacket pip = new PlayerInfoPacket();
            Console.WriteLine("Player Info Packet size is {0}", reader.Size);
            pip.Read(reader);

            if (!reader.Failed)
            {
                client.HandlePlayerInfo(pip);
            }
        }
Пример #3
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;
            }
        }