Пример #1
0
        public void AddVisitor(GameCharacter visitor)
        {
            for (var i = 0; i < Visitors.Length; i++)
            {
                if (Visitors[i] == null)
                {
                    using var pw = new PacketWriter(ServerOperationCode.PlayerInteraction);
                    pw.WriteByte(InteractionCode.Visit);
                    pw.WriteByte(i + 1);
                    pw.WriteBytes(visitor.AppearanceToByteArray());
                    pw.WriteString(visitor.Name);
                    Broadcast(pw);

                    visitor.PlayerShop = this;
                    Visitors[i]        = visitor;

                    using var pwVisitor = new PacketWriter(ServerOperationCode.PlayerInteraction);
                    pwVisitor.WriteByte(InteractionCode.Room);
                    pwVisitor.WriteByte(4);
                    pwVisitor.WriteByte(4);
                    pwVisitor.WriteBool(true);
                    pwVisitor.WriteByte(0);
                    pwVisitor.WriteBytes(Owner.AppearanceToByteArray());
                    pwVisitor.WriteString(Owner.Name);

                    for (var slot = 0; slot < 3; slot++)
                    {
                        if (Visitors[slot] != null)
                        {
                            pwVisitor.WriteByte(slot + 1);
                            pwVisitor.WriteBytes(Visitors[slot].AppearanceToByteArray());
                            pwVisitor.WriteString(Visitors[slot].Name);
                        }
                    }


                    pwVisitor.WriteByte(byte.MaxValue);
                    pwVisitor.WriteString(Description);
                    pwVisitor.WriteByte(0x10);
                    pwVisitor.WriteByte((byte)Items.Count);

                    foreach (var loopShopItem in Items)
                    {
                        pwVisitor.WriteShort(loopShopItem.Bundles);
                        pwVisitor.WriteShort(loopShopItem.Quantity);
                        pwVisitor.WriteInt(loopShopItem.MerchantPrice);
                        pwVisitor.WriteBytes(loopShopItem.ToByteArray(true, true));
                    }

                    visitor.Send(pwVisitor);

                    break;
                }
            }
        }
Пример #2
0
        public Trade(GameCharacter owner)
        {
            Owner         = owner;
            Visitor       = null;
            OwnerMeso     = 0;
            VisitorMeso   = 0;
            OwnerItems    = new List <Item>();
            VisitorItems  = new List <Item>();
            Started       = false;
            OwnerLocked   = false;
            VisitorLocked = false;

            using var pw = new PacketWriter(ServerOperationCode.PlayerInteraction);
            pw.WriteByte(InteractionCode.Room);
            pw.WriteByte(3);
            pw.WriteByte(2);
            pw.WriteByte(0); // NOTE: Player index.
            pw.WriteByte(0);
            pw.WriteBytes(Owner.AppearanceToByteArray());
            pw.WriteString(Owner.Name);
            pw.WriteByte(byte.MaxValue);
            Owner.Send(pw);
        }
Пример #3
0
        public PlayerShop(GameCharacter owner, string description)
        {
            Owner       = owner;
            Description = description;
            Visitors    = new GameCharacter[3];
            Items       = new List <PlayerShopItem>();
            Opened      = false;

            using var pw = new PacketWriter(ServerOperationCode.PlayerInteraction);
            pw.WriteByte(InteractionCode.Room);
            pw.WriteByte(4);
            pw.WriteByte(4);
            pw.WriteByte(0);
            pw.WriteByte(0);
            pw.WriteBytes(Owner.AppearanceToByteArray());
            pw.WriteString(Owner.Name);
            pw.WriteByte(byte.MaxValue);
            pw.WriteString(Description);
            pw.WriteByte(16);
            pw.WriteByte(0);

            Owner.Send(pw);
        }