예제 #1
0
 /// <summary>
 /// 获取不显示在背包的物品
 /// </summary>
 /// <param name="info"></param>
 private void GetHideItem(ItemInfo info)
 {
     //面具碎片和钥匙
     if (hideList.Any(x => x.id == info.id))
     {
         hideList.Find(x => x.id == info.id).num++;
     }
     else
     {
         hideList.Add(info);
     }
     if (info.id != 62)
     {
         UIMgr.Instance.CommonHint(info);
     }
     else
     {
         int num = GameDataMgr.Instance.playerInfo.hideList.Find(x => x.id == 62).num;
         UIMgr.Instance.ShowPanel <BasePanel>("MaskHintPanel", E_UI_Layer.top, (o) =>
         {
             o.GetComponent <MaskHintPanel>().TurnOnAnim(num);
             //if (num >= 4)
             //{
             //    GameDataMgr.Instance.playerInfo.hideList.Find(x => x.id == 62).num -= 4;
             //    MaxHp++;
             //    HP++;
             //    GameDataMgr.Instance.SavePlayerInfo();
             //}
         });
     }
     //给任务用的检查委托
     OnGetItemEvent?.Invoke(info.id, 1);
 }
예제 #2
0
 /// <summary>
 /// 仓库、装备专用获取道具
 /// </summary>
 /// <param name="info">道具信息</param>
 /// <param name="amount">获取数量</param>
 /// <param name="simulLoseItems">会同时失去的道具</param>
 /// <returns>是否成功</returns>
 public bool GetItem(ItemInfo info, int amount, params ItemInfo[] simulLoseItems)//仓库、装备专用
 {
     if (Backpack == null || info == null || !info.item || amount < 1)
     {
         return(false);
     }
     if (!TryGetItem_Boolean(info, amount, simulLoseItems))
     {
         return(false);
     }
     if (simulLoseItems != null)
     {
         foreach (var si in simulLoseItems)
         {
             LoseItem(si.item, si.Amount);
         }
     }
     if (info.item.StackAble)
     {
         Backpack.GetItemSimple(info, amount);
         ItemAgent ia = itemAgents.Find(x => !x.IsEmpty && (x.MItemInfo.item == info.item || x.MItemInfo.ItemID == info.ItemID));
         if (ia)
         {
             ia.UpdateInfo();
         }
         else//如果找不到,说明该物品是新的,原来背包里没有的
         {
             ia = itemAgents.Find(x => x.IsEmpty);
             if (ia)
             {
                 ia.SetItem(Backpack.LatestInfo);
             }
             else
             {
                 MessageManager.Instance.New("发生内部错误!");
                 Debug.Log("[Get Item Error: Can't find ItemAgent] ID: " + info.item.ID + "[" + System.DateTime.Now.ToString() + "]");
             }
         }
     }
     else
     {
         for (int i = 0; i < amount; i++)
         {
             Backpack.GetItemSimple(info);
             foreach (ItemAgent ia in itemAgents)
             {
                 if (ia.IsEmpty)
                 {
                     ia.SetItem(Backpack.LatestInfo);
                     break;
                 }
             }
         }
     }
     OnGetItemEvent?.Invoke(info.ItemID, amount);
     UpdateUI();
     return(true);
 }
예제 #3
0
 public void WhenGetItem(string id)
 {
     OnGetItemEvent?.Invoke(id, SDDataManager.Instance.GetItemAmount(id));
 }