102 lines
2.1 KiB
C#
102 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class enemy : Role
|
|
{
|
|
public override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
if (camp == Camp.Enemy)
|
|
{
|
|
//开始移动
|
|
Init(InitEnenyData.instance.GetRandomWaypoints());
|
|
}
|
|
}
|
|
|
|
public void Init(waypoints _waypoints)
|
|
{
|
|
base.Navigation.waypoints = _waypoints;
|
|
|
|
//开始移动
|
|
Navigation.MoveToNextWaypoint(this.gameObject);
|
|
|
|
}
|
|
|
|
public override void die()
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
|
|
// 将当前敌人对象放入死亡池
|
|
if (SpawnPool.intance != null)
|
|
{
|
|
SkillBox.instance.UpdataExp(10);
|
|
SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // 回收当前敌人到池中
|
|
ResetAllStatus();
|
|
}
|
|
|
|
UIContorl.instance.Killnumber += 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置角色所有状态
|
|
/// </summary>
|
|
public void ResetAllStatus()
|
|
{
|
|
// 重置血量
|
|
Hp = 100f;
|
|
|
|
// 重置攻击力
|
|
Attack = 10f;
|
|
|
|
// 重置护甲
|
|
physicalArmor = 10;
|
|
magicArmor = 5;
|
|
|
|
// 重置等级
|
|
Level = 1;
|
|
|
|
// 重置金币
|
|
Gold = 10f;
|
|
|
|
// 清空 Buff 列表
|
|
buffList.Clear();
|
|
|
|
// 如果有导航组件,停止当前的导航行为
|
|
if (Navigation != null)
|
|
{
|
|
//Navigation.Stop(); // 假设你有 Stop 方法来停止导航
|
|
}
|
|
|
|
// 重置角色动画
|
|
animationHighlight = 0;
|
|
isAnimationPlay = false;
|
|
|
|
// 重置碰撞体(根据需求是否需要调整)
|
|
if (mycollider != null)
|
|
{
|
|
mycollider.enabled = true; // 启用碰撞体
|
|
}
|
|
|
|
|
|
|
|
// 如果有其他需要重置的状态,可以在这里添加
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
// Debug.Log("进入范围检测");
|
|
if (this.camp == Camp.Enemy && collision.tag == "House")
|
|
{
|
|
UIContorl.instance.Hp -= 1;
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|
|
}
|