private float Flicker(FlickerType type)
    {
        switch (type)
        {
        case FlickerType.None:
            return(0f);

        case FlickerType.Sinusoidal:
            return((Mathf.Sin(passedTime) / 2) * amplitude);     //Goes from  -0.5 to 0.5 with passing time

        case FlickerType.ZeroAndBackAgain:
            //Increase amplitude to mach baseIntensity, then move sin wave lower than 0
            return(((baseIntensity / 2) * Mathf.Sin(passedTime)) - (baseIntensity / 2));

        case FlickerType.Random:
            return(Random.Range(-0.1f, 0.1f) * amplitude);

        case FlickerType.RandomPerlinNoise:
            return((Mathf.PerlinNoise(passedTime, 0.0f) - 0.5f) * amplitude);

        case FlickerType.FromGraph:
            if (passedTime >= 1f)
            {
                passedTime = 0f;
            }
            return(graph.Evaluate(passedTime) * amplitude);

        default:
            return(0f);
        }
    }
예제 #2
0
    private IEnumerator IBug(float duration)
    {
        FlickerType before = FlickeringType;

        FlickeringType = FlickerType.RandomFlicker;
        yield return(new WaitForSeconds(duration));

        FlickeringType = before;
    }