2024-11-26 22:01:14 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.AI;
|
|
|
|
|
2024-11-27 00:06:25 +08:00
|
|
|
public class Enemy : MonoBehaviour
|
2024-11-26 22:01:14 +08:00
|
|
|
{
|
|
|
|
public NavMeshAgent _agent;
|
2024-11-27 00:06:25 +08:00
|
|
|
public int bloodvolume;
|
2024-11-26 22:01:14 +08:00
|
|
|
public Transform player;
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
_agent = GetComponent<NavMeshAgent>();
|
|
|
|
player=GameObject.FindWithTag("Player").transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
setMoveTo(player);
|
2024-11-27 00:06:25 +08:00
|
|
|
if (bloodvolume <= 0)
|
|
|
|
{
|
|
|
|
//ToDo
|
|
|
|
|
|
|
|
Destroy(this.gameObject);
|
|
|
|
}
|
2024-11-26 22:01:14 +08:00
|
|
|
|
2024-11-27 00:06:25 +08:00
|
|
|
}
|
|
|
|
public void EnemyHpDown(int hp)
|
|
|
|
{
|
|
|
|
bloodvolume -= hp;
|
2024-11-26 22:01:14 +08:00
|
|
|
}
|
|
|
|
public void setMoveTo(Transform target)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_agent.SetDestination(target.position);
|
|
|
|
}
|
|
|
|
}
|