Exemple #1
0
    void Start()
    {
        notorietyBar.type       = Image.Type.Filled;
        notorietyBar.fillMethod = Image.FillMethod.Horizontal;

        OscillationType = OscillationTypes.smooth;
    }
Exemple #2
0
    private float GenerateOscillation(OscillationTypes typeOfOscillation)
    {   //sin of 1.571 rad = 1, so each 1.571 seconds, it does half turn
        float rangeOfOscillation = OscillationRange();
        float halfRange          = rangeOfOscillation / 2f;
        float secondsToloop      = 4f;
        float angle       = 11f;
        float oscillation = 0;

        switch (typeOfOscillation)
        {
        case OscillationTypes.linear:
            oscillation = Mathf.PingPong(LoopCounterBySeconds(secondsToloop), rangeOfOscillation);
            break;

        case OscillationTypes.smooth:
            oscillation = Mathf.Sin(LoopCounterBySeconds(secondsToloop) * angle) * halfRange + halfRange;
            break;

        case OscillationTypes.chopped:
            oscillation = Mathf.Abs(Mathf.Sin(LoopCounterBySeconds(secondsToloop) * angle) * rangeOfOscillation);
            break;

        case OscillationTypes.heartBeat:
            oscillation = Mathf.Abs(Mathf.Sin(LoopCounterBySeconds(secondsToloop) * angle) + halfRange);
            break;

        default:
            break;
        }

        return(oscillation);
    }