summaryrefslogtreecommitdiff
path: root/ROUNDS/Photon.Pun.Simple/SimulateHealth.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ROUNDS/Photon.Pun.Simple/SimulateHealth.cs')
-rw-r--r--ROUNDS/Photon.Pun.Simple/SimulateHealth.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/ROUNDS/Photon.Pun.Simple/SimulateHealth.cs b/ROUNDS/Photon.Pun.Simple/SimulateHealth.cs
new file mode 100644
index 0000000..fb143ff
--- /dev/null
+++ b/ROUNDS/Photon.Pun.Simple/SimulateHealth.cs
@@ -0,0 +1,47 @@
+using UnityEngine;
+
+namespace Photon.Pun.Simple;
+
+public class SimulateHealth : MonoBehaviour
+{
+ private Vitals vitals;
+
+ public VitalNameType vitalType = new VitalNameType(VitalType.Health);
+
+ public KeyCode AddHealthKey = KeyCode.Alpha6;
+
+ public KeyCode RemHealthKey = KeyCode.Alpha7;
+
+ public KeyCode DamagehKey = KeyCode.Alpha8;
+
+ public float amount = 20f;
+
+ private void Start()
+ {
+ IVitalsSystem componentInChildren = GetComponentInChildren<IVitalsSystem>();
+ if (componentInChildren == null || !(componentInChildren as SyncObject).PhotonView.IsMine)
+ {
+ Object.Destroy(this);
+ }
+ else
+ {
+ vitals = componentInChildren.Vitals;
+ }
+ }
+
+ private void Update()
+ {
+ if (Input.GetKeyDown(AddHealthKey))
+ {
+ vitals.ApplyCharges(vitalType, amount, allowOverload: false, propagate: false);
+ }
+ if (Input.GetKeyDown(RemHealthKey))
+ {
+ vitals.ApplyCharges(vitalType, 0f - amount, allowOverload: false, propagate: true);
+ }
+ if (Input.GetKeyDown(DamagehKey))
+ {
+ vitals.ApplyCharges(amount, allowOverload: false, propagate: true);
+ }
+ }
+}