Пример #1
0
        private void _UpdateBuff()
        {
            if (head == null || head.m_uiHead == null)
            {
                return;
            }

            if (m_listBuff.Count <= 0)
            {
                return;
            }

            for (int i = 0; i < m_listBuff.Count; i++)
            {
                UIHeadBuff buff = m_listBuff[i];
                buff.curTime -= Time.deltaTime;
                buff.pct      = buff.curTime / buff.maxTime;
            }
            head.m_uiHead.UpdateBuffPct(m_headObj, m_listBuff[m_listBuff.Count - 1].pct);
        }
Пример #2
0
        public void SetBuff(int buffId, int icon, float maxTime)
        {
            if (maxTime > 0)
            {
                for (int i = 0; i < m_listBuff.Count; i++)
                {
                    UIHeadBuff buff = m_listBuff[i];
                    if (buff.buffId == buffId)
                    {
                        buff.curTime = maxTime;
                        return;
                    }
                }
                UIHeadBuff b = new UIHeadBuff();
                b.buffId  = buffId;
                b.icon    = icon;
                b.curTime = maxTime;
                b.maxTime = maxTime;
                m_listBuff.Add(b);

                head.m_uiHead.ShowBuff(m_headObj, true);
            }
            else
            {
                for (int i = 0; i < m_listBuff.Count; i++)
                {
                    UIHeadBuff buff = m_listBuff[i];
                    if (buff.buffId == buffId)
                    {
                        m_listBuff.Remove(buff);
                        break;
                    }
                }
                if (m_listBuff.Count == 0)
                {
                    head.m_uiHead.ShowBuff(m_headObj, false);
                }
            }
            head.m_uiHead.UpdateBuffList(m_headObj, m_listBuff);
        }