Esempio n. 1
0
    public BuyTransaction BuyItem(RPGItem item, int Amount)
    {
        if (item.ID == 0)
        {
            return(BuyTransaction.SomeError);
        }
        //calculate price
        int price = (int)(item.SellValue * Amount);

        //currency item
        //RPGItem currencyItem = new RPGItem();
        //currencyItem = Storage.LoadById<RPGItem>(CurrencyID, new RPGItem());
        //skill affecting price put modifier here
        //check if you have enough gold
        if (!Player.Instance.Hero.CanYouAfford(price, item.BuyCurrency))
        {
            return(BuyTransaction.NotEnoughGold);
        }

        //check space in inventory
        if (!Player.Instance.Hero.Inventory.DoYouHaveSpaceForThisItem(item, Amount))
        {
            return(BuyTransaction.NotEnoughSpaceInInventory);
        }
        else
        {
            //add item to inventory
            if (item.ItemCategory == ItemType.Armor)
            {
                PreffixSolver.GiveItem(PreffixType.ARMOR, item.ID, Amount);
            }
            else
            {
                Player.Instance.Hero.Inventory.AddItem(item, Amount);
            }

            //remove currency amount from inventory
            Player.Instance.Hero.RemoveCurrency(price, item.BuyCurrency);

            //remove item from current shop collection
            foreach (ItemInWorld shopItem in ShopItems)
            {
                if (shopItem.rpgItem.UniqueId == item.UniqueId)
                {
                    shopItem.CurrentAmount = shopItem.CurrentAmount - Amount;
                    if (shopItem.CurrentAmount <= 0)
                    {
                        ShopItems.Remove(shopItem);
                    }
                    break;
                }
            }

            //add bio log info
            //player.Hero.Log.BuyItem(Player.activeNPC, Amount, item.UniqueId);
            return(BuyTransaction.OK);
        }
    }
Esempio n. 2
0
    public void StartNewGame()
    {
        for (int i = 1; i < 15; i++)
        {
            PreffixSolver.GiveItem(PreffixType.ARMOR, i, 1);
            //Debug.Log(i);
        }

        //PreffixSolver.GiveItem(PreffixType.ARMOR, 1, 1);

        BodyInventory.EquipItem(BodyInventory.Items[1]);
        HeadInventory.EquipItem(HeadInventory.Items[1]);
        ArmLInventory.EquipItem(ArmLInventory.Items[0]);
        ArmRInventory.EquipItem(ArmRInventory.Items[0]);
        LegsInventory.EquipItem(LegsInventory.Items[1]);

        AddCurrency(1000, BuyCurrencyType.Magnets);
        AddCurrency(100, BuyCurrencyType.Crystals);
        //PreffixSolver.GiveItem(PreffixType.ARMOR, 1, 1);
        //PreffixSolver.GiveItem(PreffixType.ARMOR, 2, 1);
    }