public void OnHarvestSuccess() { onHarvestFinish?.Invoke(); HarvestAble = false; if (currentStage.ProductItems.Count > 0) { List <ItemInfo> lootItems = new List <ItemInfo>(); foreach (DropItemInfo di in currentStage.ProductItems) { if (ZetanUtility.Probability(di.DropRate)) { if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID))) { lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1))); } } } if (lootItems.Count > 0) { LootAgent la = ObjectPool.Get(currentStage.LootPrefab).GetComponent <LootAgent>(); la.Init(lootItems, transform.position); } } HarvestDone(); }
public static List <ItemWithAmount> Drop(IEnumerable <DropItemInfo> DropItems) { List <ItemWithAmount> lootItems = new List <ItemWithAmount>(); Dictionary <string, ItemWithAmount> map = new Dictionary <string, ItemWithAmount>(); foreach (DropItemInfo di in DropItems) { if (ZetanUtility.Probability(di.DropRate)) { if (!di.OnlyDropForQuest || QuestManager.Instance.HasOngoingQuest(di.BindedQuest.ID)) { if (di.item.StackAble) { if (map.TryGetValue(di.ItemID, out var find)) { find.amount += Random.Range(di.MinAmount, di.MaxAmount + 1); } else { var iaw = new ItemWithAmount(di.item.CreateData(), Random.Range(di.MinAmount, di.MaxAmount + 1)); map.Add(di.ItemID, iaw); lootItems.Add(iaw); } } else { lootItems.Add(new ItemWithAmount(di.item.CreateData(), Random.Range(di.MinAmount, di.MaxAmount + 1))); } } } } return(lootItems); }
public void Death() { //Debug.Log("One [" + info.Name + "] was killed"); OnDeathEvent?.Invoke(); QuestManager.Instance.UpdateUI(); if (info.DropItems.Count > 0) { List <ItemInfo> lootItems = new List <ItemInfo>(); foreach (DropItemInfo di in info.DropItems) { if (ZetanUtility.Probability(di.DropRate)) { if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID))) { lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1))); } } } if (lootItems.Count > 0) { LootAgent la = ObjectPool.Get(info.LootPrefab).GetComponent <LootAgent>(); la.Init(lootItems, transform.position); } } }
public virtual void GatherSuccess() { onGatherFinish?.Invoke(); GetComponent <Renderer>().enabled = false; GatherAble = false; if (GatheringInfo.ProductItems.Count > 0) { List <ItemInfo> lootItems = new List <ItemInfo>(); foreach (DropItemInfo di in GatheringInfo.ProductItems) { if (ZetanUtility.Probability(di.DropRate)) { if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID))) { lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1))); } } } if (lootItems.Count > 0) { LootAgent la = ObjectPool.Get(GatheringInfo.LootPrefab).GetComponent <LootAgent>(); la.Init(lootItems, transform.position); } } StartCoroutine(UpdateTime()); }