public static void SendDamage(ClientTCP client, int caster, ObjectType type, int index, int physicDamage, int ignisDamage, int terraDamage, int caeliDamage, int aquaDamage, int pureDamage, bool heal) { using (PacketBuffer buffer = new PacketBuffer()) { buffer.WriteInteger((int)ServerPackets.SDamage); buffer.WriteInteger((int)type); buffer.WriteInteger(index); buffer.WriteInteger(physicDamage); buffer.WriteInteger(ignisDamage); buffer.WriteInteger(terraDamage); buffer.WriteInteger(caeliDamage); buffer.WriteInteger(aquaDamage); buffer.WriteInteger(pureDamage); buffer.WriteBoolean(heal); ServerTCP.SendDataToClient(client.room.playersTCP[caster], buffer.ToArray()); } }
/// <summary> /// Buffer: /// int PacketNum; /// string nickname; /// int[5] level; /// int[5] rank; /// </summary> public static void SendLoginOk(string nickname, ClientTCP client) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SLoginOK); buffer.WriteString(nickname); buffer.WriteString(client.accountData.GuideKey); for (int i = 0; i < client.accountData.AccountParameters.Levels.ToArray().Length; i++) { buffer.WriteInteger(client.accountData.AccountParameters.Levels.ToArray()[i]); } for (int i = 0; i < client.accountData.AccountParameters.Ranks.ToArray().Length; i++) { buffer.WriteInteger(client.accountData.AccountParameters.Ranks.ToArray()[i]); } ServerTCP.SendDataToClient(client, buffer.ToArray()); buffer.Dispose(); }
/// <summary> /// Buffer: /// int PacketNum; /// int amount of spellBuilds (number of players) /// for(amount of spellBuilds) /// int spellBuildLength /// short[spellBuildLength] spellBuild /// </summary> public static void SendLoadSpells(ClientTCP client, short[][] spellBuilds) { PacketBuffer buffer = new PacketBuffer(); buffer.WriteInteger((int)ServerPackets.SSpellLoaded); buffer.WriteInteger(spellBuilds.Length); foreach (short[] spellBuild in spellBuilds) { buffer.WriteInteger(spellBuild.Length); for (int i = 0; i < spellBuild.Length; i++) { buffer.WriteShort(spellBuild[i]); buffer.WriteShort(1); } } ServerTCP.SendDataToClient(client, buffer.ToArray()); buffer.Dispose(); }
/// <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()); } }
public static void ServerStart() { try { HandleDataTCP.InitializeNetworkPackages(); Global.InitGlobals(); Global.serverForm.StatusIndicator(1); try { Global.data.GetAccount("1"); Global.data.GetMap(1); Global.serverForm.StatusIndicator(4); } catch (Exception ex) { Global.serverForm.StatusIndicator(4, ex); } } catch (Exception ex) { Global.serverForm.StatusIndicator(1, ex); } ServerTCP.SetupServer(); }