diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/StatsWhenFullHP.cs |
+ init
Diffstat (limited to 'GameCode/StatsWhenFullHP.cs')
-rw-r--r-- | GameCode/StatsWhenFullHP.cs | 58 |
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(); + } + } +} |