84 lines
1.7 KiB
C#
84 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class enemy : Role
|
|
{
|
|
public string enemyId;
|
|
[Header("移动速度")] public float moveSpeed;
|
|
|
|
[HideInInspector]
|
|
public float harmNumber=0;//伤害
|
|
|
|
|
|
public float HarmNumber
|
|
{
|
|
get=> harmNumber;
|
|
set
|
|
{
|
|
harmNumber=value;
|
|
Debug.Log(enemyId+"总伤害"+ harmNumber );
|
|
}
|
|
}
|
|
|
|
public override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
//
|
|
//moveSpeed += Random.Range(-0.5f,0.5f);
|
|
if (camp == Camp.Enemy)
|
|
{
|
|
if (AnimationTree!=null)
|
|
{
|
|
AnimationTree[0].CharacterAnimationFrameInterval = (int)(36/moveSpeed) ;
|
|
|
|
|
|
}
|
|
|
|
//开始移动
|
|
Init(InitEnenyData.instance.GetRandomWaypoints());
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public void Init(waypoints _waypoints)
|
|
{
|
|
base.Navigation.waypoints = _waypoints;
|
|
|
|
//开始移动
|
|
Navigation.MoveToNextWaypoint(this.gameObject,moveSpeed);
|
|
|
|
}
|
|
|
|
public override void die()
|
|
{
|
|
base.die();
|
|
if (Application.isPlaying)
|
|
{
|
|
// 将当前敌人对象放入死亡池
|
|
if (SpawnPool.intance != null )
|
|
{
|
|
|
|
SkillBox.instance.AddExperience(6,this.gameObject.transform);
|
|
}
|
|
|
|
UIContorl.instance.Killnumber += 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
// Debug.Log("进入范围检测");
|
|
if (this.camp == Camp.Enemy && collision.tag == "House")
|
|
{
|
|
UIContorl.instance.Hp -= 1;
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|
|
}
|