Ejemplo n.º 1
0
 public StatusItemEntry(StatusItemGroup.Entry item, StatusItemCategory category, GameObject status_item_prefab, Transform parent, TextStyleSetting tooltip_style, Color color, TextStyleSetting style, bool skip_fade, Action <StatusItemEntry> onDestroy)
 {
     this.item      = item;
     this.category  = category;
     tooltipStyle   = tooltip_style;
     this.onDestroy = onDestroy;
     this.color     = color;
     this.style     = style;
     widget         = Util.KInstantiateUI(status_item_prefab, parent.gameObject, false);
     text           = widget.GetComponentInChildren <LocText>(true);
     SetTextStyleSetting.ApplyStyle(text, style);
     toolTip = widget.GetComponentInChildren <ToolTip>(true);
     image   = widget.GetComponentInChildren <Image>(true);
     item.SetIcon(image);
     widget.SetActive(true);
     toolTip.OnToolTip = OnToolTip;
     button            = widget.GetComponentInChildren <KButton>();
     if (item.item.statusItemClickCallback != null)
     {
         button.onClick += OnClick;
     }
     else
     {
         button.enabled = false;
     }
     fadeStage = (skip_fade ? FadeStage.WAIT : FadeStage.IN);
     SimAndRenderScheduler.instance.Add(this, false);
     Refresh();
     SetColor(1f);
 }
Ejemplo n.º 2
0
        public void RenderEveryTick(float dt)
        {
            switch (fadeStage)
            {
            case FadeStage.IN:
            {
                fade = Mathf.Min(fade + Time.deltaTime / fadeInTime, 1f);
                float num2 = fade;
                SetColor(num2);
                if (fade >= 1f)
                {
                    fadeStage = FadeStage.WAIT;
                }
                break;
            }

            case FadeStage.OUT:
            {
                float num = fade;
                SetColor(num);
                fade = Mathf.Max(fade - Time.deltaTime / fadeOutTime, 0f);
                if (fade <= 0f)
                {
                    Destroy(true);
                }
                break;
            }
            }
        }
Ejemplo n.º 3
0
 public FadeScreen()
 {
     mAlphaValue = 0;
     mFadeIncrement = 40;
     mFadeDelay = .035;
     mFadeState = FadeStage.FadeStop;
 }
Ejemplo n.º 4
0
 public FadeScreen()
 {
     mAlphaValue    = 0;
     mFadeIncrement = 40;
     mFadeDelay     = .035;
     mFadeState     = FadeStage.FadeStop;
 }
Ejemplo n.º 5
0
 public void ScreenFadeOut(GameTime gameTime, int fadeIncrement, int alpha)
 {
     mFadeIncrement = fadeIncrement;
     mFadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;
     if (mFadeDelay <= 0 && mAlphaValue >= alpha)
     {
         mFadeDelay = .035;
         mAlphaValue -= mFadeIncrement;
         mFadeState = FadeStage.FadeOut;
     }
     if (mAlphaValue < alpha)
         mFadeState = FadeStage.FadeStop;
 }
Ejemplo n.º 6
0
 public void ScreenFadeOut(GameTime gameTime, int fadeIncrement, int alpha)
 {
     mFadeIncrement = fadeIncrement;
     mFadeDelay    -= gameTime.ElapsedGameTime.TotalSeconds;
     if (mFadeDelay <= 0 && mAlphaValue >= alpha)
     {
         mFadeDelay   = .035;
         mAlphaValue -= mFadeIncrement;
         mFadeState   = FadeStage.FadeOut;
     }
     if (mAlphaValue < alpha)
     {
         mFadeState = FadeStage.FadeStop;
     }
 }
Ejemplo n.º 7
0
 public void Destroy(bool immediate)
 {
     if (immediate)
     {
         if (onDestroy != null)
         {
             onDestroy(this);
         }
         SimAndRenderScheduler.instance.Remove(this);
         toolTip.OnToolTip = null;
         UnityEngine.Object.Destroy(widget);
     }
     else
     {
         fade      = 0.5f;
         fadeStage = FadeStage.OUT;
     }
 }
Ejemplo n.º 8
0
        public override void Update(DeltaTime deltaTime)
        {
            fadeTime += deltaTime.Seconds;
            float alpha;
            Color c;

            switch (CurrentFadeStage)
            {
            case FadeStage.FadeOut:

                Current.Update(deltaTime);

                alpha = ((fadeTime / FadeOutDuration) * 255f);

                if (alpha < 0 || alpha > 255)
                {
                    alpha = 255;
                }

                c = Color.FromArgb((int)alpha, 0, 0, 0);

                graphics.FillRectangle(new SolidBrush(c), 0, 0, Program.Width, Program.Height);

                if (fadeTime >= FadeOutDuration)
                {
                    fadeTime = 0;
                    if (PauseDuration > 0)
                    {
                        CurrentFadeStage = FadeStage.Pause;
                    }
                    else
                    {
                        CurrentFadeStage = FadeStage.FadeIn;
                    }
                }

                break;

            case FadeStage.Pause:

                graphics.FillRectangle(Brushes.Black, 0, 0, Program.Width, Program.Height);

                if (fadeTime >= PauseDuration)
                {
                    fadeTime         = 0;
                    CurrentFadeStage = FadeStage.FadeIn;
                }

                break;

            case FadeStage.FadeIn:

                New.Update(deltaTime);

                alpha = ((1f - (fadeTime / FadeInDuration)) * 255f);

                if (alpha < 0 || alpha > 255)
                {
                    alpha = 0;
                }

                c = Color.FromArgb((int)alpha, 0, 0, 0);

                graphics.FillRectangle(new SolidBrush(c), 0, 0, Program.Width, Program.Height);

                if (fadeTime >= FadeInDuration)
                {
                    Program.SetCurrentState(New);
                }

                break;
            }
        }