| | |
| | |
|
| | |
|
| | | // 通用显示获得的物品
|
| | | public void ShowGetItem(List<Item> items, string info = "", int seconds = 3, string btnName = "", Action func = null, bool isNameShow = true, string eventName = "default")
|
| | | public void ShowGetItem(List<Item> items, string eventName = "default", bool isNameShow = true)
|
| | | {
|
| | | if (getItemEventName != eventName)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | getItemInfo = info;
|
| | | OnGetItem = func;
|
| | | if (btnName == "")
|
| | | btnName = Language.Get("PopConfirmWin_OK");
|
| | | getItemBtnText = btnName;
|
| | | closeSeconds = seconds;
|
| | | this.isNameShow = isNameShow;
|
| | | OnGetItemShowEvent?.Invoke();
|
| | | if (!UIManager.Instance.IsOpenedInList<CommonGetItemWin>())
|
| | |
| | | getItemEventName = "";
|
| | | }
|
| | |
|
| | | |
| | | public void UseItem(string guid, int useCnt = 1, int extra = 0)
|
| | | {
|
| | | var item = packModel.GetItemByGuid(guid);
|
| | | if (item == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | var error = 0;
|
| | | if (CanUseItem(guid, useCnt, out error))
|
| | | {
|
| | | UseItemSendServer(guid, useCnt, extra);
|
| | | }
|
| | | else
|
| | | {
|
| | | switch (error)
|
| | | {
|
| | | case 1:
|
| | | SysNotifyMgr.Instance.ShowTip("EverydayUseLimit");
|
| | | break;
|
| | | case 2:
|
| | | SysNotifyMgr.Instance.ShowTip("UseCntLimit");
|
| | | break;
|
| | | case 3:
|
| | | SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_749572");
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public bool CanUseItem(string guid, int useCnt, out int error)
|
| | | {
|
| | | var item = packModel.GetItemByGuid(guid);
|
| | | if (item == null)
|
| | | {
|
| | | error = 999;
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | | if (item.config.Type == 145 && item.config.CDTime > 0)
|
| | | {
|
| | | var createTime = item.GetUseDataFirstValue((int)ItemUseDataKey.createTime);
|
| | | if (createTime > 0)
|
| | | {
|
| | | DateTime useTime;
|
| | | if (item.config.CDTypeEx == 1)
|
| | | {
|
| | | //itemConfig.CDTime 为天,过0点可用
|
| | | useTime = TimeUtility.GetTime((uint)createTime).AddDays(item.config.CDTime);
|
| | | useTime = TimeUtility.GetDayStartTime(useTime.Year, useTime.Month, useTime.Day);
|
| | | }
|
| | | else
|
| | | {
|
| | | useTime = TimeUtility.GetTime((uint)createTime).AddSeconds(item.config.CDTime);
|
| | | }
|
| | | if (TimeUtility.ServerNow < useTime)
|
| | | {
|
| | | error = 3;
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | var usedCountToday = packModel.GetItemUsedTimesToday(item.itemId);
|
| | | if (item.config.MaxSkillCnt > 0 && item.config.MaxSkillCnt <= usedCountToday)
|
| | | {
|
| | | error = 1;
|
| | | return false;
|
| | | }
|
| | |
|
| | | //var usedCountTotal = packModel.GetItemTotalUsedTimes(item.itemId);
|
| | | // var fruitConfig = AttrFruitConfig.Get(item.itemId);
|
| | | // if (fruitConfig != null)
|
| | | // {
|
| | | // var limitTimes = 0;
|
| | | // if (fruitConfig.FuncID == 2)
|
| | | // {
|
| | | // limitTimes = alchemyModel.GetAlchemyDrugUseLimit(item.itemId);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // limitTimes = fruitConfig.basicUseLimit;
|
| | | // }
|
| | | // if (usedCountTotal >= limitTimes || useCnt > limitTimes)
|
| | | // {
|
| | | // error = 1;
|
| | | // return false;
|
| | | // }
|
| | | // }
|
| | |
|
| | | error = 0;
|
| | | return true;
|
| | | }
|
| | |
|
| | | void UseItemSendServer(string guid, int useCnt, int extra)
|
| | | {
|
| | | var itemModel = packModel.GetItemByGuid(guid);
|
| | | if (itemModel == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | var useItem = new CA323_tagCMUseItems();
|
| | | useItem.ItemIndex = (byte)itemModel.gridIndex;
|
| | | useItem.UseCnt = (ushort)useCnt;
|
| | | useItem.ExData = (uint)extra;
|
| | | GameNetSystem.Instance.SendInfo(useItem); //使用物品
|
| | | }
|
| | |
|
| | | }
|