Example #1
0
 public static void ChatMessage(Int32 id, Int32 sender, String msg, Enumerations.MessageType type)
 {
     if (Data.TempPlayers.ContainsKey(sender) && Data.Players.ContainsKey(sender)) {
         using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.ChatMessage);
         buffer.WriteByte((Byte)type);
             if (Data.TempPlayers[sender].InGame) {
                 switch (type) {
                     case Enumerations.MessageType.System:
                     buffer.WriteString(String.Format("<SYSTEM> {0}", msg));
                     break;
                     case Enumerations.MessageType.Error:
                     buffer.WriteString(String.Format("<ERROR> {0}", msg));
                     break;
                     case Enumerations.MessageType.World:
                     buffer.WriteString(String.Format("[W] {0}: {1}", Data.Players[sender].Characters[Data.TempPlayers[sender].CurrentCharacter].Name, msg));
                     break;
                     case Enumerations.MessageType.Map:
                     buffer.WriteString(String.Format("[S] {0}: {1}", Data.Players[sender].Characters[Data.TempPlayers[sender].CurrentCharacter].Name, msg));
                     break;
                     case Enumerations.MessageType.Emote:
                     buffer.WriteString(String.Format("{0} {1}", Data.Players[sender].Characters[Data.TempPlayers[sender].CurrentCharacter].Name, msg));
                     break;
                 }
             }
             SendDataTo(id, buffer);
         }
     }
 }
Example #2
0
 public static void Ping()
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.Ping);
         SendData(buffer);
     }
 }
Example #3
0
 public static void RequestMapList()
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.RequestMapList);
         SendData(buffer);
     }
 }
Example #4
0
 internal static void HandleChatMessage(DataBuffer buffer)
 {
     var type = (Enumerations.MessageType)buffer.ReadByte();
     var msg = buffer.ReadString();
     SFML.Graphics.Color color = new SFML.Graphics.Color(0, 0, 0);
     if (!Data.InGame) return;
     switch (type) {
         case Enumerations.MessageType.System:
             color = new SFML.Graphics.Color(100, 100, 49);
         break;
         case Enumerations.MessageType.Error:
             color = new SFML.Graphics.Color(255, 0, 0);
         break;
         case Enumerations.MessageType.World:
             color = new SFML.Graphics.Color(0, 195, 255);
         break;
         case Enumerations.MessageType.Map:
             color = new SFML.Graphics.Color(0, 0, 0);
         break;
         case Enumerations.MessageType.Emote:
             color = new SFML.Graphics.Color(255, 59, 0);
         break;
     }
     Interface.GUI.Get<TGUI.ChatBox>("chat").AddLine(msg, color);
 }
Example #5
0
 public static void ChatMessage(String msg)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.ChatMessage);
         buffer.WriteString(msg);
         SendData(buffer);
     }
 }
Example #6
0
 public static void HandleLoginOk(DataBuffer buffer)
 {
     Program.FrmLogin.BeginInvoke((Action)(()=> {
         Program.FrmLogin.Visible = false;
         Program.FrmEditor = new MainEditor();
         Program.FrmEditor.Show();
     }));
 }
Example #7
0
 public static void ErrorMessage(Int32 id, String message)
 {
     // Write our alert into a buffer and send it along.
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.ErrorMsg);
         buffer.WriteString(message);
         SendDataTo(id, buffer);
     }
 }
Example #8
0
 public void SendData(Byte[] data)
 {
     var b = new DataBuffer();
     b.WriteInt32(data.Length);
     b.Append(data);
     try {
         this.MainSocket.BeginSend(b.ToArray(), 0, (Int32)b.Length(), SocketFlags.None, new AsyncCallback(DataSent), null);
     } catch { }
 }
Example #9
0
 public static void NewAccount(String username, String Password)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.NewAccount);
         buffer.WriteString(username);
         buffer.WriteString(Password);
         SendData(buffer);
     }
 }
Example #10
0
 public static void AddCharacter(String name, Int32 pclass, Enumerations.Gender gender)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.AddCharacter);
         buffer.WriteString(name);
         buffer.WriteInt32(pclass);
         buffer.WriteByte((Byte)gender);
         SendData(buffer);
     }
 }
Example #11
0
 public static void Login(String username, String Password)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.Login);
         buffer.WriteString(username);
         buffer.WriteString(Password);
         buffer.WriteBoolean(true);     //Signifies we're an editor, not a client.
         SendData(buffer);
     }
 }
Example #12
0
 public static void PlayerMoving()
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Client.PlayerMoving);
         for (var i = 0; i < (Int32)Enumerations.Direction.Direction_Count; i++) {
             buffer.WriteBoolean(Logic.Input.DirectionPressed[i]);
         }
         SendData(buffer);
     }
 }
Example #13
0
        internal static void HandleMapList(DataBuffer buffer)
        {
            var max = buffer.ReadInt32();

            Program.FrmEditor.BeginInvoke((Action)(() => {
                Program.FrmEditor.ClearMaps();

            }));
            for (var i = 1; i <= max; i++) {
                    Program.FrmEditor.BeginInvoke((Action<Int32, String>)((num, name) => {
                        Program.FrmEditor.AddMap(String.Format("{0}: {1}", num, name));
                }), i, buffer.ReadString());
            }
        }
Example #14
0
        internal static void HandleLoadMap(DataBuffer buffer)
        {
            var mapnum = buffer.ReadInt32();
            var revision = buffer.ReadInt32();

            // Load our map.
            Data.LoadMap(mapnum);

            // Compare revisions
            if (Data.Map.Revision == revision) {
                Send.MapOK();
            } else {
                Send.RequestMap();
            }
        }
Example #15
0
        internal static void HandleCreateCharacterData(DataBuffer buffer)
        {
            // get amount of classes.
            var classes = buffer.ReadInt32();

            for (var i = 1; i < classes + 1; i++) {
                var c = new Class();
                c.Name = buffer.ReadString();
                c.MaleSprite = buffer.ReadInt32();
                c.FemaleSprite = buffer.ReadInt32();
                Data.Classes.Add(i, c);
            }

            Interface.ChangeUI(Interface.Windows.CharacterCreate);
        }
Example #16
0
 public static void MapEditorData(Int32 id)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.MapEditorData);
         SendDataTo(id, buffer);
     }
 }
Example #17
0
 public static void LoadMap(Int32 id, Int32 map)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.LoadMap);
         buffer.WriteInt32(map);
         buffer.WriteInt32(Data.Map[map].Revision);
         SendDataTo(id, buffer);
     }
 }
Example #18
0
 public static void InGame(Int32 id)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.InGame);
         SendDataTo(id, buffer);
     }
 }
Example #19
0
        public static void NewCharacterData(Int32 id)
        {
            // Write our classlist and send it.
            using (var buffer = new DataBuffer()) {
                buffer.WriteInt32((Int32)Packets.Server.NewCharacterData);

                // Write our class count.
                buffer.WriteInt32(Data.Settings.MaxClasses);

                // We're going to have to write data for each class.
                for (var i = 1; i <= Data.Settings.MaxClasses; i++) {

                    // Name
                    buffer.WriteString(Data.Classes[i].Name);

                    // Sprites
                    buffer.WriteInt32(Data.Classes[i].MaleSprite);
                    buffer.WriteInt32(Data.Classes[i].FemaleSprite);

                }
                // Send our data!
                SendDataTo(id, buffer);
            }
        }
Example #20
0
 public static void PlayerData(Int32 id, Int32 player)
 {
     if (Data.Players.ContainsKey(player) && Data.TempPlayers.ContainsKey(player)) {
         using (var buffer = new DataBuffer()) {
             buffer.WriteInt32((Int32)Packets.Server.PlayerData);
             buffer.WriteInt32(player);
             buffer.WriteString(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Name);
             buffer.WriteByte(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Gender);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Class);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Level);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Experience);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Sprite);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Map);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].X);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Y);
             buffer.WriteByte(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Direction);
             for (var i = 0; i < (Int32)Enumerations.Stats.Stat_Count - 1; i++) {
                 buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Statistic[i]);
             }
             SendDataTo(id, buffer);
         }
     }
 }
Example #21
0
 private static void SendDataTo(Int32 id, DataBuffer buffer)
 {
     Program.Server.SendDataTo(id, buffer.ToArray());
 }
Example #22
0
 public static void SelectCharacterData(Int32 id)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.SelectCharacterData);
         for (var i = 0; i < Data.Players[id].Characters.Length; i++) {
             buffer.WriteString(Data.Players[id].Characters[i].Name);
             buffer.WriteInt32(Data.Players[id].Characters[i].Level);
         }
         SendDataTo(id, buffer);
     }
 }
Example #23
0
 public static void PlayerLocation(Int32 id, Int32 player)
 {
     if (Data.Players.ContainsKey(player) && Data.TempPlayers.ContainsKey(player)) {
         using (var buffer = new DataBuffer()) {
             buffer.WriteInt32((Int32)Packets.Server.PlayerLocation);
             buffer.WriteInt32(player);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Map);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].X);
             buffer.WriteInt32(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Y);
             buffer.WriteByte(Data.Players[player].Characters[Data.TempPlayers[player].CurrentCharacter].Direction);
         }
     }
 }
Example #24
0
 public static void PlayerID(Int32 id)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.PlayerId);
         buffer.WriteInt32(id);
         SendDataTo(id, buffer);
     }
 }
Example #25
0
 private static void SendData(DataBuffer buffer)
 {
     Program.NetworkClient.SendData(buffer.ToArray());
 }
Example #26
0
 private static void SendDataToAll(DataBuffer buffer)
 {
     Program.Server.SendDataToAll(buffer.ToArray());
 }
Example #27
0
 public static void PlayerMoving(Int32 id, Int32 player)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.PlayerMoving);
         buffer.WriteInt32(player);
         for (var i = 0; i < (Int32)Enumerations.Direction.Direction_Count; i++) {
             if (Data.TempPlayers.ContainsKey(player)) buffer.WriteBoolean(Data.TempPlayers[player].IsMoving[i]);
         }
         SendDataTo(id, buffer);
     }
 }
Example #28
0
 public static void Ping()
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.Ping);
         SendDataToAll(buffer);
     }
 }
Example #29
0
 internal static void HandlePlayerId(DataBuffer buffer)
 {
     Data.MyId = buffer.ReadInt32();
 }
Example #30
0
 public static void RemovePlayer(Int32 id, Int32 player)
 {
     using (var buffer = new DataBuffer()) {
         buffer.WriteInt32((Int32)Packets.Server.RemovePlayer);
         buffer.WriteInt32(player);
         SendDataTo(id, buffer);
     }
 }