Exemple #1
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);
            }
        }
Exemple #2
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();
            }
        }