Ejemplo n.º 1
0
    private void UpdateData()
    {
        // 超过最大显示个数则立即刪除前面的tips改为后续的
        if (tipsShowingCount > TipsShowMax)
        {
            tipsShowingCount--;
            if (tipsItemList.Count > 0)
            {
                TipsItem ui = tipsItemList[tipsItemList.Count - 1];
                tipsItemList.Remove(ui);
                Destroy(ui.gameObject);
            }
            if (tipsDataList.Count > 0)
            {
                tipsDataList.RemoveRange(0, 1);
            }
        }

        // 一次只产生一条toast
        if (tipsDataList.Count == 0)
        {
            return;
        }

        TipsData data = null;

        for (int i = 0; i < tipsDataList.Count; ++i)
        {
            data = tipsDataList[i];
            if (data != null && data.IsNew())
            {
                if (data.IsImportantNotice())
                {
                    // 判断是否有其他的flowleft在展示, 如果没有,则展示
                    bool has = false;
                    for (int j = 0; j < tipsDataList.Count; ++j)
                    {
                        if (tipsDataList[j].IsImportantNotice() && tipsDataList[j].IsShow())
                        {
                            has = true;
                            break;
                        }
                    }
                    if (!has)
                    {
                        MakeToast(data);
                        break;
                    }
                }
                else
                {
                    MakeToast(data);
                    break;
                }
            }
        }
    }
Ejemplo n.º 2
0
        public void ShowText(int id)
        {
            TipsItem tipsItem = Global.gApp.gGameData.TipsData.Get(id);

            if (tipsItem != null)
            {
                ShowText(Global.gApp.gGameData.GetTipsInCurLanguage(id));
            }
            else
            {
                ShowText(string.Format(TipsFormatConstValpublic.NO_TIPS_CONFIG_FOMAT, id));
            }
        }
Ejemplo n.º 3
0
    private void UpdateDelete()
    {
        if (tipsItemList.Count > 0)
        {
            TipsItem ui = tipsItemList[tipsItemList.Count - 1];
            if (ui != null && ui.UnUse())
            {
                tipsItemList.Remove(ui);
                Destroy(ui.gameObject);
            }
        }

        Invoke("UpdateDelete", TipsClearInterval);
    }
Ejemplo n.º 4
0
    private void MakeToast(TipsData data)
    {
        TipsItem   ti = null;
        GameObject go = null;

        // 找到目前未使用的
        for (int i = 0; i < tipsItemList.Count; ++i)
        {
            if (tipsItemList[i].UnUse())
            {
                go = tipsItemList[i].gameObject;
                ti = tipsItemList[i];
            }
        }

        if (go == null && ti == null)
        {
            switch (data.mType)
            {
            case TipsType.FlowLeft:
            {
                go = NGUITools.AddChild(flowLeftParent, itemTemplate);
            } break;

            case TipsType.FlowUp:
            {
                go = NGUITools.AddChild(flowUpParent, itemTemplate);
            } break;

            default:
            {
                go = NGUITools.AddChild(topParrent, itemTemplate);
            } break;
            }

            if (go == null)
            {
                return;
            }

            ti = go.GetComponent <TipsItem>();
            tipsItemList.Add(ti);
        }

        switch (data.mType)
        {
        case TipsType.FlowLeft:
        {
            go.transform.SetParent(flowLeftParent.transform);
        } break;

        case TipsType.FlowUp:
        {
            go.transform.SetParent(flowUpParent.transform);
        } break;

        default:
        {
            go.transform.SetParent(topParrent.transform);
        } break;
        }

        ti.Show(data, clipWidth, clipHeight, this);
    }