示例#1
0
        /// <summary>
        /// Updates for sliding and rolling and emits new particles if the particles are not looped.
        /// Will stop emitting if the new parameters don't produce valid data.
        /// </summary>
        /// <param name="newResult">The updated result.</param>
        public void KeepAlive(IInteractionResult newResult)
        {
            IsAlive = true;

            ParticleInteractionResult particleInteractionResult = newResult as ParticleInteractionResult;

            if (IsParticleLooped && particlesInstance != null)
            {
                particlesInstance.UpdateTransform(particleInteractionResult.OriginalData.Point, particleInteractionResult.OriginalData.Normal);
            }
            else
            {
                if (EmissionIntervalType == InteractionIntervalType.Time)
                {
                    intervalCounter += Time.fixedDeltaTime;
                }
                else
                {
                    intervalCounter = Vector3.Distance(particleInteractionResult.OriginalData.Point, previousEmissionPosition);
                }

                if (intervalCounter >= currentEmissionIntervalTarget)
                {
                    currentEmissionIntervalTarget = EmissionInterval.RandomInRange();
                    particlesInstance             = ImpactParticlePool.EmitParticles(this, particleInteractionResult.OriginalData.Point, particleInteractionResult.OriginalData.Normal, parent.Priority);

                    intervalCounter          = 0;
                    previousEmissionPosition = particleInteractionResult.OriginalData.Point;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Emit particles using our data.
        /// </summary>
        /// <param name="parent">The Impact Object that created this result.</param>
        public void Process(IImpactObject parent)
        {
            this.parent = parent;

            particlesInstance = ImpactParticlePool.EmitParticles(this, OriginalData.Point, OriginalData.Normal, InteractionResultExtensions.GetPriority(OriginalData.PriorityOverride, parent));
            IsAlive           = true;

            currentEmissionIntervalTarget = EmissionInterval.RandomInRange();

            //Dispose immediately for Collision interaction types
            if (OriginalData.InteractionType == InteractionData.InteractionTypeCollision)
            {
                Dispose();
            }
        }