Пример #1
0
        public bool Purshase(ShopDefItem item, int quantity)
        {
            if (item.Type == ShopItemType.Mech)
            {
                var shop_item = ShopToUse.ActiveInventory.Find((ShopDefItem cachedItem) => cachedItem.ID == item.ID && cachedItem.Type == item.Type);
                if (shop_item == null)
                {
                    Control.LogError($"Shop dont containg {item.ID} to purshase");
                    return(false);
                }
                if (!item.IsInfinite)
                {
                    shop_item.Count -= quantity;
                    if (shop_item.Count < 1)
                    {
                        ShopToUse.ActiveInventory.Remove(shop_item);
                    }
                }
                int price = UIControler.GetPrice(item);

                Control.State.Sim.AddFunds(-price * quantity, null, true, true);
                var mech = CustomShops.Control.State.Sim.DataManager.MechDefs.Get(item.ID);

                for (int i = 0; i < quantity; i++)
                {
                    Control.State.Sim.AddItemStat(mech.Chassis.Description.Id, mech.GetType(), false);
                }
                return(true);
            }

            return(UIControler.DefaultPurshase(this, item, quantity));
        }
        public static int GetPrice(this Shop shop, ShopDefItem item, Shop.PurchaseType purchaseType, Shop.ShopType shopType)
        {
            var price = UIControler.GetPrice(item);

            //Control.LogDebug(DInfo.Price, $"get_price for {item.ID}: {price}");
            return(price);
        }
Пример #3
0
 private void OnClick()
 {
     UIControler.TabSelected(Shop);
 }