Aimbot-ParallelEnv/Assets/Script/InGame/states.cs
Koha9 25eac00c53 Target & dynamic reward System V1.0
太多了...总之能用了,就这样吧,也懒得用英文写了(;´Д`)
ParameterContainer用于管理所有的Reward和Parameter.
TargetController用于生成目标,然后再让SceneBlockContainer实际生成目标块,并且兼顾reward计算功能和目标观察结果的获取.
EnemyContainer用于生成和删除敌人.
SceneBlockContainer用于生成和删除目标块.

States用于管理HP.
SceneBlock用于管理目标块的...一堆东西,比如目标大小,目标区内人数等和目标所属状态等.
2022-11-29 07:54:08 +09:00

59 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class states : MonoBehaviour
{
public bool isDead = false;
public float MaxHP = 100;
float myHP = 100;
void Start()
{
myHP = MaxHP;
}
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;
}
}