Aimbot-ParallelEnv/Assets/Script/InGame/states.cs
Koha9 630cbc4f70 V3.1.5 修正PlayMode中TargetUI问题
修正TargetUI初始化StayMode Button可使用的问题
修正TargetUI可使用按钮逻辑问题
修正TargetUI与TargetController联动问题
修正Enemy击杀后不死亡问题
2023-07-28 19:44:02 +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<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;
}
}