Esempio n. 1
0
        //public ObjectCachePool(CacheReleaser _releaser, int _max_cache_count, int _cache_limit_count, float _worn_time, GameObject _root_node);

        private void Awake()
        {
            mInstance = this;

            //init gameobj pool root
            mPoolRoot = new GameObject("PoolRoot");
            mPoolRoot.SetActive(false);
            DontDestroyOnLoad(mPoolRoot);
            Transform root_trans = mPoolRoot.transform;

            mPoolRootActor = new GameObject("PoolActor");
            mPoolRootActor.transform.parent = root_trans;
            mPoolRootSmallPrefab            = new GameObject("PoolSmallPrefab");
            //mPoolRootSmallPrefab.SetActive(false);
            mPoolRootSmallPrefab.transform.parent = root_trans;
            mPoolRootSFX = new GameObject("PoolSFX");
            //mPoolRootSFX.SetActive(false);
            mPoolRootSFX.transform.parent = root_trans;
            mPoolRootUIPrefab             = new GameObject("PoolUIPrefab");
            //mPoolRootUIPrefab.SetActive(false);
            mPoolRootUIPrefab.transform.parent = root_trans;
            mPoolRootDropPrefab = new GameObject("PoolDropPrefab");
            //mPoolRootDropPrefab.SetActive(false);
            mPoolRootDropPrefab.transform.parent = root_trans;

            CacheReleaser cacheReleaserUnityObj = new CacheReleaser();

            cacheReleaserUnityObj.register_release(new CacheReleaser.ReleaseCacheHandle(CacheReleaseHandlerUnityObj));

            CacheReleaser cacheReleaserGameObject = new CacheReleaser();

            cacheReleaserGameObject.register_release(new CacheReleaser.ReleaseCacheHandle(CacheReleaseHandlerPrefab));

            mDicObjPools.Add(ObjCachePoolType.JSON, new ObjectCachePool(cacheReleaserUnityObj, 16, 32, 10, null));
            mDicObjPools.Add(ObjCachePoolType.AIJSON, new ObjectCachePool(cacheReleaserUnityObj, 16, 32, 120, null));
            mDicObjPools.Add(ObjCachePoolType.AI, new ObjectCachePool(null, 128, 256, 120, null));
            mDicObjPools.Add(ObjCachePoolType.MACHINE, new ObjectCachePool(null, 256, 512, 60, null));
            mDicObjPools.Add(ObjCachePoolType.STATE, new ObjectCachePool(null, 1024, 2048, 60, null));
            mDicObjPools.Add(ObjCachePoolType.SMALL_PREFAB, new ObjectCachePool(cacheReleaserGameObject, 128, 256, 10, mPoolRootSmallPrefab));
            mDicObjPools.Add(ObjCachePoolType.UI_PREFAB, new ObjectCachePool(cacheReleaserGameObject, 50, 100, 60, mPoolRootUIPrefab));
            mDicObjPools.Add(ObjCachePoolType.DROP_PREFAB, new ObjectCachePool(cacheReleaserGameObject, 50, 100, 180, mPoolRootDropPrefab));

            if (QualitySetting.IsVeryLowIPhone())
            {
                mDicObjPools.Add(ObjCachePoolType.ACTOR, new ObjectCachePool(cacheReleaserGameObject, 15, 30, 30, mPoolRootActor));
                mDicObjPools.Add(ObjCachePoolType.SFX, new ObjectCachePool(cacheReleaserGameObject, 25, 50, 30, mPoolRootSFX));
            }
            else
            {
                mDicObjPools.Add(ObjCachePoolType.ACTOR, new ObjectCachePool(cacheReleaserGameObject, 25, 50, 60, mPoolRootActor));
                mDicObjPools.Add(ObjCachePoolType.SFX, new ObjectCachePool(cacheReleaserGameObject, 50, 100, 60, mPoolRootSFX));
            }

            //timers
            InvokeRepeating("UpdateCachePool", 5f, 5f);

            ClientEventMgr.Instance.SubscribeClientEvent((int)ClientEvent.CE_START_SWITCHSCENE, OnStartSwitchScene);
        }
Esempio n. 2
0
 // 默认数值:(_releaser, 64, 128, 60, null);
 public ObjectCachePool(CacheReleaser _releaser, int _max_cache_count, int _cache_limit_count, float _worn_time, GameObject _root_node)
 {
     mCacheBlockMaxCount = _max_cache_count;
     mBlockLimitCount    = _cache_limit_count;
     mWornTime           = _worn_time;
     mRootNode           = _root_node;
     mReleaser_          = _releaser;
     mLastUpdateTime     = Time.time;
     init_pool();
 }
Esempio n. 3
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="key"></param>
 /// <param name="_releaser"></param>
 /// <returns></returns>
 public bool init_cache(string key, CacheReleaser _releaser)
 {
     if (key == null)
     {
         weight_ = -1f;
         return(false);
     }
     mKey      = key;
     releaser_ = _releaser;
     return(true);
 }