public override void SendPosition(Client sender, bool fromServer = false) { if(!fromServer) Server.NotifyClientPosition(this, sender); var packet = sender.GetDataPacket(); packet.Origin = sender.Id; SendPacketToAll(packet); }
public override void AddClient(Client client) { // -- We assume the Client is a GameJolt or the Client's password is correct and no one is using the Client's name. if (IsGameJoltIdUsed(client as P3DPlayer)) { client.Kick("You are already on server!"); return; } SavePlayerGJ(client as P3DPlayer); ClientUpdate(client, true); // Send to player his Id client.SendPacket(new CreatePlayerPacket { Origin = -1, PlayerId = client.Id }); // Send to player all Players Id foreach (var aClient in Server.GetAllClients()) { client.SendPacket(new CreatePlayerPacket { Origin = -1, PlayerId = aClient.Id }); var packet = aClient.GetDataPacket(); packet.Origin = aClient.Id; client.SendPacket(packet); } // Send to Players player Id SendPacketToAll(new CreatePlayerPacket { Origin = -1, PlayerId = client.Id }); var p = client.GetDataPacket(); p.Origin = client.Id; SendPacketToAll(p); ClientConnected(client); base.AddClient(client); }
public override void ClientConnected(Client client) { SendPacketToAll(new CreatePlayerPacket { Origin = -1, PlayerId = client.Id }); var packet = client.GetDataPacket(); packet.Origin = client.Id; SendPacketToAll(packet); SendPacketToAll(new ChatMessageGlobalPacket { Origin = -1, Message = $"Player {client.Name} joined the game!" }); }
public override void SendPosition(Client sender, bool fromServer = false) { if (!fromServer) Server.NotifyClientPosition(this, sender); if (sender is PokeDPlayer) return; else { var posData = sender.GetDataPacket(); SendPacketToAll(new PositionPacket() { Position = posData.GetPosition(posData.DecimalSeparator) }); } }