Exemplo n.º 1
0
    /// <summary>
    /// 缓存非常之引导
    /// </summary>
    /// <param name="grid"></param>
    private void CacheUnconstrainGrid(uint guideID)
    {
        UIUnconstraintGrid guideGrid = null;

        if (!TryGetUnconstrainGuide(guideID, out guideGrid))
        {
            return;
        }
        m_dic_showGuide.Remove(guideID);
        guideGrid.Release();
        if (guideGrid.Visible)
        {
            guideGrid.SetVisible(false);
        }
        if (!m_lst_cacheGuideGrid.Contains(guideGrid))
        {
            m_lst_cacheGuideGrid.Add(guideGrid);
        }
        if (m_lst_cacheGuideGrid.Count > CACHE_MAX_UNCONSTRAIN_NUM)
        {
            int needDestoryNum          = m_lst_cacheGuideGrid.Count - CACHE_MAX_UNCONSTRAIN_NUM;
            UIUnconstraintGrid tempGrid = null;
            for (int i = 0; i < needDestoryNum; i++)
            {
                tempGrid = m_lst_cacheGuideGrid[0];
                m_lst_cacheGuideGrid.RemoveAt(0);
                tempGrid.Destroy();
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 释放所有非强制引
    /// </summary>
    private void RelaseAllUnconstrainGrid()
    {
        List <uint> showGuideIDs = new List <uint>();

        showGuideIDs.AddRange(m_dic_showGuide.Keys);
        int max = showGuideIDs.Count;

        if (max > 0)
        {
            for (int i = 0; i < max; i++)
            {
                ResetGuide(showGuideIDs[i]);
            }
        }

        UIUnconstraintGrid grid = null;

        while (m_lst_cacheGuideGrid.Count > 0)
        {
            grid = m_lst_cacheGuideGrid[0];
            m_lst_cacheGuideGrid.RemoveAt(0);
            if (null != grid)
            {
                grid.Destroy();
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 获得一个非强制引导格子
    /// </summary>
    /// <returns></returns>
    private UIUnconstraintGrid GetUnconstrainGrid()
    {
        UIUnconstraintGrid grid = null;

        if (null != m_lst_cacheGuideGrid && m_lst_cacheGuideGrid.Count != 0)
        {
            grid = m_lst_cacheGuideGrid[0];
            m_lst_cacheGuideGrid.RemoveAt(0);
        }
        else if (null != m_trans_UnconstrainRoot && null != m_trans_UIUnconstraintGrid)
        {
            GameObject cloneObj = NGUITools.AddChild(m_trans_UnconstrainRoot.gameObject, m_trans_UIUnconstraintGrid.gameObject);
            if (null != cloneObj)
            {
                grid = cloneObj.AddComponent <UIUnconstraintGrid>();
                if (null != grid)
                {
                    grid.SetVisible(false);
                }
            }
        }
        return(grid);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 引导ID
    /// </summary>
    /// <param name="guideId"></param>
    private void ShowGuide(uint guideId)
    {
        GuideDefine.LocalGuideData localData = null;
        if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(guideId, out localData))
        {
            if (null == localData.GuideTargetObj)
            {
                return;
            }
            PanelType ptype = PanelType.SmartPopUp;
            UIPanelManager.LocalPanelInfo localInfo = null;
            if (DataManager.Manager <UIPanelManager>().TryGetLocalPanelInfo(localData.GuideTargetDependPanel, out localInfo))
            {
                ptype = localInfo.PType;
            }
            if (IsShowUnconstrainGuide(guideId))
            {
                //如果不可见重新获取当前面板深度
                UIUnconstraintGrid showGrid = m_dic_showGuide[guideId];
                if (!showGrid.Visible)
                {
                    showGrid.SetVisible(true);
                    GuideTrigger gTrigger = localData.GuideTargetObj.GetComponent <GuideTrigger>();
                    if (null != gTrigger && !gTrigger.enabled)
                    {
                        gTrigger.enabled = true;
                    }
                    int maxDepth = DataManager.Manager <UIPanelManager>().GetTargetRootMaxDepth(ptype);
                    showGrid.SetDepth(maxDepth + 1);
                    if (localData.RefreshPosInTime)
                    {
                        showGrid.RefreshPos();
                    }
                    showGrid.CheckTriggerData(guideId, GuideTriggerDlg);
                }
            }
            else
            {
                int maxDepth            = DataManager.Manager <UIPanelManager>().GetTargetRootMaxDepth(ptype);
                UIUnconstraintGrid grid = GetUnconstrainGrid();
                if (null != grid)
                {
                    grid.CacheTransform.gameObject.name = guideId.ToString();
                    m_dic_showGuide.Add(guideId, grid);
                }
                grid.SetData(maxDepth + 1, guideId, GuideTriggerDlg);

                if (localData.TableData.voiceID != 0)
                {
                    DataManager.Manager <UIManager>().PlayUIAudioEffect(localData.TableData.voiceID);
                }
            }


            GuideTriggerData gtData = localData.GuideTargetObj.GetComponent <GuideTriggerData>();
            if (null == gtData)
            {
                gtData = localData.GuideTargetObj.AddComponent <GuideTriggerData>();
            }
            if (null != gtData && !gtData.IsGuideTrigger)
            {
                gtData.IsGuideTrigger = true;
            }
        }
    }
Exemplo n.º 5
0
 public bool TryGetUnconstrainGuide(uint guideId, out UIUnconstraintGrid grid)
 {
     return(m_dic_showGuide.TryGetValue(guideId, out grid));
 }