コード例 #1
0
    public void SetEquipTipInfo(EquipmentInfo _info, int _depath, List <GameObject> _list)
    {
        if (batchUseGo != null)
        {
            batchUseGo.GetComponent <UIPanel>().depth = _depath + 1;
        }
        if (nameLabel != null)
        {
            nameLabel.text = _info.ItemName;
        }
        if (item != null)
        {
            item.FillInfo(_info);
        }
        if (btnName != null)
        {
            if (_info.IsEquip || _info.Family == EquipmentFamily.MOUNTEQUIP)
            {
                btnName.text = ConfigMng.Instance.GetUItext(301);
            }
            else
            {
                btnName.text = ConfigMng.Instance.GetUItext(302);
            }
        }
        if (btnClose != null)
        {
            UIEventListener.Get(btnClose.gameObject).onClick = delegate
            {
                isClose = true;
                if (EquipTip.Contains(_info))
                {
                    EquipTip.Remove(_info);
                }
                _list.Remove(this.gameObject);
                //DestroyImmediate(this.gameObject);
            }
        }
        ;
        if (clickBtn != null)
        {
            UIEventListener.Get(clickBtn.gameObject).onClick = delegate
            {
                if (_info.Slot != EquipSlot.None)
                {
                    _info.DoItemAction(ItemActionType.NormalLeft);
                }
                else
                {
                    _info.TryToUseAll();//直接批量使用不弹数量选择界面了
                }
                if (EquipTip.Contains(_info))
                {
                    EquipTip.Remove(_info);
                }
                _list.Remove(this.gameObject);
                if (_info.CanUseBatch && _info.StackCurCount > 1)
                {
                    TreasureHouseWnd wnd = GameCenter.uIMng.GetGui <TreasureHouseWnd>();
                    if (wnd != null)
                    {
                        DestroyImmediate(this.gameObject);
                    }
                    else
                    //OpenBatchUseWnd(_info);
                    {
                        DestroyImmediate(this.gameObject);
                        GameCenter.inventoryMng.CurSelectInventory = _info;
                        //GameCenter.uIMng.GenGUI(GUIType.IMMEDIATEUSE,true);
                        GameCenter.inventoryMng.C2S_UseItems(_info, _info.StackCurCount);//直接全部使用
                    }
                }
                else
                {
                    isClose = true;
                }
                //DestroyImmediate(this.gameObject);
            }
        }
        ;
    }

    /// <summary>
    /// 批量使用物品
    /// </summary>
    /// <param name="_eq"></param>
    void OpenBatchUseWnd(EquipmentInfo _eq)
    {
        int useNum = 0;

        batchUseNum.value = "1";
        if (batchUseGo != null && btnBatchUse != null && batchUseNum != null && int.TryParse(batchUseNum.value, out useNum))
        {
            batchUseGo.SetActive(true);
            UIEventListener.Get(btnBatchUse.gameObject).onClick = (x) =>
            {
                if (int.TryParse(batchUseNum.value, out useNum) && useNum > _eq.StackCurCount)
                {
                    GameCenter.messageMng.AddClientMsg(ConfigMng.Instance.GetUItext(293));
                    return;
                }
                GameCenter.inventoryMng.C2S_UseItems(_eq, useNum);
                batchUseGo.SetActive(false);
                DestroyImmediate(this.gameObject);
            };
        }
        if (batchUseItem != null)
        {
            batchUseItem.FillInfo(_eq);
        }
        if (labDes != null)
        {
            labDes.text = _eq.Description.Replace("\\n", "\n");
        }
        if (btnAdd != null && batchUseNum != null && int.TryParse(batchUseNum.value, out useNum))
        {
            UIEventListener.Get(btnAdd.gameObject).onClick = (x) =>
            {
                if (useNum < _eq.StackCurCount)
                {
                    batchUseNum.value = (++useNum).ToString();
                }
            };
        }

        if (btnReduce != null && batchUseNum != null && int.TryParse(batchUseNum.value, out useNum))
        {
            UIEventListener.Get(btnReduce.gameObject).onClick = (x) =>
            {
                if (useNum > 0)
                {
                    batchUseNum.value = (--useNum).ToString();
                }
            };
        }
        if (btnMaxNum != null && batchUseNum != null)
        {
            UIEventListener.Get(btnMaxNum.gameObject).onClick = (x) =>
            {
                if (batchUseNum != null)
                {
                    batchUseNum.value = _eq.StackCurCount.ToString();
                }
                useNum = _eq.StackCurCount;
            }
        }
        ;
        if (closeBtn != null)
        {
            UIEventListener.Get(closeBtn.gameObject).onClick = delegate
            {
                DestroyImmediate(this.gameObject);
            }
        }
        ;
    }

    void Update()
    {
        if (isClose)
        {
            DestroyImmediate(this.gameObject);
            isClose = false;
        }
        //解决花车巡游开始前如果获得新物品,巡游中该提示一直存在
        if (GameCenter.mainPlayerMng.MainPlayerInfo.IsHide)
        {
            if (!isHide)
            {
                this.gameObject.SetActive(false);
                isHide = true;
            }
        }
    }
}
コード例 #2
0
    public void SetActionBtn(ItemActionType _left, ItemActionType _middle, ItemActionType _right, ItemActionType _other)
    {
        HideAllBtn();
        //		gamesBtn.Clear();
        if (curEquipInfo == null)
        {
            return;
        }

        string name = curEquipInfo.GetItemActionName(_left);

        if (name != string.Empty)
        {
            ShowButton(leftButton, leftButtonText, name, x1 =>
            {
                //				if(_left == ItemActionType.SelectAdd){
                //					InventoryUtility.TryToSelect(this.curEquipInfo);
                //				}else{
                //					curEquipInfo.DoItemAction(_left);
                //				}
                curEquipInfo.DoItemAction(_left);
                Close(leftButton.gameObject);
            });
        }
        name = curEquipInfo.GetItemActionName(_middle);
        if (name != string.Empty)
        {
            ShowButton(middleButton, middleButtonText, name, x2 =>
            {
//                              if(name == "强 化"){
//                                  InventoryUtility.Strengthen(this.curEquipInfo);
//                              }else{
//                                  if(_middle == ItemActionType.SelectAdd){
//                                      InventoryUtility.TryToSelect(this.curEquipInfo);
//                                  }else{
//                                      curEquipInfo.DoItemAction(_middle);
//                                  }
                curEquipInfo.DoItemAction(_middle);
                Close(middleButton.gameObject);
                //				}
            });
        }
        name = curEquipInfo.GetItemActionName(_right);
        if (name != string.Empty)
        {
            ShowButton(rightButton, rightButtonText, name, x3 =>
            {
                //				if(_right == ItemActionType.SelectAdd){
                //					InventoryUtility.TryToSelect(this.curEquipInfo);
                //				}else{
                //					curEquipInfo.DoItemAction(_right);
                //				}
                curEquipInfo.DoItemAction(_right);
                Close(rightButton.gameObject);
            });
        }
        name = curEquipInfo.GetItemActionName(_other);
        if (name != string.Empty)
        {
            ShowButton(accessButton, accessButtonText, name, x4 =>
            {
                //				if(_right == ItemActionType.SelectAdd){
                //					InventoryUtility.TryToSelect(this.curEquipInfo);
                //				}else{
                //					curEquipInfo.DoItemAction(_right);
                //				}
                curEquipInfo.DoItemAction(_other);
                Close(accessButton.gameObject);
            });
        }
    }