summaryrefslogtreecommitdiff
path: root/GameCode/StatsWhenFullHP.cs
blob: 21166c7cc15808f1dc66880ffc167170438d6cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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();
		}
	}
}