Esempio n. 1
0
        /// <summary>
        /// 从数据库中加载
        /// </summary>
        /// <param name="playerId"></param>
        public void LoadFromDatabase(int playerId)
        {
            lock (m_lock)
            {
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    BufferInfo[] infos = db.GetUserBuffer(playerId);
                    BeginChanges();

                    foreach (BufferInfo info in infos)
                    {
                        AbstractBuffer buffer = CreateBuffer(info);
                        if (buffer != null)
                        {
                            buffer.Start(m_player);
                        }
                    }

                    CommitChanges();
                }

                //更新状态
                Update();
            }
        }
Esempio n. 2
0
        public void LoadFromDatabase(int playerId)
        {
            object @lock;

            Monitor.Enter(@lock = this.m_lock);
            try
            {
                using (PlayerBussiness playerBussiness = new PlayerBussiness())
                {
                    BufferInfo[] userBuffer = playerBussiness.GetUserBuffer(playerId);
                    this.BeginChanges();
                    BufferInfo[] array = userBuffer;
                    for (int i = 0; i < array.Length; i++)
                    {
                        BufferInfo     info           = array[i];
                        AbstractBuffer abstractBuffer = BufferList.CreateBuffer(info);
                        if (abstractBuffer != null)
                        {
                            abstractBuffer.Start(this.m_player);
                        }
                    }
                    this.CommitChanges();
                }
                this.Update();
            }
            finally
            {
                Monitor.Exit(@lock);
            }
        }
Esempio n. 3
0
 protected void OnBuffersChanged(AbstractBuffer buffer)
 {
     if (!this.m_changedBuffers.Contains(buffer))
     {
         this.m_changedBuffers.Add(buffer);
     }
     if (this.m_changeCount <= 0 && this.m_changedBuffers.Count > 0)
     {
         this.UpdateChangedBuffers();
     }
 }
Esempio n. 4
0
        public bool AddBuffer(AbstractBuffer buffer)
        {
            lock (m_buffers)
            {
                m_buffers.Add(buffer);
            }

            OnBuffersChanged(buffer);

            return(true);
        }
Esempio n. 5
0
        protected void OnBuffersChanged(AbstractBuffer buffer)
        {
            if (m_changedBuffers.Contains(buffer) == false)
            {
                m_changedBuffers.Add(buffer);
            }

            if (m_changeCount <= 0 && m_changedBuffers.Count > 0)
            {
                UpdateChangedBuffers();
            }
        }
Esempio n. 6
0
        public bool RemoveBuffer(AbstractBuffer buffer)
        {
            lock (m_buffers)
            {
                if (m_buffers.Remove(buffer))
                {
                    m_clearList.Add(buffer.Info);
                }
            }

            OnBuffersChanged(buffer);

            return(true);
        }
Esempio n. 7
0
        public bool AddBuffer(AbstractBuffer buffer)
        {
            List <AbstractBuffer> buffers;

            Monitor.Enter(buffers = this.m_buffers);
            try
            {
                this.m_buffers.Add(buffer);
            }
            finally
            {
                Monitor.Exit(buffers);
            }
            this.OnBuffersChanged(buffer);
            return(true);
        }
Esempio n. 8
0
        public bool RemoveBuffer(AbstractBuffer buffer)
        {
            List <AbstractBuffer> buffers;

            Monitor.Enter(buffers = this.m_buffers);
            try
            {
                if (this.m_buffers.Remove(buffer))
                {
                    this.m_clearList.Add(buffer.Info);
                }
            }
            finally
            {
                Monitor.Exit(buffers);
            }
            this.OnBuffersChanged(buffer);
            return(true);
        }
Esempio n. 9
0
        public static AbstractBuffer CreateBuffer(BufferInfo info)
        {
            AbstractBuffer result = null;

            switch (info.Type)
            {
            case 11:
                result = new KickProtectBuffer(info);
                break;

            case 12:
                result = new OfferMultipleBuffer(info);
                break;

            case 13:
                result = new GPMultipleBuffer(info);
                break;

            case 15:
                result = new PropsBuffer(info);
                break;
            }
            return(result);
        }
Esempio n. 10
0
 public void UpdateBuffer(AbstractBuffer buffer)
 {
     this.OnBuffersChanged(buffer);
 }
Esempio n. 11
0
        public bool AddBuffer(AbstractBuffer buffer)
        {
            lock (m_buffers)
            {
                m_buffers.Add(buffer);
            }

            OnBuffersChanged(buffer);

            return true;
        }
Esempio n. 12
0
        protected void OnBuffersChanged(AbstractBuffer buffer)
        {
            if (m_changedBuffers.Contains(buffer) == false)

                m_changedBuffers.Add(buffer);

            if (m_changeCount <= 0 && m_changedBuffers.Count > 0)
            {
                UpdateChangedBuffers();
            }
        }
Esempio n. 13
0
 public void UpdateBuffer(AbstractBuffer buffer)
 {
     OnBuffersChanged(buffer);
 }
Esempio n. 14
0
        public bool RemoveBuffer(AbstractBuffer buffer)
        {
            lock (m_buffers)
            {
                if (m_buffers.Remove(buffer))
                {
                    m_clearList.Add(buffer.Info);
                }
            }

            OnBuffersChanged(buffer);

            return true;
        }