コード例 #1
0
        private IEnumerator TimerToReAddToPool(GenericParticleController particleController)
        {
            yield return(new WaitForSeconds(1.5f));

            switch (effectType)
            {
            case HitEffectType.WOOD:
                PoolingManager.singleton.hitEffectWood.ReIntergratePoolableObject(particleController);
                break;

            case HitEffectType.METAL:
                PoolingManager.singleton.hitEffectMetal.ReIntergratePoolableObject(particleController);
                break;

            case HitEffectType.BLOOD:
                PoolingManager.singleton.hitEffectConcrete.ReIntergratePoolableObject(particleController);
                break;

            case HitEffectType.DIRT:
                PoolingManager.singleton.hitEffectDirt.ReIntergratePoolableObject(particleController);
                break;

            case HitEffectType.CONCRETE:
                PoolingManager.singleton.hitEffectConcrete.ReIntergratePoolableObject(particleController);
                break;

            case HitEffectType.GLASS:
                PoolingManager.singleton.hitEffectGlass.ReIntergratePoolableObject(particleController);
                break;
            }
        }
コード例 #2
0
        public void ObjectHit(Vector3 hitPosition, Vector3 direction)
        {
            GenericParticleController particleController = null;

            switch (effectType)
            {
            case HitEffectType.WOOD:
                particleController = PoolingManager.singleton.hitEffectWood.GetPoolableObject();
                break;

            case HitEffectType.METAL:
                particleController = PoolingManager.singleton.hitEffectMetal.GetPoolableObject();
                break;

            case HitEffectType.BLOOD:
                particleController = PoolingManager.singleton.hitEffectBlood.GetPoolableObject();
                break;

            case HitEffectType.DIRT:
                particleController = PoolingManager.singleton.hitEffectDirt.GetPoolableObject();
                break;

            case HitEffectType.CONCRETE:
                particleController = PoolingManager.singleton.hitEffectConcrete.GetPoolableObject();
                break;

            case HitEffectType.GLASS:
                particleController = PoolingManager.singleton.hitEffectGlass.GetPoolableObject();
                break;
            }
            particleController.transform.position = hitPosition;
            particleController.transform.rotation = Quaternion.LookRotation(direction);
            StartCoroutine("TimerToReAddToPool", particleController);
        }
コード例 #3
0
        public void ReIntergratePoolableObject(GenericParticleController particleController)
        {
            PoolableParticleItem newItem = new PoolableParticleItem();

            newItem.geo = particleController.gameObject;
            newItem.particleController = particleController;

            createdPoolableItems.Add(newItem);
            particleController.transform.SetParent(transform);
            particleController.transform.localPosition = Vector3.zero;
            particleController.transform.localRotation = Quaternion.identity;
        }
コード例 #4
0
        public GenericParticleController GetPoolableObject()
        {
            if (createdPoolableItems.Count == 0)
            {
                Debug.LogError(gameObject.name + " Has no available objects in the pool currently, increase the amount to spawn");
                return(null);
            }

            GenericParticleController particleController = createdPoolableItems[0].particleController;

            particleController.transform.SetParent(null);
            particleController.PlayParticles();
            createdPoolableItems.RemoveAt(0);
            return(particleController);
        }