From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/StatsWhenFullHP.cs | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 GameCode/StatsWhenFullHP.cs (limited to 'GameCode/StatsWhenFullHP.cs') 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(); + } + + 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(); + } + } +} -- cgit v1.1-26-g67d0