summaryrefslogtreecommitdiff
path: root/Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-20 22:36:58 +0800
committerchai <215380520@qq.com>2024-05-20 22:36:58 +0800
commita22c505984697881f5f911a165ee022087b69e09 (patch)
treed3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs
parent4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff)
*renameHEADmaster
Diffstat (limited to 'Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs')
-rw-r--r--Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs203
1 files changed, 0 insertions, 203 deletions
diff --git a/Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs b/Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs
deleted file mode 100644
index ac4a246..0000000
--- a/Thronefall_1_0/Decompile/TFUIUpgradeChoice.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-using System;
-using MPUIKIT;
-using UnityEngine;
-using UnityEngine.UI;
-
-public class TFUIUpgradeChoice : ThronefallUIElement
-{
- [Serializable]
- public class Style
- {
- public float scale = 1f;
-
- public Color outlineColor;
-
- public Color bgColor;
-
- public AnimationCurve animationCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
-
- public float animationDuration = 0.5f;
-
- public Style(Color outlineColor, Color bgColor, AnimationCurve animationCurve, float animationDuration, float scale)
- {
- this.scale = scale;
- this.bgColor = bgColor;
- this.outlineColor = outlineColor;
- this.animationCurve = animationCurve;
- this.animationDuration = animationDuration;
- }
- }
-
- public class Animation
- {
- public TFUIUpgradeChoice target;
-
- public Style startStyle;
-
- public Style endStyle;
-
- public float clock;
-
- public Animation(Style startStyle, Style endStyle, TFUIUpgradeChoice target)
- {
- this.startStyle = startStyle;
- this.endStyle = endStyle;
- this.target = target;
- target.ApplyStyle(startStyle);
- target.currentAnimation = this;
- }
-
- public void Tick()
- {
- clock += Time.unscaledDeltaTime;
- float num = Mathf.InverseLerp(0f, endStyle.animationDuration, clock);
- float t = endStyle.animationCurve.Evaluate(num);
- target.iconImg.color = Color.Lerp(startStyle.outlineColor, endStyle.outlineColor, t);
- target.backgroundImg.color = Color.Lerp(startStyle.bgColor, endStyle.bgColor, t);
- target.backgroundImg.OutlineColor = Color.Lerp(startStyle.outlineColor, endStyle.outlineColor, t);
- target.backgroundImg.transform.localScale = Vector3.one * Mathf.LerpUnclamped(startStyle.scale, endStyle.scale, t);
- if (num >= 1f)
- {
- target.ApplyStyle(endStyle);
- target.currentAnimation = null;
- }
- }
- }
-
- [SerializeField]
- private Color lockedBgColor;
-
- [SerializeField]
- private Color lockedOutlineColor;
-
- [SerializeField]
- private MPImageBasic backgroundImg;
-
- [SerializeField]
- private Image iconImg;
-
- [SerializeField]
- private Sprite lockIcon;
-
- public AnimationCurve defaultAnimationCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
-
- public float defaultAnimationTime = 0.3f;
-
- public Style focussedStyle;
-
- public Style selectedStyle;
-
- public Style focussedAndSelectedStyle;
-
- private Style defaultStyle;
-
- private bool defaultStyleInitialized;
-
- private Animation currentAnimation;
-
- private Choice choiceData;
-
- private Color defaultBgColor;
-
- private Color defaultIconColor;
-
- private bool locked;
-
- public Choice Data => choiceData;
-
- public bool Locked => locked;
-
- public Image IconImg => iconImg;
-
- private void Update()
- {
- if (currentAnimation != null)
- {
- currentAnimation.Tick();
- }
- }
-
- protected override void OnApply()
- {
- }
-
- protected override void OnClear()
- {
- new Animation(GetStyle(previousState), defaultStyle, this);
- }
-
- protected override void OnFocus()
- {
- new Animation(GetStyle(previousState), focussedStyle, this);
- }
-
- protected override void OnSelect()
- {
- new Animation(GetStyle(previousState), selectedStyle, this);
- }
-
- protected override void OnFocusAndSelect()
- {
- new Animation(GetStyle(previousState), focussedAndSelectedStyle, this);
- }
-
- protected override void OnHardStateSet(SelectionState selectionState)
- {
- currentAnimation = null;
- ApplyStyle(GetStyle(selectionState));
- }
-
- protected Style GetStyle(SelectionState state)
- {
- if (!defaultStyleInitialized)
- {
- InitializeDefaultStyle();
- }
- return state switch
- {
- SelectionState.Default => defaultStyle,
- SelectionState.Focussed => focussedStyle,
- SelectionState.Selected => selectedStyle,
- SelectionState.FocussedAndSelected => focussedAndSelectedStyle,
- _ => defaultStyle,
- };
- }
-
- private void ApplyStyle(Style style)
- {
- iconImg.color = style.outlineColor;
- backgroundImg.color = style.bgColor;
- backgroundImg.OutlineColor = style.outlineColor;
- backgroundImg.transform.localScale = Vector3.one * style.scale;
- }
-
- private void InitializeDefaultStyle()
- {
- defaultBgColor = backgroundImg.color;
- defaultIconColor = iconImg.color;
- defaultStyle = new Style(backgroundImg.OutlineColor, backgroundImg.color, defaultAnimationCurve, defaultAnimationTime, 1f);
- defaultStyleInitialized = true;
- }
-
- public void SetData(Choice _choice)
- {
- choiceData = _choice;
- bool flag = true;
- if (_choice.requiresUnlocked != null && !PerkManager.instance.UnlockedEquippables.Contains(_choice.requiresUnlocked))
- {
- flag = false;
- }
- if (flag)
- {
- iconImg.sprite = _choice.icon;
- return;
- }
- iconImg.sprite = lockIcon;
- iconImg.color = lockedOutlineColor;
- backgroundImg.color = lockedBgColor;
- backgroundImg.OutlineColor = lockedOutlineColor;
- selectedStyle.bgColor = lockedBgColor;
- selectedStyle.outlineColor = lockedOutlineColor;
- locked = true;
- }
-}