public static ItemInfo GetItemInfoFromTooltipParams(this ItemInfoBase itemInfoBase, D3ApiClient d3ApiClient) { if (itemInfoBase == null) { throw new ArgumentNullException(nameof(itemInfoBase)); } if (d3ApiClient == null) { throw new ArgumentNullException(nameof(d3ApiClient)); } if (string.IsNullOrWhiteSpace(itemInfoBase.TooltipParams)) { return(null); } var tooltipData = itemInfoBase.TooltipParams.Split(new [] { '/' }, 2); if (tooltipData.Length != 2) { return(null); } if (tooltipData[0] != "item") { return(null); } return(d3ApiClient.GetDataItemInfo(tooltipData[1])); }
public MapRewardInfo(XmlNode node, pe_Difficulty difficulty = pe_Difficulty.Normal) { string id = node.Attributes["id"].Value; Reward = ItemInfoManager.Instance.GetInfoByID(id); Difficulty = difficulty; var showAttr = node.Attributes["show"]; if (showAttr != null) { IsShow = bool.Parse(showAttr.Value); } switch (Reward.ItemType) { case eItemType.Stuff: case eItemType.Item: Percent = short.Parse(node.Attributes["percent"].Value); break; default: Value = int.Parse(node.Attributes["value"].Value); break; } if (Reward == null) { throw new System.Exception(string.Format("not exist item id in MapRewardInfo : {0}", id)); } }
public void InitStoreItem(pd_StoreItem item) { switch (item.item_type) { case pe_StoreItemType.Item: case pe_StoreItemType.Stuff: case pe_StoreItemType.Rune: case pe_StoreItemType.Token: Clear(); Info = ItemInfoManager.Instance.GetInfoByIdn(item.item_idn); InitIcon(true); break; case pe_StoreItemType.SoulStone: Clear(); Info = ItemInfoManager.Instance.GetInfoByIdn(item.item_idn); InitSoulStoneInternal((Info as SoulStoneInfo), item.item_count); return; case pe_StoreItemType.Creature: m_RewardCreature = CreatureInfoManager.Instance.GetInfoByIdn(item.item_idn); InitCreature(m_RewardCreature, item.item_count); return; } m_count.text = item.item_count.ToString(); m_count.gameObject.SetActive(true); }
public void Init(Item item) { Clear(); Info = item.Info; InitIcon(false); m_icon.gameObject.SetActive(item.Count > 0); m_IconGray.gameObject.SetActive(item.Count <= 0); if (item.StuffInfo.PieceCountMax > 1) { if (item.Count > 0) { m_count.text = item.Count.ToString(); m_count.gameObject.SetActive(true); m_count.color = Color.white; } else { m_count.text = string.Format("[FF0000]{0}[-]/{1}", item.PieceCount, item.StuffInfo.PieceCountMax); m_count.gameObject.SetActive(true); m_count.color = Color.white; } } else { m_count.text = item.Count.ToString(); m_count.gameObject.SetActive(true); m_count.color = item.Count == 0 ? Color.red : Color.white; } }
public void PutMaterials(IEnumerable <ItemInfoBase> materials) { if (IsBuilt) { return; } foreach (var material in materials) { if (material.item.StackAble) { ItemInfoBase find = materialsStored.Find(x => x.ItemID == material.ItemID); if (find) { find.Amount += material.Amount; } else { materialsStored.Add(new ItemInfoBase(material.item, material.Amount)); } } else { materialsStored.Add(new ItemInfoBase(material.item)); } } if (Info.AutoBuild && !IsBuilding) { if (IsMaterialsEnough(currentStage.Materials)) { StartConstruct(); } } }
public void InitRune(Rune rune) { Clear(); Info = rune.Info; InitIcon(false); m_level.gameObject.SetActive(true); m_level.text = Localization.Format("HeroLevel", rune.Level); }
void InitSoulStoneInternal(SoulStoneInfo soulstone_info, int count) { Info = soulstone_info; InitCreatureInternal(soulstone_info.Creature, soulstone_info.Grade); m_Puzzle.SetActive(true); m_count.text = count.ToString(); m_count.gameObject.SetActive(true); }
void Clear() { Info = null; m_RewardCreature = null; m_creature.SetActive(false); for (int i = 0; i < m_contents.childCount; ++i) { m_contents.GetChild(i).gameObject.SetActive(false); } System.Array.ForEach(m_Notifies, e => e.SetActive(false)); }
public int GetAmountCanMake(IEnumerable <MaterialInfo> targetMaterials, IEnumerable <ItemInfoBase> givenMaterials) { if (!Inventory || givenMaterials == null || givenMaterials.Count() < 1 || targetMaterials == null || targetMaterials.Count() < 1 || targetMaterials.Count() != givenMaterials.Count()) { return(0); } List <int> amounts = new List <int>(); foreach (var material in targetMaterials) { if (material.MakingType == MakingType.SingleItem) { ItemInfoBase find = givenMaterials.FirstOrDefault(x => x.ItemID == material.ItemID); if (!find) { return(0); //所提供的材料中没有这种材料 } if (find.Amount != material.Amount) { return(0); //若材料数量不符合,则无法制作 } amounts.Add(GetAmount(find.ItemID) / material.Amount); } else { var finds = givenMaterials.Where(x => x.item.MaterialType == material.MaterialType);//找到种类相同的道具 if (finds.Count() > 0) { if (finds.Select(x => x.Amount).Sum() != material.Amount) { return(0); //若材料总数不符合,则无法制作 } foreach (var find in finds) { int amount = GetAmount(find.ItemID); if (QuestManager.Instance.HasQuestRequiredItem(find.item, GetAmount(find.item) - find.Amount)) { return(0);//若任意一个相应数量的材料无法失去,则会导致总数量不符合,所以无法制作 } amounts.Add(amount / find.Amount); } } else { return(0);//材料不足 } } } return(amounts.Min()); }
public bool IsMaterialsEnough(IEnumerable <MaterialInfo> targetMaterials, IEnumerable <ItemInfoBase> givenMaterials) { if (!Inventory || targetMaterials == null || targetMaterials.Count() < 1 || givenMaterials == null || givenMaterials.Count() < 1 || targetMaterials.Count() != givenMaterials.Count()) { return(false); } foreach (var material in targetMaterials) { if (material.MakingType == MakingType.SingleItem) { ItemInfoBase find = givenMaterials.FirstOrDefault(x => x.ItemID == material.ItemID); if (!find) { return(false); //所提供的材料中没有这种材料 } if (find.Amount != material.Amount) { return(false); //若材料数量不符合,则无法制作 } else if (GetAmount(find.ItemID) < material.Amount) { return(false); //背包中材料数量不足 } } else { var finds = givenMaterials.Where(x => x.item.MaterialType == material.MaterialType);//找到种类相同的道具 if (finds.Count() > 0) { if (finds.Select(x => x.Amount).Sum() != material.Amount) { return(false); //若材料总数不符合,则无法制作 } foreach (var find in finds) { if (GetAmount(find.item) < find.Amount || QuestManager.Instance.HasQuestRequiredItem(find.item, GetAmount(find.item) - find.Amount)) { return(false); }//若任意一个相应数量的材料无法失去(包括数量不足),则会导致总数量不符合,所以无法制作 } } else { return(false);//材料不足 } } } return(true); }
public void InitReward(int idn, int count) { Clear(); Info = ItemInfoManager.Instance.GetInfoByIdn(idn); InitInternal(count); EventParamItemMade itemMade = ItemManager.Instance.ItemMadeList.Find(e => e.item.Info.IDN == idn); m_Notifies[0].SetActive(itemMade != null); var item = ItemManager.Instance.GetItemByIdn(idn); m_Notifies[2].SetActive(item != null && item.Notify); }
private bool IsMaterialsEnough(IEnumerable <MaterialInfo> targetMaterials) { foreach (var material in targetMaterials) { if (targetMaterials == null || materialsStored == null || materialsStored.Count < 1) { return(false); } if (material.MakingType == MakingType.SingleItem) { if (material.Item.StackAble) { ItemInfoBase find = materialsStored.Find(x => x.ItemID == material.ItemID); if (!find) { return(false); //所提供的材料中没有这种材料 } if (find.Amount < material.Amount) { return(false); //若材料数量不足,则无法制作 } } else if (materialsStored.FindAll(x => x.ItemID == material.ItemID).Count < material.Amount) { return(false); } } else { var finds = materialsStored.Where(x => x.item.MaterialType == material.MaterialType);//找到种类相同的道具 if (finds.Count() > 0) { if (finds.Select(x => x.Amount).Sum() < material.Amount) { return(false); //若材料总数不足,则无法制作 } } else { return(false);//材料不足 } } } return(true); }
public RewardBase(int reward_idn, int value, int value2 = 0, int value3 = 0) { if (ItemInfoManager.Instance.ContainsIdn(reward_idn)) { ItemInfo = ItemInfoManager.Instance.GetInfoByIdn(reward_idn); } else if (CreatureInfoManager.Instance.ContainsIdn(reward_idn) == true) { CreatureInfo = CreatureInfoManager.Instance.GetInfoByIdn(reward_idn); } if (ItemInfo == null && CreatureInfo == null) { throw new System.Exception(string.Format("invalid reward idn : {0}", reward_idn)); } this.Value = value; Value2 = value2; Value3 = value3; }
public RewardBase(XmlNode node) { string id = node.Attributes["id"].Value; if (ItemInfoManager.Instance.ContainsKey(id)) { ItemInfo = ItemInfoManager.Instance.GetInfoByID(id); } else if (CreatureInfoManager.Instance.ContainsKey(id) == true) { CreatureInfo = CreatureInfoManager.Instance.GetInfoByID(id); } if (ItemInfo == null && CreatureInfo == null) { throw new System.Exception(string.Format("invalid reward id : {0}", id)); } Value = int.Parse(node.Attributes["value"].Value); XmlAttribute value2_attr = node.Attributes["value2"]; if (value2_attr != null) { Value2 = int.Parse(value2_attr.Value); } else { Value2 = 0; } XmlAttribute value3_attr = node.Attributes["value3"]; if (value3_attr != null) { Value3 = int.Parse(value3_attr.Value); } else { Value3 = 0; } }
private void CostMaterials(IEnumerable <MaterialInfo> targetMaterials) { foreach (var material in targetMaterials) { if (material.MakingType == MakingType.SingleItem) { if (material.Item.StackAble) { ItemInfoBase find = materialsStored.Find(x => x.ItemID == material.ItemID); if (find) { find.Amount -= material.Amount; } } else { int amount = material.Amount; var finds = materialsStored.FindAll(x => x.ItemID == material.ItemID); if (finds.Count >= amount) { while (amount > 0) { materialsStored.Remove(finds[0]); finds.RemoveAt(0); amount--; } } } } else { var finds = materialsStored.Where(x => x.item.MaterialType == material.MaterialType);//找到种类相同的道具 if (finds.Count() > 0) { } } } }
public void InitReward(string id, int count) { Clear(); if (id.StartsWith("token_") == true) { Info = TokenInfoManager.Instance.GetInfoByID(id); InitInternal(count); } else if (id.StartsWith("icon_gacha_")) { gameObject.SetActive(true); m_StuffGrade.SetActive(true); m_icon.gameObject.SetActive(true); m_icon.spriteName = id; m_LabelGrade.gameObject.SetActive(true); m_LabelGrade.text = count.ToString(); gameObject.SetActive(true); } }
public List <string> GetMaterialsInfoString(IEnumerable <MaterialInfo> materials) { List <string> info = new List <string>(); using (var materialEnum = materials.GetEnumerator()) while (materialEnum.MoveNext()) { if (materialEnum.Current.MakingType == MakingType.SingleItem) { int amount = 0; if (materialEnum.Current.Item.StackAble) { ItemInfoBase find = materialsStored.Find(x => x.ItemID == materialEnum.Current.ItemID); if (find) { amount = find.Amount; } } else { amount = materialsStored.FindAll(x => x.ItemID == materialEnum.Current.ItemID).Count(); } info.Add($"{materialEnum.Current.ItemName}\t[{amount}/{materialEnum.Current.Amount}]"); } else { var finds = materialsStored.FindAll(x => x.item.MaterialType == materialEnum.Current.MaterialType); int amount = 0; foreach (var item in finds) { amount += item.Amount; } info.Add($"{materialEnum.Current.ItemName}\t[{amount}/{materialEnum.Current.Amount}]"); } } return(info); }
void OnClickItem(ItemInfoBase info) { Popup.Instance.Show(ePopupMode.Stuff, info); }
public Item(ItemInfoBase info) { Info = info; Notify = false; }
public ItemWithAmount(ItemInfoBase info) : this(info.item, info.Amount) { }
void OnClickItem(ItemInfoBase info) { OnClick(); }
public void ShowItemMade(ItemInfoBase item_info) { ShowTooltip(eTooltipMode.IconMessage, item_info.IconID, Localization.Format("MadeItem", item_info.Name)); }