using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace ParticlePlayground {
public class TrailPoint
{
public Vector3 position;
public Vector3 velocity;
public float lifetime;
public float startLifetime;
public float width;
bool _canRemove = false;
float _lastTimeUpdated;
public TrailPoint (Vector3 position, float startLifetime, float creationTime)
{
this.position = position;
this.lifetime = startLifetime;
this.startLifetime = startLifetime;
this.width = 0;
_lastTimeUpdated = creationTime;
}
public TrailPoint (Vector3 position, float startLifetime, float width, float creationTime)
{
this.position = position;
this.lifetime = startLifetime;
this.startLifetime = startLifetime;
this.width = width;
_lastTimeUpdated = creationTime;
}
public TrailPoint (Vector3 position, Vector3 velocity, float startLifetime, float width, float creationTime)
{
this.position = position;
this.lifetime = startLifetime;
this.startLifetime = startLifetime;
this.width = width;
this.velocity = velocity;
_lastTimeUpdated = creationTime;
}
public void Update (float updateTime, float width)
{
lifetime -= updateTime-_lastTimeUpdated;
if (lifetime <= 0)
{
_canRemove = true;
lifetime = 0;
}
this.width = width;
_lastTimeUpdated = updateTime;
}
///
/// Gets the normalized lifetime of this trail point.
///
/// The normalized lifetime.
public float GetNormalizedLifetime () {
return 1f-(lifetime/startLifetime);
}
///
/// Determines whether this point can be removed.
///
/// true if this point can be removed; otherwise, false.
public bool CanRemove () {
return _canRemove;
}
}
}