65 lines
1.5 KiB
C#
65 lines
1.5 KiB
C#
//using System;
|
|
//using System.Collections;
|
|
//using System.Collections.Generic;
|
|
//using UnityEngine;
|
|
//using UnityEngine.Events;
|
|
|
|
|
|
//普通怪物
|
|
//public class Enemy : CharacterManager
|
|
//{
|
|
// [Header("距离")]
|
|
// public float cheseDistance = 3f;
|
|
// public float attackDistance = 0.8f;
|
|
|
|
// public UnityEvent<Vector2> OnMoveInput;
|
|
// public Action OnAttack;
|
|
|
|
// private Transform player;
|
|
|
|
// //玩家与敌人的距离方向
|
|
// private float dis;
|
|
// private Vector2 dir;
|
|
|
|
|
|
// private void Awake()
|
|
// {
|
|
// player = GameObject.FindWithTag("Player").transform;
|
|
// }
|
|
|
|
// private void Update()
|
|
// {
|
|
// if (player == null)
|
|
// return;
|
|
// dis = Vector2.Distance(player.position,transform.position);
|
|
// if(dis<cheseDistance)
|
|
// {
|
|
// //追击
|
|
// if(dis<=attackDistance)
|
|
// {
|
|
// OnMoveInput?.Invoke(Vector2.zero);
|
|
// //攻击
|
|
// OnAttack?.Invoke();
|
|
// }
|
|
// else
|
|
// {
|
|
// dir = player.position - transform.position;
|
|
// OnMoveInput?.Invoke(dir.normalized);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// OnMoveInput?.Invoke(Vector2.zero);//放弃追击
|
|
// }
|
|
// }
|
|
// private void OnDrawGizmosSelected()
|
|
// {
|
|
|
|
// Gizmos.color = Color.yellow;
|
|
// Gizmos.DrawWireSphere(transform.position,cheseDistance);
|
|
|
|
// Gizmos.color = Color.red;
|
|
// Gizmos.DrawWireSphere(transform.position, attackDistance);
|
|
// }
|
|
//}
|