Beispiel #1
0
 private void OnUIEventCallback(UIEventType eventType, object data, object param)
 {
     switch (eventType)
     {
     case UIEventType.Click:
     {
         if (data is UIItemCommonGrid)
         {
             UIItemCommonGrid grid = data as UIItemCommonGrid;
             if (grid != null)
             {
                 if (m_currInputPanel != null)
                 {
                     //1 物品 2 坐骑 3 宠物
                     int type = 2;
                     if (m_CurrToggleEnum == ToggleEnum.Pet)
                     {
                         type = 3;
                     }
                     else if (m_CurrToggleEnum == ToggleEnum.Mount)
                     {
                         type = 2;
                     }
                     else if (m_CurrToggleEnum == ToggleEnum.Wear || m_CurrToggleEnum == ToggleEnum.Bag)
                     {
                         type = 1;
                     }
                     m_currInputPanel.AddLinkerItem(grid.Data.Name, grid.Data.ItemThisId, grid.Data.Qulity, type);
                 }
             }
         }
     }
     break;
     }
 }
Beispiel #2
0
 void OnSelectItem(UIItemCommonGrid grid)
 {
     m_trans_select.transform.parent        = grid.transform;
     m_trans_select.transform.localPosition = Vector3.zero;
     m_selectdata = grid.Data;
     m_trans_select.gameObject.SetActive(true);
     // TipsManager.Instance.ShowItemTips(grid.Data.ItemThisId, grid.gameObject, false);
 }
Beispiel #3
0
    private void OnUpdateGridData(UIGridBase grid, int index)
    {
        UIItemCommonGrid itemGrid = grid as UIItemCommonGrid;

        if (itemGrid != null)
        {
            if (m_lstUIItemCommondata != null && m_lstUIItemCommondata.Count > index && index >= 0)
            {
                itemGrid.SetGridData(m_lstUIItemCommondata[index]);
            }
        }
    }
Beispiel #4
0
    /// <summary>
    /// 金币经验类icon显示
    /// </summary>
    /// <param name="type"></param>
    /// <param name="num"></param>
    /// <returns></returns>
    public UIItem GetUIMoneyExpItem(ItemDefine.CommonItem type, uint num, bool showGetWay = true)
    {
        //货币的图集Icon跟枚举一致
        string keyStr = ((int)type).ToString();
        UIItem uiitem = GetUIItem(keyStr, num);

        if (!showGetWay)
        {
            UIItemCommonGrid grid = uiitem.GetGrid <UIItemCommonGrid>();
            grid.SetShowGetWay(showGetWay);
        }
        return(uiitem);
    }
Beispiel #5
0
    void GetWayCallBack(UIItemCommonGrid grid)
    {
        int itemCount = DataManager.Manager <ItemManager>().GetItemNumByBaseId(grid.Data.DwObjectId);

        if (0 == itemCount)
        {
            TipsManager.Instance.ShowItemTips(grid.Data.DwObjectId);
            DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: grid.Data.DwObjectId);
        }
        else
        {
            TipsManager.Instance.ShowItemTips(grid.Data.DwObjectId);
        }
    }
Beispiel #6
0
    void ShowGetWayCallBack(UIItemCommonGrid grid)
    {
        int itemCount = DataManager.Manager <ItemManager>().GetItemNumByBaseId(m_needItmeID);

        if (grid.Data.Num < grid.Data.NeedNum)
        {
            TipsManager.Instance.ShowItemTips(m_needItmeID);
            DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: grid.Data.DwObjectId);
        }
        else
        {
            TipsManager.Instance.ShowItemTips(m_needItmeID);
        }
    }
Beispiel #7
0
 void ShowGetWayCallBack(UIItemCommonGrid grid)
 {
     DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: grid.Data.DwObjectId);
 }
Beispiel #8
0
 void OnGetItem(UIItemCommonGrid grid)
 {
     DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: m_nUseItemId);
 }
Beispiel #9
0
    private UIItem GetUIItem(string spriteName, uint num, uint itemid = 0, uint itemThisId = 0, Action <UIItemCommonGrid> callback = null, Action <UIItemCommonGrid, bool> pressCallback = null, bool showGetWay = true)
    {
        UnityEngine.Object obj = UIManager.GetResGameObj(GridID.Uiitemcommongrid);
        if (obj == null)
        {
            Engine.Utility.Log.Error("Get GridID.Uiitemcommongrid failed");
            return(null);
        }

        GameObject       gridObj = GameObject.Instantiate(obj) as GameObject;
        UIItemCommonGrid grid    = gridObj.GetComponent <UIItemCommonGrid>();

        if (null == grid)
        {
            grid = gridObj.AddComponent <UIItemCommonGrid>();
        }

        uint qulity = 0;

        table.ItemDataBase db = GameTableManager.Instance.GetTableItem <table.ItemDataBase>(itemid);
        if (db != null)
        {
            qulity = db.quality;
        }
        grid.SetGridData(new ItemDefine.UIItemCommonData()
        {
            DwObjectId = itemid,
            IconName   = spriteName,
            Num        = num,
            ItemThisId = itemThisId,
            Qulity     = qulity,
            ShowGetWay = showGetWay,
        });

        if (itemid != 0)//非零显示tips
        {
            bool blongPress = false;
            grid.RegisterUIEventDelegate((UIEventType eventType, object data, object param) =>
            {
                UIItemCommonGrid uigrid = data as UIItemCommonGrid;
                switch (eventType)
                {
                case UIEventType.Click:
                    blongPress = false;

                    if (callback != null)
                    {
                        callback(uigrid);
                        return;
                    }

                    if (uigrid.Data.Num > 0)
                    {
                        if (uigrid.Data.ItemThisId > 0)
                        {
                            TipsManager.Instance.ShowItemTips(uigrid.Data.ItemThisId, uigrid.gameObject, false);
                        }
                        else
                        {
                            //策划说货币也要弹出Tips
//                                 if (uigrid.Data.DwObjectId == MainPlayerHelper.GoldID || uigrid.Data.DwObjectId == MainPlayerHelper.MoneyTicketID)
//                                 {
//                                     return;
//                                 }
                            TipsManager.Instance.ShowItemTips(uigrid.Data.DwObjectId, uigrid.gameObject, false);
                        }
                    }
                    else
                    {
                        PanelID panelId = UIFrameManager.Instance.CurrShowPanelID;
                        uint itemID     = uigrid.Data.DwObjectId;
                        if (DataManager.Manager <UIPanelManager>().IsShowPanel(panelId))
                        {
                            UIPanelBase panelBase = DataManager.Manager <UIPanelManager>().GetPanel(panelId);
                            UIPanelManager.LocalPanelInfo uidata = panelBase.PanelInfo;
                            //Client.UIPanelInfo uidata = panelBase.PanelShowInfo;
                            if (uidata != null && uidata.NeedBg)
                            {
                                DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: itemID);
                            }
                        }
                        else if (panelId == PanelID.None)
                        {
                            DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: itemID);
                        }
                    }
                    break;

                case UIEventType.LongPress:
                    blongPress = true;
                    if (pressCallback != null)
                    {
                        pressCallback(uigrid, blongPress);
                        return;
                    }
                    if (grid.Data.ItemThisId > 0)
                    {
                        TipsManager.Instance.ShowItemTips(grid.Data.ItemThisId, grid.gameObject, false);
                    }
                    else
                    {
                        TipsManager.Instance.ShowItemTips(uigrid.Data.DwObjectId, uigrid.gameObject, false);
                    }
                    break;

                case UIEventType.Press:
                    bool press = (bool)param;
                    if (!press && blongPress)
                    {
                        blongPress = false;
                        if (pressCallback != null)
                        {
                            pressCallback(uigrid, blongPress);
                            return;
                        }
                        DataManager.Manager <UIPanelManager>().HidePanel(PanelID.ItemTipsPanel);
                    }
                    break;
                }
            });
        }

        UIItem item = new UIItem(grid);

        return(item);
    }