Esempio n. 1
0
 void UpdateBarValue()
 {
     if (effectBurn)
     {
         if (effectSmoothChange)
         {
             // in burn mode smooth primary bar only when it's increasing
             if (ValueF > ValueF2)
             {
                 EnergyBarCommons.SmoothDisplayValue(ref ValueF2, ValueF, effectSmoothChangeSpeed);
             }
             else
             {
                 ValueF2 = energyBar.ValueF;
             }
         }
         else
         {
             ValueF2 = energyBar.ValueF;
         }
     }
     else
     {
         if (effectSmoothChange)
         {
             EnergyBarCommons.SmoothDisplayValue(ref ValueF2, ValueF, effectSmoothChangeSpeed);
         }
         else
         {
             ValueF2 = energyBar.ValueF;
         }
     }
 }
Esempio n. 2
0
    private float actualDisplayValue; // value that is actually displayed

    // ===========================================================
    // Getters, Setters
    // ===========================================================

    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================

    // ===========================================================
    // Methods
    // ===========================================================

    new protected void Update()
    {
        base.Update();

        if (effectSmoothChange)
        {
            EnergyBarCommons.SmoothDisplayValue(ref actualDisplayValue, ValueF, effectSmoothChangeSpeed);
        }
        else
        {
            actualDisplayValue = ValueF;
        }

        float iconCount       = actualDisplayValue * icons.Length;
        int   filledIconCount = (int)Mathf.Floor(iconCount);    // icons painted at full visibility

        ForEachIcon((Icon icon, int i) => {
            if (i + 1 <= iconCount)
            {
                SetIconProgress(icon, 1);
            }
            else if (i > iconCount)
            {
                SetIconProgress(icon, 0);
            }
            else
            {
                SetIconProgress(icon, iconCount - filledIconCount);
            }

            // if not in grow effect then apply current scales
            // this allows user to scale icons on his will
            if (effect != Effect.GrowIn)
            {
                icon.ApplyScales();
            }
        });
    }
Esempio n. 3
0
 void UpdateBurnValue()
 {
     EnergyBarCommons.SmoothDisplayValue(
         ref ValueFBurn, ValueF2, effectSmoothChangeSpeed);
     ValueFBurn = Mathf.Max(ValueFBurn, ValueF2);
 }
Esempio n. 4
0
    void UpdateBarValue()
    {
        if (effectBurn)
        {
            if (effectSmoothChange)
            {
                // in burn mode smooth primary bar only when it's increasing
                bool canGoUp = effectSmoothChangeDirection == SmoothDirection.Both ||
                               effectSmoothChangeDirection == SmoothDirection.OnlyWhenIncreasing;

                if (ValueF > ValueF2 && canGoUp)
                {
                    EnergyBarCommons.SmoothDisplayValue(ref ValueF2, ValueF, effectSmoothChangeSpeed);
                }
                else
                {
                    ValueF2 = energyBar.ValueF;
                }

                if (!Mathf.Approximately(ValueF, ValueF2))
                {
                    effectSmoothChangeWorking = true;
                }
                else if (effectSmoothChangeWorking)
                {
                    effectSmoothChangeFinishedNotify.Execute(this);
                    effectSmoothChangeWorking = false;
                }
            }
            else
            {
                ValueF2 = energyBar.ValueF;
            }
        }
        else
        {
            if (effectSmoothChange)
            {
                bool canGoUp = effectSmoothChangeDirection == SmoothDirection.Both ||
                               effectSmoothChangeDirection == SmoothDirection.OnlyWhenIncreasing;
                bool canGoDown = effectSmoothChangeDirection == SmoothDirection.Both ||
                                 effectSmoothChangeDirection == SmoothDirection.OnlyWhenDecreasing;

                if ((ValueF > ValueF2 && canGoUp) || (ValueF < ValueF2 && canGoDown))
                {
                    EnergyBarCommons.SmoothDisplayValue(ref ValueF2, ValueF, effectSmoothChangeSpeed);
                }
                else
                {
                    ValueF2 = energyBar.ValueF;
                }

                if (!Mathf.Approximately(ValueF, ValueF2))
                {
                    effectSmoothChangeWorking = true;
                }
                else if (effectSmoothChangeWorking)
                {
                    effectSmoothChangeFinishedNotify.Execute(this);
                    effectSmoothChangeWorking = false;
                }
            }
            else
            {
                ValueF2 = energyBar.ValueF;
            }
        }
    }
Esempio n. 5
0
    void UpdateBurnValue()
    {
        EnergyBarCommons.SmoothDisplayValue(
            ref ValueFBurn, ValueF2, effectSmoothChangeSpeed);
        ValueFBurn = Mathf.Max(ValueFBurn, ValueF2);
        switch (effectBurnDirection)
        {
        case BurnDirection.Both:
            if (ValueF > ValueF2)
            {
                ValueFBurn = ValueF;
            }
            else if (ValueF < ValueF2)
            {
                EnergyBarCommons.SmoothDisplayValue(
                    ref ValueFBurn, ValueF, effectSmoothChangeSpeed);
            }
            else
            {
                ValueFBurn = Mathf.Max(ValueFBurn, ValueF2);
            }

            break;

        case BurnDirection.OnlyWhenDecreasing:
            if (ValueF < ValueF2)
            {
                EnergyBarCommons.SmoothDisplayValue(
                    ref ValueFBurn, ValueF, effectSmoothChangeSpeed);
            }
            else
            {
                ValueFBurn = Mathf.Max(ValueFBurn, ValueF2);
            }

            break;

        case BurnDirection.OnlyWhenIncreasing:
            if (ValueF > ValueF2)
            {
                ValueFBurn = ValueF;
            }
            else
            {
                ValueFBurn = ValueF2;
            }

            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        if (!Mathf.Approximately(ValueFBurn, ValueF2))
        {
            effectBurnWorking = true;
        }
        else if (effectBurnWorking)
        {
            effectBurnFinishedNotify.Execute(this);
            effectBurnWorking = false;
        }
    }
    new protected void Update()
    {
        base.Update();

        switch (colorType)
        {
        case ColorType.Solid:
            // do nothing, color changed by inspector code
            break;

        case ColorType.Gradient:
            colorVisible = colorGradient.Evaluate(ValueF);
            break;

        default:
            Debug.LogError("unknown option: " + colorType);
            break;
        }

        if (effectBurn)
        {
            if (effectSmoothChange)
            {
                // in burn mode smooth primary bar only when it's increasing
                if (ValueF > actualDisplayValue)
                {
                    EnergyBarCommons.SmoothDisplayValue(ref actualDisplayValue, ValueF, effectSmoothChangeSpeed);
                }
                else
                {
                    actualDisplayValue = ValueF;
                }
            }
            else
            {
                actualDisplayValue = ValueF;
            }

            EnergyBarCommons.SmoothDisplayValue(ref actualBurnValue, actualDisplayValue, effectSmoothChangeSpeed);
            actualBurnValue = Mathf.Max(actualBurnValue, actualDisplayValue);
        }
        else
        {
            if (effectSmoothChange)
            {
                EnergyBarCommons.SmoothDisplayValue(ref actualDisplayValue, ValueF, effectSmoothChangeSpeed);
            }
            else
            {
                actualDisplayValue = ValueF;
            }

            actualBurnValue = actualDisplayValue;
        }

        bar.fillAmount = actualDisplayValue;
        if (effectBurnBar != null)
        {
            effectBurnBar.fillAmount = actualBurnValue;
        }

        if (Application.isPlaying)
        {
            if (effectBlink && EnergyBarCommons.Blink(ValueF, effectBlinkValue, effectBlinkRatePerSecond, ref effectBlinkAccum))
            {
                bar.color = effectBlinkColor;
                if (effectBurnBar != null)
                {
                    effectBurnBar.alpha = 0;
                }
            }
            else
            {
                bar.color = colorVisible;
                if (effectBurnBar != null)
                {
                    effectBurnBar.alpha = 1;
                    effectBurnBar.color = effectBlinkBaseColorBurn;
                }
            }
        }
    }