Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
    private void OnTake(ItemInfo item, int amount)
    {
        if (!LootAgent)
        {
            return;
        }
        if (!LootAgent.lootItems.Contains(item))
        {
            return;
        }
        int takeAmount = BackpackManager.Instance.TryGetItem_Integer(item, amount);

        if (BackpackManager.Instance.GetItem(item.item, takeAmount))
        {
            item.Amount -= takeAmount;
        }
        if (item.Amount < 1)
        {
            LootAgent.lootItems.Remove(item);
        }
        ItemAgent ia = GetItemAgentByInfo(item);

        if (ia)
        {
            ia.UpdateInfo();
        }
        if (LootAgent.lootItems.Count < 1)
        {
            LootAgent.Recycle();
            CloseWindow();
        }
    }
Ejemplo n.º 4
0
 public void TakeAll()
 {
     if (!LootAgent)
     {
         return;
     }
     foreach (ItemInfo item in LootAgent.lootItems)
     {
         int takeAmount = BackpackManager.Instance.TryGetItem_Integer(item);
         if (BackpackManager.Instance.GetItem(item.item, takeAmount))
         {
             item.Amount -= takeAmount;
         }
         ItemAgent ia = GetItemAgentByInfo(item);
         if (ia)
         {
             ia.UpdateInfo();
         }
     }
     LootAgent.lootItems.RemoveAll(x => x.Amount < 1);
     if (LootAgent.lootItems.Count < 1)
     {
         LootAgent.Recycle();
         CloseWindow();
     }
 }
Ejemplo n.º 5
0
 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());
 }
Ejemplo n.º 6
0
 public void CanPick(LootAgent lootAgent)
 {
     if (!lootAgent)
     {
         return;
     }
     LootAgent = lootAgent;
     UIManager.Instance.EnableInteract(true, LootAgent.name);
     PickAble = true;
 }
Ejemplo n.º 7
0
 public void Death()
 {
     //Debug.Log("One [" + info.Name + "] was killed");
     OnDeathEvent?.Invoke();
     if (info.DropItems && info.DropItems.IsValid)
     {
         var lootItems = info.DropItems.DoDrop();
         if (lootItems.Count > 0)
         {
             LootAgent la = ObjectPool.Get(info.LootPrefab).GetComponent <LootAgent>();
             la.Init(lootItems, transform.position);
         }
     }
 }