Exemplo n.º 1
0
        public int GetTrailEffectIndex(float3 position)
        {
            TrailRendererHolder trailRendererHolder = GetOrCreateEmptyParticleHolder();

            trailRendererHolder.isActive = true;
            trailRendererHolder.trailTransform.position = position;
            trailRendererHolder.trailRenderer.Clear();
            trailRendererHolder.effectGameObject.SetActive(true);

            _trailHolders[trailRendererHolder.elementIndex] = trailRendererHolder;
            return(trailRendererHolder.elementIndex);
        }
Exemplo n.º 2
0
        public void UpdateTrailPosition(float3 position, int effectIndex)
        {
            TrailRendererHolder trailRendererHolder = _trailHolders[effectIndex];

            if (!trailRendererHolder.isActive)
            {
                Debug.Log("Invalid Effect Updated");
                return;
            }

            trailRendererHolder.trailTransform.position     = position;
            _trailHolders[trailRendererHolder.elementIndex] = trailRendererHolder;
        }
Exemplo n.º 3
0
        public void StopTrailEffect(int effectIndex)
        {
            TrailRendererHolder trailRendererHolder = _trailHolders[effectIndex];

            if (!trailRendererHolder.isActive)
            {
                Debug.Log("Effect Is Already InActive");
                return;
            }

            trailRendererHolder.isActive = false;
            trailRendererHolder.effectGameObject.SetActive(false);
            _trailHolders[trailRendererHolder.elementIndex] = trailRendererHolder;
        }
Exemplo n.º 4
0
        public void StopTrailEffect(int effectIndex)
        {
            TrailRendererHolder trailRendererHolder = _trailHolders[effectIndex];

            if (!trailRendererHolder.isActive)
            {
                Debug.Log("Effect Is Already InActive");
                return;
            }

            trailRendererHolder.isActive = false;
            trailRendererHolder.particleSystem.Stop(true, ParticleSystemStopBehavior.StopEmitting);
            trailRendererHolder.effectGameObject.SetActive(false);
            _trailHolders[trailRendererHolder.elementIndex] = trailRendererHolder;
        }
Exemplo n.º 5
0
        private TrailRendererHolder GetOrCreateEmptyParticleHolder()
        {
            for (int i = 0; i < _trailHolders.Count; i++)
            {
                if (!_trailHolders[i].isActive)
                {
                    return(_trailHolders[i]);
                }
            }

            GameObject          trailEffect = Instantiate(blueBullEffectPrefab, Vector3.zero, Quaternion.identity);
            TrailRendererHolder trailHolder = new TrailRendererHolder()
            {
                isActive         = false,
                elementIndex     = _trailHolders.Count,
                trailRenderer    = trailEffect.GetComponent <TrailRenderer>(),
                trailTransform   = trailEffect.transform,
                effectGameObject = trailEffect
            };

            _trailHolders.Add(trailHolder);
            return(trailHolder);
        }