Exemple #1
0
        private CommonItem CreateCommonItem(IItem iItem, string itemId, EnchantmentsEnchantment enchantment,
                                            Craftingrequirements[] craftingrequirements, bool isTransmut, int enchantIp = 0)
        {
            var im = new ItemMarket();
            var enchantmentlevel = enchantment?.enchantmentlevel ?? (iItem is IItemEnchantmentLevel ie ? ie.enchantmentlevel : 0);

            var main = CreateCommonItemExt(iItem, itemId,
                                           CreateCraftingAndUpgradeRequirements(iItem.uniquename, craftingrequirements, enchantment, isTransmut),
                                           enchantmentlevel, 1, im, enchantIp);

            main.QualityLevels = Empty;
            if (iItem is IItemPowered)
            {
                main.QualityLevels = new CommonItem[4];
                for (var i = 1; i < 5; i++)
                {
//                    var upgrades = CreateUpgradeRequirements(iItem.uniquename, enchantment, i + 1);
                    var upgrades = CreateCraftingAndUpgradeRequirements(iItem.uniquename, craftingrequirements, enchantment, isTransmut, i + 1);
                    main.QualityLevels[i - 1] =
                        CreateCommonItemExt(iItem, itemId,
                                            upgrades, enchantmentlevel, i + 1, im, enchantIp);
                }
            }

            return(main);
        }
Exemple #2
0
        public CommonItem(BaseResorcedRequirement[] craftingRequirements,
                          ItemMarket itemMarket,
                          CraftBuilding craftingBuilding,
                          int qualityLevel,
                          ITownManager buyTownManager,
                          ITownManager sellTownManager
                          )
        {
            QualityLevel         = qualityLevel;
            CraftingRequirements = craftingRequirements;

            IsArtefacted = CraftingRequirements.SelectMany(x => x.Resources)
                           .Any(r => r.Item.ShopCategory == ShopCategory.Artefacts || r.Item.ShopCategory == ShopCategory.Token);

            CraftingBuilding = craftingBuilding;
            ItemMarket       = itemMarket;

            _longBuyRequirement = new LongBuyRequirement(buyTownManager);
            _fastBuyRequirement = new FastBuyRequirement(buyTownManager);

            LongSellProfit   = new LongSellProfit(this, sellTownManager);
            FastSellProfit   = new FastSellProfit(this, sellTownManager);
            BmFastSellProfit = new BmFastSellProfit(this);
            BmLongSellProfit = new BmLongSellProfit(this);

            CostCalcOptions.Instance.Changed        += RequirementsOnUpdated;
            CostCalcOptions.Instance.ProfitsChanged += ProfitsOnUpdated;
        }
Exemple #3
0
 public void OnClickUpdate()//刷新按钮
 {
     for (int i = 0; i < itemMarketNum; i++)
     {
         int        id   = Random.Range(1, dataList.Count);
         GameObject item = itemMarketContent.GetChild(i).gameObject;
         ItemMarket it   = item.GetComponent <ItemMarket>();
         it.SetID(dataList[id].ID);
     }
 }
 private bool IsUniqueItem(Item item)
 {
     foreach (string name in ItemMarket.GetUniqueItemNames())
     {
         if (item.Name.Contains(name))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
    void RandomCreate()                                                        //随机生成5个物品
    {
        GameObject prefab = (GameObject)Resources.Load("Prefab/Image_Market"); //预设只需要加载一次,之后的5次都用它来渲染

        if (prefab == null)
        {
            Debug.Log("没加商品滑块预设");
            return;
        }

        for (int i = 0; i < itemMarketNum; i++)
        {
            int        id        = Random.Range(1, dataList.Count); //根据物品数量随机生成一个物品
            GameObject objMarket = Instantiate(prefab);             //克隆
            objMarket.transform.parent = itemMarketContent;
            ItemMarket item = objMarket.GetComponent <ItemMarket>();
            item.SetID(dataList[id].ID);
        }
    }
Exemple #6
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Lembrando que os itens na loja tem que estar na mesma ordem que os upgrades do player");
        for (int i = 0; i < items.Length; i++)
        {
            GameObject     g  = Instantiate(items[i], itemSpots[i].position, itemSpots[i].rotation);
            SpriteRenderer s  = g.GetComponent <SpriteRenderer>();
            ItemMarket     im = g.GetComponent <ItemMarket>();
            if (um.HasUpgrade(i))
            {
                im.price = 0;
                s.color  = new Color(s.color.r, s.color.g, s.color.b, .5f);
            }

            if (Money.value < im.price)
            {
                g.GetComponent <Collider2D>().enabled = false;
                //im.enabled = false;
            }
        }
    }
Exemple #7
0
        private CommonItem CreateCommonItemExt(IItem iItem, string itemId,
                                               IEnumerable <BaseResorcedRequirement> craftingRequirements, int enchant, int qualityLevel,
                                               ItemMarket itemMarket, int enchantIp = 0)
        {
            //            BaseResorcedRequirement[] crs = (iItem.shopcategory == shopCategory.token) ? _empty : craftingRequirements.ToArray();

            var crs =
                //нет трансмута цветных камней
                (iItem.shopsubcategory1 == Enums.shopSubCategory.rock && enchant > 0)
             ? new BaseResorcedRequirement[0]
             : craftingRequirements.ToArray();

            var item = new CommonItem(crs, itemMarket,
                                      BuildingByItem(iItem.uniquename),
                                      qualityLevel,
                                      _buyTownManager,
                                      _sellTownManager
                                      )
            {
#if DEBUG
                Debug = iItem,
#endif
                MemId           = _memCounter++,
                Id              = itemId,
                Name            = Localization.TryGetValue("@ITEMS_" + iItem.uniquename, out var name) ? name : itemId,
                Tir             = iItem.tier,
                Enchant         = enchant,
                ShopCategory    = (ShopCategory)iItem.shopcategory,
                ShopSubCategory = (ShopSubCategory)iItem.shopsubcategory1,
                IsSalvageable   = (iItem as IItemSalvageable)?.salvageable ?? false,
                ItemValue       = GetItemValue(iItem, crs),
                ItemFame        = GetItemFame(iItem, crs),
                ItemPower       = enchantIp > 0
                    ? enchantIp
                    : (iItem as IItemPowered)?.itempower ?? (iItem as IItemPowered2)?.dummyitempower ?? 0
            };

            if (item.ItemPower > 0 && qualityLevel > 1)
            {
                item.ItemPower += _qualityLevelItemPower[qualityLevel - 2];
            }

            item.IsCraftable = //iItem.unlockedtocraft &&
                               !(itemId.Contains("_CAPEITEM_") && itemId.EndsWith("_BP") &&
                                 item.CraftingBuilding == NoneBuilding) &&
                               item.CraftingRequirements.Length > 0;
            //            item.IsCraftable = item.CraftingBuilding != NoneBuilding || item.CraftingRequirements.Length > 0 && (item.CraftingRequirements[0] as CraftingRequirement)?.Silver > 0;
            //                               || item.ShopCategory == ShopCategory.Artefacts;

            item.Init();

            if (iItem is ItemsJournalitem journalitem)
            {
                AddJournal(journalitem, item);
            }

            Items.Add(item.Id + (qualityLevel > 1 ? $"_{qualityLevel}" : ""), item);

            //            if (iItem.shopcategory == shopCategory.token && iItem.unlockedtocraft) Debug.WriteLine("tk");

            return(item);
        }