Ejemplo n.º 1
0
        private void loadSpawnButton_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Filter = dialog.Filter = "Map files (*.map)|*.map";
            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                // Clear map
                if (Spawns.Count > 0)
                {
                    foreach (var spawn in Spawns)
                    {
                        RenderObjectsManager.RemoveSpawn(spawn);
                    }
                    Spawns.Clear();
                }

                var spawnReader = new SpawnReader();
                spawnReader.MapFileName = dialog.FileName;
                var spawns = spawnReader.LoadSpawns();

                Spawns = spawns;
                allSpawnsListBox.DataSource = Spawns;

                foreach (var spawn in spawns)
                {
                    RenderObjectsManager.AddSpawner(spawn);
                }

                RefreshUI();
            }
        }
Ejemplo n.º 2
0
        public static void UserConnection(Packet p)
        {
            bool   login    = p.ReadBool();
            string username = p.ReadASCII(p.ReadByte());

            UserObject user = RenderObjectsManager.GetUser(username);

            if (user == null)
            {
                if (login)
                {
                    UOClientManager.SysMessage("[Login][" + username + "]: Connected.", 83);
                    RenderObjectsManager.AddUser(new UserObject(username));
                }
            }
            else
            {
                if (!login)
                {
                    if (Global.TrackedUser != null && Global.TrackedUser == user)
                    {
                        Global.TrackedUser = null;
                    }

                    UOClientManager.SysMessage("[Logout][" + username + "]: Disconnected.", 83);
                    user.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        private static void SharedLabel(Packet p)
        {
            bool  toremove = p.ReadBool();
            short x        = (short)p.ReadUShort();
            short y        = (short)p.ReadUShort();
            byte  map      = p.ReadByte();

            if (toremove)
            {
                UserObject        user  = RenderObjectsManager.GetUser(p.ReadASCII(p.ReadByte()));
                SharedLabelObject label = RenderObjectsManager.Get <SharedLabelObject>().FirstOrDefault(s => s.Parent == user && s.Position.X == x && s.Position.Y == y && s.Map == map);
                label?.Dispose();

                UOClientManager.SysMessage(string.Format("[SharedLabel][{0}] Removed a shared label!", user.Name), 83);
            }
            else
            {
                string     description = p.ReadASCII(p.ReadByte());
                string     username    = p.ReadASCII(p.ReadByte());
                UserObject user        = RenderObjectsManager.GetUser(username);
                if (user == null)
                {
                    RenderObjectsManager.AddUser(user = new UserObject(username));
                }

                RenderObjectsManager.AddSharedLabel(new SharedLabelObject(user, x, y, map, description));
                UOClientManager.SysMessage(string.Format("[SharedLabel][{0}] Added a shared label!", user.Name), 83);
            }
        }
Ejemplo n.º 4
0
        private void deleteSpawnButton_Click(object sender, EventArgs e)
        {
            if (SelectedSpawn == null)
            {
                MessageBox.Show("Please select a valid spawn.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            RenderObjectsManager.RemoveSpawn(SelectedSpawn);
            Spawns.Remove(SelectedSpawn);
        }
Ejemplo n.º 5
0
        private static void NewChatMessage(Packet p)
        {
            ushort msglen  = p.ReadUShort();
            int    color   = (int)p.ReadUInt();
            string message = p.ReadASCII(msglen);

            string     username = p.ReadASCII(p.ReadByte());
            UserObject user     = RenderObjectsManager.GetUser(username);

            ChatManager.Add(username, message);
            user.UpdateLifeTime();
            UOClientManager.SysMessage("[Chat][" + username + "]: " + message, 83);
        }
Ejemplo n.º 6
0
        private static void NewAlert(Packet p)
        {
            int    x        = (short)p.ReadUShort();
            int    y        = (short)p.ReadUShort();
            string username = p.ReadASCII(p.ReadByte());

            UserObject   user   = RenderObjectsManager.GetUser(username);
            SignalObject signal = new SignalObject(x, y);

            RenderObjectsManager.AddSignal(signal);

            UOClientManager.SysMessage(string.Format("[Alert][{0}] sends an alert!", user.Name), 83);
        }
Ejemplo n.º 7
0
        static NetworkManager()
        {
            SocketClient = new SocketClient();

            SocketClient.Disconnected += (sender, e) =>
            {
                RenderObjectsManager.Get <UserObject>().Where(s => !(s is PlayerObject)).ToList().ForEach(s => s.Dispose());
                RenderObjectsManager.Get <SharedLabelObject>().ToList().ForEach(s => s.Dispose());
            };

            _TimerReconnect = TimerManager.Create(5000, 5000, () =>
            {
                if (!SocketClient.IsConnected)
                {
                    Connect();
                }
            }, false);
        }
Ejemplo n.º 8
0
        public SharedLabelF()
        {
            InitializeComponent();
            Icon        = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            MinimumSize = MaximumSize = Size;
            MaximizeBox = false;
            Text        = "Shared Label Creator";

            void hanlder(object sender, EventArgs e)
            {
                if (sender is NumericTextBox tb && string.IsNullOrEmpty(tb.Text))
                {
                    tb.Text = "0";
                }
            }

            foreach (MapEntry m in Global.Maps)
            {
                comboBoxMap.Items.Add(m.Index);
                if (comboBoxMap.Items.Count - 1 == Global.Facet)
                {
                    comboBoxMap.SelectedIndex = comboBoxMap.Items.Count - 1;
                }
            }

            numericTextBoxX.Text = MouseManager.Location.X.ToString();
            numericTextBoxY.Text = MouseManager.Location.Y.ToString();

            numericTextBoxX.TextChanged += hanlder;
            numericTextBoxY.TextChanged += hanlder;

            customButtonSend.Click += (sender, e) =>
            {
                if (NetworkManager.SocketClient.IsConnected)
                {
                    NetworkManager.SocketClient.Send(new PSharedLabel((ushort)numericTextBoxX.IntValue, (ushort)numericTextBoxY.IntValue, (byte)comboBoxMap.SelectedIndex, textBoxDescription.Text));
                    RenderObjectsManager.AddSharedLabel(new SharedLabelObject(Global.PlayerInstance, (short)numericTextBoxX.IntValue, (short)numericTextBoxY.IntValue, (byte)comboBoxMap.SelectedIndex, textBoxDescription.Text));
                }
            };
        }
Ejemplo n.º 9
0
        private void ChatManager_MessageWrited(object sender, ChatEntry e)
        {
            richTextBoxChat.Do(s =>
            {
                UserObject user = RenderObjectsManager.GetUser(e.Name);
                if (user == null)
                {
                    Logger.Error("[CHAT] User '" + e.Name + "' not found");
                }
                else
                {
                    string msg;

                    //if (_lastChatEntry.Name != e.Name && DateTime.Now.Minute > _lastChatEntry.Time.Minute)
                    {
                        msg            = string.Format("[{0}] {1}:   {2}\r\n", e.Time.ToString("HH:mm"), e.Name, e.Message);
                        _lastChatEntry = e;
                    }

                    /*else
                     * {
                     *  msg = string.Format("{0}{1}\r\n", new string(' ', _lastChatEntry.Time.ToString("HH:mm").Length), e.Message);
                     * }
                     */
                    if (s.TextLength + msg.Length >= s.MaxLength)
                    {
                        s.Clear();
                    }

                    s.AppendText(msg, user.Hue.Color);

                    if (LastLineVisible(s))
                    {
                        s.ScrollToCaret();
                    }
                }
            });
        }
Ejemplo n.º 10
0
        public static void PlayerData(Packet p)
        {
            ushort x     = p.ReadUShort();
            ushort y     = p.ReadUShort();
            byte   facet = p.ReadByte();

            ushort hits    = p.ReadUShort();
            ushort stam    = p.ReadUShort();
            ushort mana    = p.ReadUShort();
            ushort maxhits = p.ReadUShort();
            ushort maxstam = p.ReadUShort();
            ushort maxmana = p.ReadUShort();

            byte flag = p.ReadByte();

            p.Skip(1);
            bool panic = p.ReadBool();

            Color msgCol = Color.FromArgb((int)p.ReadUInt());

            string fontName = p.ReadASCII(p.ReadByte());

            float fontSize;

            unsafe
            {
                uint n = p.ReadUInt();
                fontSize = *(float *)&n;
            }


            FontStyle fontStyle = (FontStyle)p.ReadByte();

            FontFamily f = FontFamily.Families.FirstOrDefault(s => s.Name == fontName);

            if (f == null)
            {
                fontName = "Arial";
            }
            else if (!f.IsStyleAvailable(fontStyle))
            {
                fontStyle = FontStyle.Regular;
            }

            string     username = p.ReadASCII(p.ReadByte());
            UserObject user     = RenderObjectsManager.GetUser(username);

            if (user == null)
            {
                RenderObjectsManager.AddUser(user = new UserObject(username));
            }

            user.UpdatePosition(x, y);
            user.Map = facet;
            user.Hits.Set(hits, maxhits);
            user.Stamina.Set(stam, maxstam);
            user.Mana.Set(mana, maxmana);

            switch (flag)
            {
            case 1:
                user.IsPoisoned = true;
                break;

            case 2:
                user.IsYellowHits = true;
                break;

            case 3:
                user.IsParalyzed = true;
                break;

            case 4:
                if (!user.IsDead)
                {
                    RenderObjectsManager.AddDeathObject(new DeathObject(user, user.Position, user.Map));
                }
                user.IsDead = true;
                break;

            case 5:
                user.IsHidden = true;
                break;

            default:
                user.IsHidden = user.IsPoisoned = user.IsYellowHits = user.IsParalyzed = user.IsDead = false;
                break;
            }

            if (user.InPanic && panic) // already panic, ignore
            {
                if (DateTime.Now > user.LastPanicUpdate)
                {
                    UOClientManager.SysMessage($"[Panic][{user.Name}] Needs help to: {user.Position} - Map: {user.Map}", 83);
                    user.LastPanicUpdate = DateTime.Now.AddSeconds(5);
                }
            }
            else if (!user.InPanic && panic) // receive panic signal
            {
                if (Global.SettingsCollection["panicsounds"].ToBool())
                {
                    SoundsManager.Play(SOUNDS_TYPE.PANIC);
                }
                UOClientManager.SysMessage($"[Panic][{user.Name}] Starts to panic!", 83);
                user.LastPanicUpdate = DateTime.Now.AddSeconds(5);
            }
            else if (user.InPanic && !panic) // receve remove panic signal
            {
                UOClientManager.SysMessage($"[Panic][{user.Name}] Stopped to panic.", 83);
            }

            user.InPanic = panic;
            user.Font    = new Font(fontName, fontSize, fontStyle, GraphicsUnit.Pixel);
            user.Hue     = new SolidBrush(msgCol);

            user.UpdateLifeTime();
        }
Ejemplo n.º 11
0
        public PlacesEditorF()
        {
            InitializeComponent();
            Icon        = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            MaximumSize = MinimumSize = Size;
            Text        = "Places Editor";

            textX.KeyPress += (sender, e) =>
            {
                if (!char.IsNumber(e.KeyChar) && (Keys)e.KeyChar != Keys.Back)
                {
                    e.Handled = true;
                }
            };
            textY.KeyPress += (sender, e) =>
            {
                if (!char.IsNumber(e.KeyChar) && (Keys)e.KeyChar != Keys.Back)
                {
                    e.Handled = true;
                }
            };

            ComboBoxCategory.SelectedIndexChanged += (sender, e) =>
            {
                customFlatButtonAdd.Enabled = ComboBoxCategory.SelectedText != FilesManager.BuildSets[ComboBoxCategory.SelectedIndex].Name;
                PictureBox1.Image           = FilesManager.BuildSets[ComboBoxCategory.SelectedIndex].Image;
            };
            FilesManager.BuildSets.ForEach(s => ComboBoxCategory.Items.Add(s.Name));

            Global.Maps.ForEach(s => ComboBoxFacet.Items.Add(s.Name));
            if (Global.Maps.Length > 2 && Global.Maps[0]?.Name.ToLower() == "felucca" && Global.Maps[1]?.Name.ToLower() == "trammel")
            {
                ComboBoxFacet.Items.Add("Fel/Tram");
            }

            customFlatButtonCancel.Click += (sender, e) =>
            {
                if (customFlatButtonAdd.Tag is BuildingEntry build)
                {
                    build.Parent.Entries.Remove(build);
                    BuildingObject buildingObj = RenderObjectsManager.Get <BuildingObject>().FirstOrDefault(s => s.Entry == build);
                    if (buildingObj != null)
                    {
                        buildingObj.Dispose();
                    }

                    Close();
                }
                else if (customFlatButtonAdd.Tag is HouseEntry house)
                {
                    HouseObject houseObj = RenderObjectsManager.Get <HouseObject>().FirstOrDefault(s => s.Entry == house);
                    if (houseObj != null)
                    {
                        houseObj.Dispose();
                    }

                    FilesManager.Houses.Remove(house);
                    Close();
                }
                else if (customFlatButtonAdd.Tag is null)
                {
                }
            };

            customFlatButtonAdd.Click += (sender, e) =>
            {
                if (customFlatButtonAdd.Tag is BuildingEntry build)
                {
                    build.Description = textDescription.Text;
                    build.Location.X  = textX.Text.ToShort();
                    build.Location.Y  = textY.Text.ToShort();

                    int facet = ComboBoxFacet.SelectedIndex;
                    if (Global.Maps.Length > 2 && Global.Maps[0]?.Name.ToLower() == "felucca" && Global.Maps[1]?.Name.ToLower() == "trammel")
                    {
                        if (facet == 6)
                        {
                            facet = 7;
                        }
                    }

                    build.Map = facet;
                    build.Parent.Entries.Remove(build);
                    build.Parent = FilesManager.BuildSets[ComboBoxCategory.SelectedIndex];
                    FilesManager.BuildSets[ComboBoxCategory.SelectedIndex].Entries.Add(build);
                    build.IsEnabled = true;

                    RenderObjectsManager.AddBuilding(new BuildingObject(build));
                    Close();
                }
                else if (customFlatButtonAdd.Tag is HouseEntry house)
                {
                }
                else if (customFlatButtonAdd.Tag is null)
                {
                    int facet = ComboBoxFacet.SelectedIndex;
                    if (Global.Maps.Length > 2 && Global.Maps[0]?.Name.ToLower() == "felucca" && Global.Maps[1]?.Name.ToLower() == "trammel")
                    {
                        if (facet == 6)
                        {
                            facet = 7;
                        }
                    }

                    BuildingEntry entry = new BuildingEntry(FilesManager.BuildSets[ComboBoxCategory.SelectedIndex], textDescription.Text, new Position(textX.Text.ToShort(), textY.Text.ToShort()), facet);
                    FilesManager.BuildSets[ComboBoxCategory.SelectedIndex].Entries.Add(entry);
                    entry.IsEnabled = true;
                    RenderObjectsManager.AddBuilding(new BuildingObject(entry));

                    Close();
                }
            };

            textX.Text = MouseManager.Location.X.ToString();
            textY.Text = MouseManager.Location.Y.ToString();
            ComboBoxFacet.SelectedIndex = Global.Facet;
        }