Пример #1
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();
                }
            }
        }
Пример #2
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);
            }
        }
Пример #3
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();
        }