Пример #1
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------//

        /// <summary>
        /// 添加倒计时
        /// </summary>
        /// <param name="id_"></param>
        /// <param name="time_"></param>
        public void AddTime(object id_, float time_)
        {
            if (time_ <= 0)
            {
                RemoveTime(id_);
                return;
            }

            CountTimeInfo info;

            if (m_id2info.ContainsKey(id_))
            {
                info        = m_id2info[id_];
                info.CdTime = time_;
            }
            else
            {
                info = new CountTimeInfo(id_, time_);
                AddInfo(info);
            }
        }
Пример #2
0
        private void AddInfo(CountTimeInfo info_)
        {
            if (m_id2info.ContainsKey(info_.Id))
            {
                return;
            }

            m_id2info[info_.Id] = info_;
            ++m_infoNum;

            if (m_infoNum == 1)
            {
                m_nfyTime = m_nfyDelay;

                if (m_isAutoUpdate)
                {
                    SetupEvent();
                }
            }

            NotifyWithInfo(COUNT_TIMER_EVENT.ADD, info_);
        }
Пример #3
0
        /// <summary>
        /// 移除倒计时
        /// </summary>
        /// <param name="id_"></param>
        /// <returns></returns>
        public bool RemoveTime(object id_)
        {
            if (!m_id2info.ContainsKey(id_))
            {
                return(false);
            }

            CountTimeInfo info = m_id2info[id_];

            m_id2info.Remove(id_);
            --m_infoNum;

            if (m_infoNum == 0)
            {
                if (m_isAutoUpdate)
                {
                    ClearEvent();
                }
            }

            NotifyWithInfo(COUNT_TIMER_EVENT.REMOVE, info);
            return(true);
        }
Пример #4
0
 private void NotifyWithInfo(string type_, CountTimeInfo info_)
 {
     NotifyWithEvent(type_, info_);
 }