예제 #1
0
    /// <summary>
    /// takes the start and end values and lerps between them over chargeTime
    /// returns true if done charging, false otherwise
    /// </summary>
    /// <param name="startScale"></param>
    /// <param name="endScale"></param>
    /// <param name="chargeTime"></param>
    /// <param name="endData"></param>
    public bool Charge(Vector3 startScale, Vector3 endScale, float chargeTime, ElectricRoundData endData)
    {
        //get our particle system's modules to alter them over time
        ParticleSystem.ShapeModule    shapeModule    = electricParticles.shape;
        ParticleSystem.EmissionModule emissionModule = electricParticles.emission;
        ParticleSystem.MainModule     mainModule     = electricParticles.main;
        //TODO: make an animation for this instead of doing it through code
        //(only necessary if we want to do more than lerp between start and end state)
        //get our lerp progress here so we can use it for each of the different things we're lerping between
        lerpProgress += (Time.deltaTime / chargeTime);
        lerpProgress  = Mathf.Clamp(lerpProgress, 0, 1);
        //lerp all the stuff we need to lerp
        transform.localScale                  = Vector3.Lerp(startScale, endScale, lerpProgress);
        shapeModule.radius                    = Mathf.Lerp(startingData.radius, endData.radius, lerpProgress);
        shapeModule.radiusThickness           = Mathf.Lerp(startingData.radiusThickness, endData.radiusThickness, lerpProgress);
        shapeModule.scale                     = Vector3.Lerp(startingData.shapeScale, endData.shapeScale, lerpProgress);
        emissionModule.rateOverTimeMultiplier = Mathf.Lerp(startingData.emissionRate, endData.emissionRate, lerpProgress);
        //create a new MinMaxCurve for particle size and update that based on time
        Vector2 particleSize = Vector2.Lerp(startingData.particleSize, endData.particleSize, lerpProgress);

        ParticleSystem.MinMaxCurve newSize = new ParticleSystem.MinMaxCurve(particleSize.x, particleSize.y);
        mainModule.startSize = newSize;

        trail.widthMultiplier = Mathf.Lerp(startingData.trailWidth, endData.trailWidth, lerpProgress);
        trail.time            = Mathf.Lerp(startingData.trailLifetime, endData.trailLifetime, lerpProgress);

        if (lerpProgress == 1)
        {
            return(true);
        }
        return(false);
    }
예제 #2
0
    /// <summary>
    /// call charge without using the ElectricRoundData struct
    /// returns true if done charging, false otherwise
    /// </summary>
    /// <param name="startScale"></param>
    /// <param name="endScale"></param>
    /// <param name="chargeTime"></param>
    /// <param name="endRadius"></param>
    /// <param name="endRadiusThickness"></param>
    /// <param name="endSize"> the min and max values for particle size at the end of charging</param>
    /// <param name="endEmissionRate"></param>
    /// <param name="endTrailLife"> the lifetime of the trail at the end of charging</param>
    /// <param name="endTrailWidth"> the width multiplier for the trail at the end of charging</param>
    /// <param name="psEndScale"></param>
    /// <returns></returns>
    public bool Charge(Vector3 startScale,
                       Vector3 endScale, float chargeTime, float endRadius,
                       float endRadiusThickness, Vector2 endSize, float endEmissionRate,
                       float endTrailLife, float endTrailWidth, Vector3 psEndScale)
    {
        ElectricRoundData endData = new ElectricRoundData(endRadius, endRadiusThickness, endEmissionRate, endSize, endScale, endTrailLife, endTrailWidth);

        return(Charge(startScale, endScale, chargeTime, endData));
    }
예제 #3
0
 /// <summary>
 /// Overloaded method for charge that allows us to call it with no argument for startScale
 /// assumes that starting scale is (1,1,1)
 /// returns true if done charging, false otherwise
 /// </summary>
 /// <param name="endScale"></param>
 /// <param name="chargeTime"></param>
 /// <param name="endData"></param>
 public bool Charge(Vector3 endScale, float chargeTime, ElectricRoundData endData)
 {
     return(Charge(new Vector3(1, 1, 1), endScale, chargeTime, endData));
 }