Esempio n. 1
0
    /// <summary>
    /// 设置日志内容显示
    /// </summary>
    private void SetContent(LogDataVO dataVO)
    {
        UIUtil.SetIconImage(m_Icon, TableUtil.GetItemIconBundle(dataVO.Tid), TableUtil.GetItemIconImage(dataVO.Tid));
        UIUtil.SetIconImage(m_OverlyingIcon, TableUtil.GetItemIconBundle(dataVO.Tid), TableUtil.GetItemIconImage(dataVO.Tid));
        Color  m_QualityColor = ColorUtil.GetColorByItemQuality(TableUtil.GetItemQuality(dataVO.Tid));
        string m_Name         = TableUtil.GetItemName(dataVO.Tid);
        string m_ColorText    = ColorUtil.AddColor(m_Name, m_QualityColor);
        string m_ShowText     = "";

        if (dataVO.Num > 1)
        {
            m_ShowText = string.Format(TableUtil.GetLanguageString("log_text_1011"), m_ColorText, dataVO.Num);
        }
        else
        {
            m_ShowText = string.Format(TableUtil.GetLanguageString("log_text_1010"), m_ColorText);
        }
        m_Describe.text = string.Format(m_ShowText);
    }
Esempio n. 2
0
    /// <summary>
    /// 更新所有条目
    /// </summary>
    private void UpdateItems()
    {
        float now = Time.time;

        if (!m_Paused && m_WaitingQueue.Count > 0)
        {
            if (now >= m_LastCreateTime + ITEM_CREATE_INTERVAL)
            {
                m_LastCreateTime = now;

                CfgLanguageProxy languageProxy = Facade.RetrieveProxy(ProxyName.CfgLanguageProxy) as CfgLanguageProxy;

                ItemData data = m_WaitingQueue[0];
                m_WaitingQueue.RemoveAt(0);

                Transform item = null;

                for (int i = 0; i < m_Root.childCount; i++)
                {
                    if (!m_Root.GetChild(i).gameObject.activeSelf)
                    {
                        item = m_Root.GetChild(i);
                        break;
                    }
                }

                if (item == null)
                {
                    item = GameObject.Instantiate(m_ItemTemplate, m_Root);
                }

                Image    quality1 = item.Find("Quality/Quality_1").GetComponent <Image>();
                Image    quality2 = item.Find("Quality_2").GetComponent <Image>();
                Image    quality3 = item.Find("Quality_3").GetComponent <Image>();
                Image    quality4 = item.Find("Quality_4").GetComponent <Image>();
                Image    quality5 = item.Find("Quality_5").GetComponent <Image>();
                Image    icon     = item.Find("Image_Icon").GetComponent <Image>();
                TMP_Text text     = item.Find("Label_IconName").GetComponent <TMP_Text>();
                Animator animator = item.GetComponent <Animator>();

                item.SetAsLastSibling();
                item.gameObject.SetActive(true);
                Color color = ColorUtil.GetColorByItemQuality(data.Quality);
                quality1.color = quality2.color = quality3.color = quality4.color = quality5.color = color;
                string name = ColorUtil.AddColor(data.Name, color);
                text.text = string.Format(TableUtil.GetLanguageString("hud_text_id_1018"), name, data.Count.ToString());

                UIUtil.SetIconImage(icon, data.IconBundle, data.IconName);

                data.CreateTime = now;
                data.Transform  = item;
                data.IsNew      = true;
                m_ShowingQueue.Add(data);
            }
        }

        while (m_ShowingQueue.Count > ITEM_MAX_COUNT)
        {
            ItemData first = m_ShowingQueue[0];
            first.Transform.SetAsLastSibling();
            first.Transform.gameObject.SetActive(false);
            first.Transform = null;

            m_ShowingQueue.RemoveAt(0);
        }

        float y = 0;

        for (int i = m_ShowingQueue.Count - 1; i >= 0; i--)
        {
            ItemData data = m_ShowingQueue[i];
            if (data.CreateTime + ITEM_LIFE_TIME < now)
            {
                data.Transform.SetAsLastSibling();
                data.Transform.gameObject.SetActive(false);
                data.Transform = null;

                m_ShowingQueue.RemoveAt(i);
            }
            else
            {
                Vector3 position = data.Transform.localPosition;
                if (data.IsNew)
                {
                    data.Transform.localPosition = new Vector3(position.x, y, position.z);
                    data.IsNew = false;
                }
                else
                {
                    data.Transform.localPosition = new Vector3(position.x, Mathf.Lerp(position.y, y, 0.5f), position.z);
                }

                y += ITEM_HEIGHT;
                if (m_ShowingQueue.Count - 1 - i == 1)
                {
                    data.Transform.GetComponent <CanvasGroup>().alpha = 0.4f;
                }
                else if (m_ShowingQueue.Count - 1 - i == 0)
                {
                    data.Transform.GetComponent <CanvasGroup>().alpha = 1f;
                }
                else if (m_ShowingQueue.Count - 1 - i == 2)
                {
                    data.Transform.GetComponent <CanvasGroup>().alpha = 0.2f;
                }
            }
        }
    }