Esempio n. 1
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]);
            }
        }
    }
Esempio n. 2
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);
    }