summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/BlacksmithUpgrade.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_v1.0/Decompile/BlacksmithUpgrade.cs
parent4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff)
*renameHEADmaster
Diffstat (limited to 'Thronefall_v1.0/Decompile/BlacksmithUpgrade.cs')
-rw-r--r--Thronefall_v1.0/Decompile/BlacksmithUpgrade.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/BlacksmithUpgrade.cs b/Thronefall_v1.0/Decompile/BlacksmithUpgrade.cs
new file mode 100644
index 0000000..9022dc2
--- /dev/null
+++ b/Thronefall_v1.0/Decompile/BlacksmithUpgrade.cs
@@ -0,0 +1,88 @@
+using UnityEngine;
+
+public class BlacksmithUpgrade : MonoBehaviour, DayNightCycle.IDaytimeSensitive
+{
+ [SerializeField]
+ private BuildingInteractor buildingInteractor;
+
+ [SerializeField]
+ private ProductionBar productionBar;
+
+ [SerializeField]
+ private Weapon.EDamageAffectedByBlacksmithUpgrade upgrade;
+
+ [SerializeField]
+ private float multiplyer = 1.2f;
+
+ [SerializeField]
+ private int researchTime = 2;
+
+ [SerializeField]
+ private Equippable researchSpeedPerk;
+
+ private int researchTimeLeft;
+
+ private void Start()
+ {
+ DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
+ }
+
+ public void OnDawn_AfterSunrise()
+ {
+ }
+
+ public void OnDawn_BeforeSunrise()
+ {
+ if (!base.gameObject.activeInHierarchy)
+ {
+ return;
+ }
+ researchTimeLeft--;
+ Debug.Log(researchTimeLeft);
+ UpdateProgressBar();
+ if (researchTimeLeft <= 0)
+ {
+ productionBar.gameObject.SetActive(value: false);
+ switch (upgrade)
+ {
+ case Weapon.EDamageAffectedByBlacksmithUpgrade.MultiplyBy_MeleeDamage:
+ BlacksmithUpgrades.instance.meleeDamage *= multiplyer;
+ break;
+ case Weapon.EDamageAffectedByBlacksmithUpgrade.MultiplyBy_RangedDamage:
+ BlacksmithUpgrades.instance.rangedDamage *= multiplyer;
+ break;
+ case Weapon.EDamageAffectedByBlacksmithUpgrade.DivideBy_MeleeResistance:
+ BlacksmithUpgrades.instance.meleeResistance *= multiplyer;
+ break;
+ case Weapon.EDamageAffectedByBlacksmithUpgrade.DivideBy_RangedResistance:
+ BlacksmithUpgrades.instance.rangedResistance *= multiplyer;
+ break;
+ }
+ buildingInteractor.buildingIsCurrentlyBusyAndCantBeUpgraded = false;
+ buildingInteractor.UpdateInteractionState();
+ DayNightCycle.Instance.UnregisterDaytimeSensitiveObject(this);
+ }
+ }
+
+ public void OnDusk()
+ {
+ }
+
+ private void OnEnable()
+ {
+ researchTimeLeft = researchTime;
+ if (PerkManager.IsEquipped(researchSpeedPerk))
+ {
+ researchTimeLeft--;
+ }
+ UpdateProgressBar();
+ buildingInteractor.buildingIsCurrentlyBusyAndCantBeUpgraded = true;
+ buildingInteractor.UpdateInteractionState();
+ }
+
+ private void UpdateProgressBar()
+ {
+ productionBar.gameObject.SetActive(value: true);
+ productionBar.UpdateVisual(1f - (float)researchTimeLeft / ((float)researchTime + 0.1f));
+ }
+}