Beispiel #1
0
    /// <summary>
    /// grid 点击事件
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="data"></param>
    /// <param name="param"></param>
    private void OnGridUIEvent(UIEventType eventType, object data, object param)
    {
        if (eventType == UIEventType.Click)
        {
            UIShortcutItemGrid grid = data as UIShortcutItemGrid;
            if (grid == null)
            {
                return;
            }

            if (grid.item.itemid == 0)
            {
                GoToSettingPanel();// 跳转设置面板
            }
            else
            {
                //使用道具
                ShortCuts item = grid.item;

                List <BaseItem> itemList = DataManager.Manager <ItemManager>().GetItemByBaseId(item.itemid);

                if (itemList != null && itemList.Count > 0)
                {
                    DataManager.Manager <ItemManager>().Use(itemList[0].QWThisID);
                }
                else
                {
                    DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.GetWayPanel, data: item.itemid);
                }
            }

            if (grid.item.id >= m_fixItemCount)//点活动的item  面板要收
            {
                ClickShortcut();

                if (m_fixItemCount == m_allItemCount)
                {
                    return;
                }
                UIPlayTween playTween = m_btn_BtnArrow.GetComponent <UIPlayTween>();
                if (playTween != null)
                {
                    playTween.Play(true);
                }
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// 初始化grid数据
    /// </summary>
    void InitShortcutGrid()
    {
        m_fixItemCount = DataManager.Manager <SettingManager>().FixedShortcutItemCount;

        itemList = DataManager.Manager <SettingManager>().GetShortcutSetItemList();

        for (int i = 0; i < m_grid_FixedItemGridsRoot.transform.childCount; i++)
        {
            int index = m_grid_FixedItemGridsRoot.transform.childCount - i - 1;
            if (index >= 0 && index < m_grid_FixedItemGridsRoot.transform.childCount)
            {
                GameObject         gridGo = m_grid_FixedItemGridsRoot.transform.GetChild(index).gameObject;
                UIShortcutItemGrid grid   = gridGo.GetComponent <UIShortcutItemGrid>();
                if (grid == null)
                {
                    grid = gridGo.AddComponent <UIShortcutItemGrid>();
                }

                if (i < itemList.Count)
                {
                    grid.SetGridData(itemList[i]);
                    grid.RegisterUIEventDelegate(OnGridUIEvent);
                }
            }
        }

        for (int i = 0; i < m_grid_MovableItemGridsRoot.transform.childCount; i++)
        {
            int index = m_grid_MovableItemGridsRoot.transform.childCount - i - 1;
            if (index >= 0 && index < m_grid_MovableItemGridsRoot.transform.childCount)
            {
                GameObject         gridGo = m_grid_MovableItemGridsRoot.transform.GetChild(index).gameObject;
                UIShortcutItemGrid grid   = gridGo.GetComponent <UIShortcutItemGrid>();
                if (grid == null)
                {
                    grid = gridGo.AddComponent <UIShortcutItemGrid>();
                }

                if (m_fixItemCount + i < itemList.Count)
                {
                    grid.SetGridData(itemList[m_fixItemCount + i]);
                    grid.RegisterUIEventDelegate(OnGridUIEvent);
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 更新物品UI
    /// </summary>
    /// <param name="data">物品数据</param>
    private void OnUpdateItemDataUI(object data)
    {
        if (null == data || !(data is ItemDefine.UpdateItemPassData))
        {
            return;
        }
        ItemDefine.UpdateItemPassData passData = data as ItemDefine.UpdateItemPassData;
        uint qwThisId = passData.QWThisId;

        if (qwThisId == 0)
        {
            Engine.Utility.Log.Warning("->UpdateItemDataUI qwThisId 0!");
            return;
        }
        if (m_lstItemGo.Count == 0)
        {
            return;
        }

        if (itemList == null)
        {
            Engine.Utility.Log.Error("--->>> itemList 数据为null !");
            return;
        }

        ShortCuts item = itemList.Find((d) => { return(d.itemid == passData.BaseId); });

        if (item == null)
        {
            return;
        }

        for (int i = 0; i < m_lstItemGo.Count; i++)
        {
            UIShortcutItemGrid grid = m_lstItemGo[i].GetComponent <UIShortcutItemGrid>();
            if (grid != null)
            {
                if (grid.item.itemid == passData.BaseId)
                {
                    grid.SetGridData(item);
                }
            }
        }
    }