summaryrefslogtreecommitdiff
path: root/GameCode/StatsWhenFullHP.cs
diff options
context:
space:
mode:
Diffstat (limited to 'GameCode/StatsWhenFullHP.cs')
-rw-r--r--GameCode/StatsWhenFullHP.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/GameCode/StatsWhenFullHP.cs b/GameCode/StatsWhenFullHP.cs
new file mode 100644
index 0000000..21166c7
--- /dev/null
+++ b/GameCode/StatsWhenFullHP.cs
@@ -0,0 +1,58 @@
+using Sonigon;
+using UnityEngine;
+
+public class StatsWhenFullHP : MonoBehaviour
+{
+ public bool playSound;
+
+ public SoundEvent soundPristineGrow;
+
+ public SoundEvent soundPristineShrink;
+
+ public float healthMultiplier = 1f;
+
+ public float sizeMultiplier = 1f;
+
+ public float healthThreshold = 0.95f;
+
+ private CharacterData data;
+
+ private bool isOn;
+
+ private void Start()
+ {
+ data = GetComponentInParent<CharacterData>();
+ }
+
+ private void Update()
+ {
+ bool flag = data.health / data.maxHealth >= healthThreshold;
+ if (flag == isOn)
+ {
+ return;
+ }
+ isOn = flag;
+ if (isOn)
+ {
+ if (playSound)
+ {
+ SoundManager.Instance.PlayAtPosition(soundPristineGrow, SoundManager.Instance.GetTransform(), base.transform);
+ }
+ data.health *= healthMultiplier;
+ data.maxHealth *= healthMultiplier;
+ data.stats.sizeMultiplier *= sizeMultiplier;
+ data.stats.ConfigureMassAndSize();
+ }
+ else
+ {
+ if (playSound)
+ {
+ SoundManager.Instance.PlayAtPosition(soundPristineShrink, SoundManager.Instance.GetTransform(), base.transform);
+ }
+ data.health /= healthMultiplier;
+ data.maxHealth /= healthMultiplier;
+ data.stats.sizeMultiplier /= sizeMultiplier;
+ data.stats.ConfigureMassAndSize();
+ }
+ }
+}