Beispiel #1
0
        public static void SpawnPlayer(int recipientClient, PlayerServer player, bool justJoined)
        {
            using (Packet packet = new Packet((int)ServerPackets.spawnPlayer))
            {
                packet.Write(player.ID);
                packet.Write(player.Username);
                packet.Write(player.Position);
                packet.Write(player.IsFacingRight);

                packet.Write(player.RunSpeed);
                packet.Write(player.SprintSpeed);

                packet.Write(player.IsDead);
                packet.Write(justJoined);

                packet.Write(player.Kills);
                packet.Write(player.Deaths);
                packet.Write(player.Score);

                packet.Write(player.MaxHealth);
                packet.Write(player.CurrentHealth);

                packet.Write(player.PlayerColor);

                packet.Write(player.Paused);

                SendTCPPacket(recipientClient, packet);
            }
        }
Beispiel #2
0
        internal static void PlayerStillConnectedUDP(byte clientID, Packet packet)
        {
            try
            {
                PlayerServer player = Server.ClientDictionary[clientID].Player;

                player.LastPacketReceivedUDP(DateTime.Now.TimeOfDay);
                ServerSend.PlayerConnectedAcknAndPingUDP(clientID, player.Latency2WayMSUDP, player.GetLatencyIDUDP());
            }
            catch (Exception e) {
                OutputPacketError(clientID, e);
            }
        }
Beispiel #3
0
        internal static void PlayerPingAckUDP(byte clientID, Packet packet)
        {
            try
            {
                byte latencyIDUDP = packet.ReadByte();

                PlayerServer player = Server.ClientDictionary[clientID].Player;

                player.LastPacketReceivedUDP(DateTime.Now.TimeOfDay);
                player.PingAckUDP(latencyIDUDP);
            }
            catch (Exception e) {
                OutputPacketError(clientID, e);
            }
        }
Beispiel #4
0
        internal static void ConstantPlayerData(byte clientID, Packet packet)
        {
            try
            {
                bool[]       bits   = packet.Read1ByteAs8Bools();
                PlayerServer player = Server.ClientDictionary[clientID].Player;

                if (bits[0])
                {
                    Quaternion armRotation = packet.ReadQuaternion();
                    player.PlayerArmRotation(armRotation);
                }

                if (bits[1])
                {
                    Vector2 armPosition = packet.ReadLocalVector2();
                    player.PlayerArmPosition(armPosition);
                }

                if (bits[2])
                {
                    Vector2 playerPosition = packet.ReadUVector2WorldPosition();
                    player.SetPlayerPosition(playerPosition);
                }

                if (bits[3])
                {
                    byte moveState = packet.ReadByte();
                    player.PlayerMoveState(moveState);
                }
            }
            catch (Exception e)
            {
                OutputPacketError(clientID, e);
            }
        }