예제 #1
0
        public override bool Initialize()
        {
            mPoolManager = new PoolManager2();
            SpawnPool2 pool = mPoolManager[PoolKey.SendPacket];

            pool.onCreateObject  = onCreatObject;
            pool.onSpawnObject   = onSpawnObject;
            pool.onDespawnObject = onDesPawnObject;
            return(true);
        }
예제 #2
0
        protected void onSpawnObject(object obj, object poolKey, SpawnPool2 pool)
        {
            IReference refence = obj as IReference;

            if (null != refence)
            {
                refence.Retain();
                refence.AutoRelease();
            }
            //return refence;
        }
예제 #3
0
        protected object onCreatObject(object poolKey, SpawnPool2 pool)
        {
            object obj = null;

            switch ((PoolKey)poolKey)
            {
            case PoolKey.SendPacket:
                obj = new NetSendPacket();
                break;
            }
            return(obj);
        }
예제 #4
0
        public void ClosePool(object poolKey)
        {
            if (poolKey == null)
            {
                throw new ArgumentNullException("poolKey CAN'T be null");
            }
            SpawnPool2 pool = TryGetPool(poolKey);

            if (null != pool)
            {
                pool.DisposeAllObjects();
                mPoolDict.Remove(poolKey);
            }
        }
예제 #5
0
        public SpawnPool2 TryGetPool(object poolKey)
        {
            if (poolKey == null)
            {
                throw new ArgumentNullException("poolKey CAN'T be null");
            }
            SpawnPool2 result = null;

            if (!this.mPoolDict.TryGetValue(poolKey, out result))
            {
                result = null;
            }
            return(result);
        }
예제 #6
0
 public SpawnPool2 this[object poolKey]
 {
     get
     {
         if (poolKey == null)
         {
             throw new ArgumentNullException();
         }
         SpawnPool2 pool = TryGetPool(poolKey);
         if (null == pool)
         {
             //audo 简单实现SpwanPool的使用
             pool = new SpawnPool2();
             pool.mPoolManager  = this;
             pool.mPoolKey      = poolKey;
             mPoolDict[poolKey] = pool;
         }
         return(pool);
     }
 }
예제 #7
0
 protected void onDesPawnObject(object obj, object poolkey, SpawnPool2 pool)
 {
 }