Beispiel #1
0
        public Shop(Map map, Player player, Actor merchant)
        {
            this.player   = player;
            this.merchant = merchant;

            //intialize Buy Inventory
            buyInventory = new ShopInventory(map, player, merchant, false);
            buyInventory.Kill();
            buyInventory.SetWindowPosition(Inventory.Side.up);

            //intialize Sell Inventory
            sellInventory = new ShopInventory(map, player, merchant, true);
            sellInventory.Kill();
            sellInventory.SetWindowPosition(Inventory.Side.up);

            //intialize Choice
            buyText   = new Text(Game.content.Load <SpriteFont>("Fonts\\medival1"), Vector2.Zero, Color.White, "Buy", null, new Vector2(2, 5));
            sellText  = new Text(Game.content.Load <SpriteFont>("Fonts\\medival1"), Vector2.Zero, Color.White, "Sell", null, new Vector2(2, 5));
            exitText  = new Text(Game.content.Load <SpriteFont>("Fonts\\medival1"), Vector2.Zero, Color.White, "Talk", null, new Vector2(2, 5));
            tallkText = new Text(Game.content.Load <SpriteFont>("Fonts\\medival1"), Vector2.Zero, Color.White, "Exit", null, new Vector2(2, 5));
            choice    = new Choice(map, merchant.bounds, player, new List <WindowItem> {
                buyText, sellText, tallkText, exitText
            }, HandleChoice, Choice.Arrangement.square, true);
        }
Beispiel #2
0
        public void SubItem(Item item)
        {
            if (item.amount > 1)
            {
                Text result = null;
                foreach (Item item2 in items)
                {
                    foreach (Text amount in representation.amountTexts)
                    {
                        if (item.icon.position == amount.position)
                        {
                            result = amount;
                        }
                    }
                }
                if (result != null)
                {
                    if (item.amount == 2)
                    {
                        representation.RemoveWindowItem(result, true, true);
                        representation.amountTexts.Remove(result);
                    }
                    else
                    {
                        result.text = item.amount - 1 + "X";
                    }
                }
                item.amount--;
                UpdatePlayerWeight(false);
                return;
            }

            if (representation.alive)
            {
                //remove price
                ShopInventory shopInventory = representation as ShopInventory;
                if (shopInventory != null)
                {
                    shopInventory.SubPrice(item.icon);
                }

                //remove window item
                representation.RemoveWindowItem(item.icon, true);
            }

            //check if the item is equiped
            Hostile hostile = source as Hostile;

            if (hostile != null)
            {
                Armor armor = item as Armor;
                if (armor != null)
                {
                    List <Armor> identicalArmorsList = new List <Armor>();
                    foreach (Armor armor2 in hostile.equipmentList)
                    {
                        if (armor.iconID == armor2.iconID)
                        {
                            identicalArmorsList.Add(armor2);
                        }
                    }
                    if (identicalArmorsList.Count == 1)
                    {
                        hostile.UnEquip(identicalArmorsList[0]);
                    }
                }
            }

            //remove item
            items.Remove(item);
            UpdatePlayerWeight(false);
        }