コード例 #1
0
 // Create a new vector oscillator.
 //
 // oscillationTime: The amount of time to do a full cycle from 0 to 1 and back for each axis.
 // startPctOffset: The percentage along the oscillationTime at which to start for each axis.
 // type: the type of curve on the oscillation
 // randomizeStart: True to choose a random time along the oscillationTime to start.
 //
 public VectorOscillator(Vector3 oscillationTime, Vector3 startPctOffset, OscillationType type = OscillationType.LINEAR, bool randomizeStart = false)
 {
     for (int i = 0; i < 3; i++)
     {
         oscillators [i] = new ValueOscillator(oscillationTime [i], startPctOffset [i], type, randomizeStart);
     }
 }
コード例 #2
0
    // Create a new value oscillator.
    //
    // oscillationTime: The amount of time to do a full cycle from 0 to 1 and back.
    // startPctOffset: The percentage along the oscillationTime at which to start.
    // type: the type of curve on the oscillation
    // randomizeStart: True to choose a random time along the oscillationTime to start.
    //
    public ValueOscillator(float oscillationTime, float startPctOffset = 0.0f, OscillationType type = OscillationType.LINEAR, bool randomizeStart = false)
    {
        if (oscillationTime <= 0f)
        {
            Debug.LogError("ValueOscillator cannot have oscillationTime (" + oscillationTime + ") less than or equal to zero.");
            oscillationTime = 1f;
        }

        wavelength = oscillationTime;
        curveType  = type;

        if (randomizeStart)
        {
            startPctOffset = Random.Range(0f, 1f);
        }

        startTime = Time.time - (startPctOffset * wavelength);
    }