public void OpenUsePop(ItemView v) { if (MainUI.Instance.GetPopState(MainUI.PopType.BagUse) != true) { GameObject obj = Instantiate(pop.usePrefab); obj.SetActive(true); usePop = obj.GetComponent <BagUsePop>(); usePop.InitData(v.data); usePop.transform.parent = pop.transform.parent; usePop.transform.localScale = Vector3.one; MainUI.Instance.SetPopState(MainUI.PopType.BagUse, true); } }
public void UseItemCallBack(C2sSprotoType.use_prop.response resp) { pop.useBtn.isEnabled = true; if (curCallBackView != null && resp.errorcode == 1) { if (resp.errorcode == 3) { print("不能使用"); return; } List <ItemViewData> addl = new List <ItemViewData>(); //改变背包内道具 if (resp.props.Count > 0) { for (int i = 0; i < resp.props.Count; i++) { ItemViewData add = null; //Debug.Log("csv_id" + resp.props[i].csv_id + "num" + resp.props[i].num); if (itemTable.ContainsKey((int)resp.props[i].csv_id)) { ItemViewData v = itemTable[(int)resp.props[i].csv_id]; if (resp.props[i].csv_id < 5)//加金币 经验 { switch (resp.props[i].csv_id) { case 1: UserManager.Instance.SetDiamond((int)resp.props[i].num); break; case 2: UserManager.Instance.SetGold((int)resp.props[i].num); break; case 3: UserManager.Instance.SetExp((int)resp.props[i].num); break; case 4: UserManager.Instance.SetFriendPoint((int)resp.props[i].num); break; case 6: UserManager.Instance.SetHonor((int)resp.props[i].num); break; } if (v.curCount < resp.props[i].num) { add = new ItemViewData(); add.curCount = (int)resp.props[i].num - v.curCount; add.data = GameShared.Instance.GetItemData((int)resp.props[i].csv_id); addl.Add(add); } } else if (v != null)//原来就有道具 { //获得增加多少道具 if (v.curCount < resp.props[i].num) { add = new ItemViewData(); add.curCount = (int)resp.props[i].num - v.curCount; add.data = v.data; addl.Add(add); } if ((int)resp.props[i].num < 1) { RemoveItem(v.view); } else if (v.view != null) { v.view.SetCount((int)resp.props[i].num); } } } else//新增道具 { ItemViewData d = InitItemViewData((int)resp.props[i].csv_id, (int)resp.props[i].num); if (d.curCount > 0 && d.data.id != null) { itemTable.Add(d.data.id, d); } pop.AddItem(d); //获得增加多少道具 add = new ItemViewData(); add.curCount = (int)resp.props[i].num; add.data = d.data; addl.Add(add); } } } //是否用完 设置描述 Debug.Log("csv_id" + resp.props[0].csv_id + "num" + resp.props[0].num); if (resp.props[0].num > 0) { pop.SetCount((int)resp.props[0].num); } else { //变到第一个 SelectItem(GetTableChild(0)); } curCallBackView = null; pop.useBtn.isEnabled = true; if (usePop != null) { usePop.CloseClick(); usePop = null; } MainUI.Instance.GetItemClick(addl); if (addl.Count == 0) { Debug.Log("null"); } } }