public static void SendToRoomPlayers(BaseGameRoom room, byte[] data) { try { for (int i = 0; i < room.PlayersCount; i++) { try { if (room.playersUDP[i] != null) { connectUDP.Send(data, data.Length, room.playersUDP[i].ip); } } catch (Exception ex) { //room.playersUDP[i].Close(); throw ex; } } } catch (Exception ex) { Global.serverForm.Debug(ex + ""); } }
public void LeaveRoom() { playerState = NetPlayerState.InMainLobby; clientState = ClientTCPState.MainLobby; race = null; room = null; }
public static void SendDataToRoomPlayers(BaseGameRoom room, ClientTCP exceptClient, byte[] data) { try { for (int i = 0; i < room.PlayersCount; i++) { try { if (room.playersTCP[i] != null && !exceptClient.Equals(room.playersTCP[i])) { room.playersTCP[i].socket.Send(data); } } catch (Exception ex) { room.playersTCP[i].Close(); throw ex; } } } catch (Exception ex) { Global.serverForm.Debug(ex + ""); } }
public void EnterRoom(BaseGameRoom room, GamePlayerUDP playerUDP, int ID) { this.room = room; this.playerUDP = playerUDP; this.ID = ID; Global.unconectedPlayersUDP.Add(playerUDP); }
/// <summary> /// Buffer: /// int PacketNum; /// </summary> public static void SendRoomStart(BaseGameRoom room) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SRoomStart); ServerTCP.SendDataToRoomPlayers(room, buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// Buffer: /// int PacketNum; /// float loadProgress; /// </summary> public static void SendEnemyProgress(BaseGameRoom room, ClientTCP client, float loadProgress) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SEnemyLoadProgress); buffer.WriteFloat(loadProgress); ServerTCP.SendDataToRoomPlayers(room, client, buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// Buffer: /// int PacketNum; /// string winnerNickname; /// </summary> public static void SendMatchEnded(string nickname, BaseGameRoom room) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SMatchResult); buffer.WriteString(nickname); ServerTCP.SendDataToRoomPlayers(room, buffer.ToArray()); buffer.Dispose(); }
public static void SendDestroy(BaseGameRoom room, int spellIndex, ObjectType type) { using (PacketBuffer buffer = new PacketBuffer()) { buffer.WriteInteger((int)ServerPackets.SDestroy); buffer.WriteInteger((int)type); buffer.WriteInteger(spellIndex); ServerTCP.SendDataToRoomPlayers(room, buffer.ToArray()); } }
public static void SendSynergyUpdate(BaseGameRoom room, ObjectType type, int ObjectIndex, int Synergy, int UpdateIndex) { using (PacketBuffer buffer = new PacketBuffer()) { buffer.WriteInteger((int)UDPServerPackets.USSynergyUpdate); buffer.WriteInteger((int)type); buffer.WriteInteger(ObjectIndex); buffer.WriteInteger(UpdateIndex); buffer.WriteInteger(Synergy); UDPConnector.SendToRoomPlayers(room, buffer.ToArray()); } }
public static void SendPositonUpdate(BaseGameRoom room, ObjectType type, int ObjectIndex, float[] Position, int UpdateIndex) { using (PacketBuffer buffer = new PacketBuffer()) { buffer.WriteInteger((int)UDPServerPackets.USPositionUpdate); buffer.WriteInteger((int)type); buffer.WriteInteger(ObjectIndex); buffer.WriteInteger(UpdateIndex); buffer.WriteFloat(Position[0]); buffer.WriteFloat(Position[1]); buffer.WriteFloat(Position[2]); UDPConnector.SendToRoomPlayers(room, buffer.ToArray()); } }
public void Add(BaseGameRoom room, int spellIndex, int parentIndex, float[] spawnPos, float[] targetPos, float[] rot, int hp, string nickname) { int caster = -1; for (int i = 0; i < room.PlayersCount; i++) { if (room.playersTCP[i].nickname.Equals(nickname)) { caster = i; break; } } int index = Add(room, hp, spawnPos, rot, caster); SendDataTCP.SendInstantiate(room, spellIndex, index, parentIndex, spawnPos, targetPos, rot, hp, nickname); }
/// <summary> /// Buffer: /// int PacketNum; /// int sceneIndex; /// </summary> public static void SendMatchFound(BaseGameRoom room) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SMatchFound); buffer.WriteInteger((int)room.roomType); foreach (ClientTCP player in room.playersTCP) { foreach (ClientTCP friend in player.friends) { SendDataTCP.SendFriendChange(player, friend); } } ServerTCP.SendDataToRoomPlayers(room, buffer.ToArray()); buffer.Dispose(); }
public int[] Add(StaticTypes staticType, ObjectType type, BaseGameRoom room, int count, bool big, bool medium, bool small) { int number = Offset + count; int[] ranges = new int[] { Offset, number - 1 }; ChangeLength(number); _ranges.Add(staticType, ranges); while (Offset < number) { _list[Offset] = new StaticObject(Offset, staticType, type, room.randomer.RandomHP(staticType, big, medium, small), room.randomer.RandomPosition(type), room.randomer.RandomRotation()); Offset++; } return(ranges); }
/// <summary> /// Buffer: /// int PacketNum; /// string firstPlayerNickname; /// string secondPlayerNickname; /// float[3] firstPlayerPosition; /// float[3] secondPlayerPosition; /// float[4] firstPlayerRotation; /// float[4] secondPlayerRotation; /// </summary> public static void SendPlayersSpawned(ClientTCP client, BaseGameRoom room) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SPlayerSpawned); buffer.WriteInteger(room.PlayersCount); for (int i = 0; i < room.PlayersCount; i++) { buffer.WriteString(room.playersTCP[i].nickname); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].PositionX); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].PositionY); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].RotationX); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].RotationY); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].RotationZ); buffer.WriteFloat(room.map.SpawnPoints.ToArray <SpawnPoint>()[i].RotationW); } ServerTCP.SendDataToClient(client, buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// Buffer: /// int PacketNum; /// int SpellIndex; (index in client's spell array) /// int DynamicIndex; (index in dynamicObjects list) /// int parentIndex; /// float[3] position; /// float[4] rotation; /// int hp; /// string nickname; (nickname of master-client) /// </summary> public static void SendInstantiate(BaseGameRoom room, int spellIndex, int dynamicIndex, int parentIndex, float[] castPos, float[] targetPos, float[] rot, int hp, string nickname) { using (PacketBuffer buffer = new PacketBuffer()) { buffer.WriteInteger((int)ServerPackets.SInstantiate); buffer.WriteInteger(spellIndex); buffer.WriteInteger(dynamicIndex); buffer.WriteInteger(parentIndex); buffer.WriteFloat(castPos[0]); buffer.WriteFloat(castPos[1]); buffer.WriteFloat(castPos[2]); buffer.WriteFloat(targetPos[0]); buffer.WriteFloat(targetPos[1]); buffer.WriteFloat(targetPos[2]); buffer.WriteFloat(rot[0]); buffer.WriteFloat(rot[1]); buffer.WriteFloat(rot[2]); buffer.WriteFloat(rot[3]); buffer.WriteInteger(hp); buffer.WriteString(nickname); ServerTCP.SendDataToRoomPlayers(room, buffer.ToArray()); } }
private int Add(BaseGameRoom room, int hp, float[] pos, float[] rot, int caster) { lock (_list) { int index = -1; for (int i = 0; i < Length; i++) { if (_list[i] == null) { _list[i] = new DynamicObject(i, ObjectType.spell, hp, pos, rot, caster); index = i; break; } } if (index == -1) { Length++; Array.Resize(ref _list, Length); index = Length - 1; _list[index] = new DynamicObject(index, ObjectType.spell, hp, pos, rot, caster); } return(index); } }
public GamePlayerUDP(IPEndPoint ipEndpoint, int id, BaseGameRoom gameRoom) { ip = ipEndpoint; ID = id; room = gameRoom; }
public DynamicObjectList(BaseGameRoom room) { Length = 10; _list = new DynamicObject[Length]; _room = room; }
public abstract void Destroy(BaseGameRoom room);
public override void Destroy(BaseGameRoom room) { throw new NotImplementedException(); }
public override void Destroy(BaseGameRoom room) { SendDataTCP.SendDestroy(room, index, type); room.dynamicObjectsList.Destroy(index); }