Aimbot-ParallelEnv/Assets/Script/InGame/states.cs
Koha9 cfccd12820 V3.1.1 优化代码
优化可读性与规范化命名方式
2023-06-30 18:30:12 +09:00

59 lines
1.1 KiB
C#

using UnityEngine;
public class States : MonoBehaviour
{
public bool isDead = false;
public float maxHP = 100;
private float myHP = 100;
private void Start()
{
myHP = maxHP;
}
private void Update()
{
}
private void DetactDeath()
{
if (myHP <= 0)
{
Destroy(this.gameObject);
isDead = true;
}
}
// while got hit
public void ReactToHit(float Damage, GameObject damageSource)
{
myHP -= Damage;
Debug.Log("HP:" + myHP);
if (myHP <= 0)
{
if (damageSource.tag == "Player")
{
damageSource.GetComponent<AgentWithGun>().KillRecord(transform.position);
Destroy(this.gameObject);
isDead = true;
}
else
{
Destroy(this.gameObject);
isDead = true;
}
}
}
// get my hp from other script
public float GetnowHP()
{
return myHP;
}
public void DestroyMe()
{
Destroy(this.gameObject);
isDead = true;
}
}