From b1a45c232474e99b52eadc43406ab7de15b7ee95 Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Tue, 12 May 2026 08:49:44 +0800 Subject: Add health system --- Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs | 55 ----------------------- 1 file changed, 55 deletions(-) delete mode 100644 Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs (limited to 'Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs') diff --git a/Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs b/Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs deleted file mode 100644 index c301d4a..0000000 --- a/Assets/Scripts/DamageVolumeSystem/SimpleHealth.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using UnityEngine; - -namespace DamageVolumeSystem -{ - [RequireComponent(typeof(Rigidbody))] - public class SimpleHealth : MonoBehaviour - { - public int max = 10000; - public int health = 10000; - - private Rigidbody _rigidbody; - - private void Start() - { - _rigidbody = GetComponent(); - } - - public void Damage(Damage amount) - { - health -= amount.Force; - health = Mathf.Clamp(health, 0, max); - - _rigidbody.AddForce(amount.Direction * amount.Force / 200); - } - - public void Heal(Damage amount) - { - health += amount.Force; - health = Mathf.Clamp(health, 0, max); - } - - private void OnDrawGizmos() - { - var t = transform; - var size = (t.lossyScale.x + t.lossyScale.y + t.lossyScale.z) / 3; - - Gizmos.matrix = t.localToWorldMatrix; - - Gizmos.DrawWireCube(new Vector3(0, size, 0), new Vector3( - 2 / t.lossyScale.x, - 0.5f / t.lossyScale.y, - 0.5f / t.lossyScale.z - ) * size); - - Gizmos.color = new Color(1f, 0.44f, 0.37f); - - Gizmos.DrawCube(new Vector3(0, size, 0), new Vector3( - 2 / t.lossyScale.x * ((float) health / max), - 0.5f / t.lossyScale.y, - 0.5f / t.lossyScale.z - ) * size * 0.8f); - } - } -} -- cgit