示例#1
0
 public Waypoint(WaypointType Type, ShopAction ShopAction, uint ItemID, int Amount)
 {
     wType = Type;
     wShopAction = ShopAction;
     wItemID = ItemID;
     wAmount = Amount;
 }
示例#2
0
        private void AcceptStringInput(string userInput)
        {
            if (string.IsNullOrEmpty(userInput))
            {
                return;
            }

            if (!IsInputValid(userInput))
            {
                InputInvalid();
                return;
            }

            ShopAction.BuyItem(_controller, int.Parse(userInput));
            InputComplete();
        }
示例#3
0
文件: Shop.cs 项目: xzkmxd/Destiny
        public void Handle(Character customer, Packet iPacket)
        {
            ShopAction action = (ShopAction)iPacket.ReadByte();

            switch (action)
            {
            case ShopAction.Buy:
            {
                short index    = iPacket.ReadShort();
                int   mapleID  = iPacket.ReadInt();
                short quantity = iPacket.ReadShort();

                ShopItem item = this.Items[index];

                if (customer.Meso < item.PurchasePrice * quantity)
                {
                    return;
                }

                Item purchase;
                int  price;

                if (item.IsRecharageable)
                {
                    purchase = new Item(item.MapleID, item.MaxPerStack);
                    price    = item.PurchasePrice;
                }
                else if (item.Quantity > 1)
                {
                    purchase = new Item(item.MapleID, item.Quantity);
                    price    = item.PurchasePrice;
                }
                else
                {
                    purchase = new Item(item.MapleID, quantity);
                    price    = item.PurchasePrice * quantity;
                }

                if (customer.Items.SpaceTakenBy(purchase) > customer.Items.RemainingSlots(purchase.Type))
                {
                    customer.Notify("Your inventory is full.", NoticeType.Popup);
                }
                else
                {
                    customer.Meso -= price;
                    customer.Items.Add(purchase);
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte();

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Sell:
            {
                short slot     = iPacket.ReadShort();
                int   mapleID  = iPacket.ReadInt();
                short quantity = iPacket.ReadShort();

                Item item = customer.Items[mapleID, slot];

                if (item.IsRechargeable)
                {
                    quantity = item.Quantity;
                }

                if (quantity > item.Quantity)
                {
                    return;
                }
                else if (quantity == item.Quantity)
                {
                    customer.Items.Remove(item, true);
                }
                else if (quantity < item.Quantity)
                {
                    item.Quantity -= quantity;
                    item.Update();
                }

                if (item.IsRechargeable)
                {
                    customer.Meso += item.SalePrice + (int)(this.UnitPrices[item.MapleID] * item.Quantity);
                }
                else
                {
                    customer.Meso += item.SalePrice * quantity;
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte(8);

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Recharge:
            {
                short slot = iPacket.ReadShort();

                Item item = customer.Items[ItemType.Usable, slot];

                int price = (int)(this.UnitPrices[item.MapleID] * (item.MaxPerStack - item.Quantity));

                if (customer.Meso < price)
                {
                    customer.Notify("You do not have enough mesos.", NoticeType.Popup);
                }
                else
                {
                    customer.Meso -= price;

                    item.Quantity = item.MaxPerStack;
                    item.Update();
                }

                using (Packet oPacket = new Packet(ServerOperationCode.ConfirmShopTransaction))
                {
                    oPacket.WriteByte(8);

                    customer.Client.Send(oPacket);
                }
            }
            break;

            case ShopAction.Leave:
            {
                customer.LastNpc = null;
            }
            break;
            }
        }