Beispiel #1
0
        protected override void Update()
        {
            base.Update();

            UpdateSize();

            if (!IsValid())
            {
                return;
            }

            if (textureBar != _textureBar) // texture bar dirty?
            {
                textureBarVisibleBoundsOrig = FindBounds(textureBar);
                if (textureBarVisibleBoundsOrig.width == 0) // not readable (yet)
                {
                    return;
                }

                textureBarVisibleBounds = textureBarVisibleBoundsOrig;
                _textureBar             = textureBar;
            }

//        FixRatio();

            // update blink effect
            if (effectBlink)
            {
                effectBlinkVisible = EnergyBarCommons.Blink(
                    energyBar.ValueF, effectBlinkValue, effectBlinkRatePerSecond, ref effectBlinkAccum);
            }
        }
Beispiel #2
0
 private void UpdateBlinkEffect() {
     if (forceBlinking) {
         Blink = EnergyBarCommons.Blink(effectBlinkRatePerSecond, ref _effectBlinkAccum);
     } else if (CanBlink()) {
         Blink = EnergyBarCommons.Blink(effectBlinkRatePerSecond, ref _effectBlinkAccum);
     } else {
         Blink = false;
     }
 }
Beispiel #3
0
 protected override void Update() {
     base.Update();
 
     if (RebuildNeeded()) {
         Rebuild();
     }
     
     if (effectSmoothChange) {
         EnergyBarCommons.SmoothDisplayValue(ref actualDisplayValue, energyBar.ValueF, effectSmoothChangeSpeed);
     } else {
         actualDisplayValue = energyBar.ValueF;
     }
     
     UpdateBar();
     UpdateVisible();
 }
Beispiel #4
0
    protected override void Update() {
        if (RebuildNeeded()) {
            Rebuild();
        }

        base.Update();

        if (effectBlink) {
            Blink = EnergyBarCommons.Blink(
                ValueF, effectBlinkValue, effectBlinkRatePerSecond, ref _effectBlinkAccum);
        } else {
            Blink = false;
        }

        UpdateBar();
        UpdatePivot();
        UpdateFollowEffect();
    }
Beispiel #5
0
        new void OnGUI()
        {
            base.OnGUI();

            if (!RepaintPhase())
            {
                return;
            }

            if (!IsVisible())
            {
                return;
            }

            if (!IsValid())
            {
                return;
            }

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

            Rect texCoords;
            var  texture = GetTexture(out texCoords);

            if (texture != null)
            {
                GUIDrawBackground();

                var s   = Round(SizePixels);
                var pos = RealPosition(Round(PositionPixels), s);
                DrawTexture(new Rect(pos.x, pos.y, s.x, s.y), texture, texCoords, color);

                GUIDrawForeground();
            }

            GUIDrawLabel();
        }
Beispiel #6
0
        new void OnGUI()
        {
            base.OnGUI();

            if (!RepaintPhase())
            {
                return;
            }

            if (!IsVisible())
            {
                return;
            }

            if (!IsValid())
            {
                return;
            }

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

            var pos   = RealPosition(Round(StartPositionPixels), SizePixels);
            var iSize = SizePixels;
            var delta = PositionDeltaPixels;

            float iconCount     = actualDisplayValue * repeatCount;
            int   baseIconCount = (int)Mathf.Floor(iconCount); // icons painted at full visibility
            float lastIconValue = iconCount - baseIconCount;

            for (int i = 0; i < repeatCount; ++i)
            {
                // draw slots if set
                if (iconSlot != null)
                {
                    DrawTexture(new Rect(pos.x, pos.y, iSize.x, iSize.y), iconSlot, iconSlotColor);
                }

                if (i < baseIconCount) // draw solid icons
                {
                    DrawTexture(new Rect(pos.x, pos.y, iSize.x, iSize.y), icon, iconColor);
                }
                else if (i == baseIconCount) // draw growing icon
                {
                    var iconRect = new Rect(pos.x, pos.y, iSize.x, iSize.y);

                    switch (effect)
                    {
                    case Effect.FadeOut:
                        var tint = new Color(iconColor.r, iconColor.g, iconColor.b, iconColor.a * lastIconValue);
                        DrawTexture(new Rect(pos.x, pos.y, iSize.x, iSize.y), icon, tint);
                        break;

                    case Effect.GrowIn:
                        var rect = Resize(iconRect, lastIconValue);
                        DrawTexture(rect, icon, iconColor);
                        break;

                    case Effect.Cut:
                        switch (cutDirection)
                        {
                        case CutDirection.BottomToTop:
                            DrawTextureVertFill(iconRect, icon, new Rect(0, 0, 1, 1), iconColor, false, lastIconValue);
                            break;

                        case CutDirection.TopToBottom:
                            DrawTextureVertFill(iconRect, icon, new Rect(0, 0, 1, 1), iconColor, true, lastIconValue);
                            break;

                        case CutDirection.LeftToRight:
                            DrawTextureHorizFill(iconRect, icon, new Rect(0, 0, 1, 1), iconColor, false, lastIconValue);
                            break;

                        case CutDirection.RightToLeft:
                            DrawTextureHorizFill(iconRect, icon, new Rect(0, 0, 1, 1), iconColor, true, lastIconValue);
                            break;

                        default:
                            Debug.LogError("Unknown cut direction: " + cutDirection);
                            break;
                        }

                        break;
                    }
                }

                pos += Round(delta);
            }

            GUIDrawLabel();
        }
        void Update()
        {
            UpdateSize();

            if (!IsValid())
            {
                return;
            }

            if (textureBar != _textureBar) // texture bar dirty?
            {
                textureBarVisibleBoundsOrig = FindBounds(textureBar);
                if (textureBarVisibleBoundsOrig.width == 0) // not readable (yet)
                {
                    return;
                }

                textureBarVisibleBounds = textureBarVisibleBoundsOrig;
                _textureBar             = textureBar;
            }

//        FixRatio();

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

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

                burnDisplayValue = actualDisplayValue;
            }

            // update blink effect
            if (effectBlink)
            {
                effectBlinkVisible = EnergyBarCommons.Blink(
                    energyBar.ValueF, effectBlinkValue, effectBlinkRatePerSecond, ref effectBlinkAccum);
            }
        }