Aimbot-ParallelEnv/Assets/Script/GameScript/Character/States.cs

59 lines
1.1 KiB
C#
Raw Normal View History

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<AgentController>().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;
}
}