示例#1
0
    void Awake()
    {
        Instance = this;

        HashedObjectsPoolPropertiesList = new Dictionary <string, ObjectsPoolProperties>();
        //ObjectsPool = new Dictionary<ObjectPrefabType, List<GameObject>>();
        ObjectsPool = new Dictionary <string, List <GameObject> >();

        NeedToCallOnActivate   = new List <GameObject>();
        NeedToCallOnDeactivate = new List <GameObject>();

        CurrentlyUsedObjects = new HashSet <GameObject>();

        InitPool();
    }
示例#2
0
    public void AddGameObject()
    {
        GameObject BulletGO = ObjectsPoolManager.GetObject(mBullet.BulletType.ToString()); //从对象池中拿出物体

        if (BulletGO != null)                                                              //如果对象池里有物体,则设置该物体的子弹属性
        {
            mBullet.AnyBullet = BulletGO;
        }
        else //如果没有,就生成一个
        {
            GameObject gameObject = FactoryManager.assetFactory.LoadBullet(mBullet.BulletType.ToString());
            gameObject.AddComponent <BulletCollider>();
            ObjectsPoolManager.PushObject(mBullet.BulletType.ToString(), gameObject); //往对象池中添加物体
            mBullet.AnyBullet = gameObject;
        }
    }
示例#3
0
    public GameObject PlayEffectNow(Transform _Transform, string _EffectType, float _DestroyTime)
    {
        GameObject effect = ObjectsPoolManager.GetObject(_EffectType); //从对象池取出物体

        //Debug.Log(effect);
        if (effect != null)
        {
            effect.transform.position = _Transform.position;
            effect.transform.rotation = _Transform.rotation;
            return(effect);
        }
        else
        {
            GameObject go = FactoryManager.assetFactory.LoadEffect(_EffectType);
            go.AddComponent <DestroyTime>().SetDestroyTime(_EffectType, _DestroyTime); //添加自动销毁(取消激活)的脚本
            go.transform.position = _Transform.position;
            ObjectsPoolManager.PushObject(_EffectType, go);                            //往对象池中添加物体,要从assetfactory 里拿,不然传进来的是prefab,第一次实例的是clone
            return(go);
        }
    }
示例#4
0
    public GameObject PlayAudioNow(Transform _Transform, string _FeatureType)
    {
        GameObject audio = ObjectsPoolManager.GetObject(_FeatureType); //从对象池取出物体

        //Debug.Log(audio);
        if (audio != null)
        {
            audio.transform.position = _Transform.position;
            audio.GetComponent <AudioSource>().Play();
            return(audio);
        }
        else
        {
            GameObject  go          = new GameObject(_FeatureType.ToString());
            AudioSource audioSource = go.AddComponent <AudioSource>();
            AudioClip   _audioClip  = FactoryManager.assetFactory.LoadAudioClip(_FeatureType);
            audioSource.clip      = _audioClip;
            go.transform.position = _Transform.position;
            audioSource.Play();
            ObjectsPoolManager.PushObject(_FeatureType, go); //往对象池中添加物体,要从assetfactory 里拿,不然传进来的是prefab,第一次实例的是clone
            return(go);
        }
    }
示例#5
0
 void Awake()
 {
     _instance = this;
 }
示例#6
0
 public void Release()
 {
     ObjectsPoolManager.DestroyActiveObject(mAttr.PrefabName.ToString(), mAnyTank);
     //GameObject.Destroy(mAnyTank);
 }
示例#7
0
 /// <summary>
 /// 在坦克系统里增加改生成的坦克
 /// </summary>
 public void AddInTankSystem()
 {
     GameFacade.Instance.AddTankOne(mTank as Tank1);
     ObjectsPoolManager.PushObject(mPrefabName, mTank.GameObject);
 }
示例#8
0
 private void DenyB()
 {
     ObjectsPoolManager.DestroyActiveObject(mFeature, gameObject);
 }
示例#9
0
 /// <summary>
 /// 销毁子弹
 /// </summary>
 private void BulletDestroy()
 {
     GameFacade.Instance.RemoveBullet(mBullet.Owner);
     ObjectsPoolManager.DestroyActiveObject(mBullet.BulletType.ToString(), gameObject);
 }