143 lines
3.7 KiB
C#
143 lines
3.7 KiB
C#
//using System.Collections;
|
|
//using System.Collections.Generic;
|
|
//using UnityEngine;
|
|
//using System;
|
|
//using Manager;
|
|
|
|
|
|
//普通怪物
|
|
//public class EnemyController : MonoBehaviour
|
|
//{
|
|
// public GameObject attackVFX;
|
|
|
|
// [Header("移动速度")] public float currentSpeed;
|
|
// [Header("攻击")]
|
|
// [SerializeField] private bool isAttack = true;
|
|
// [SerializeField] private float attackCollDuration = 1;
|
|
|
|
// private bool isDead=false;
|
|
// public Vector2 MoveInput
|
|
// {
|
|
// get;set;
|
|
// }
|
|
|
|
// private Enemy enemy;
|
|
|
|
// private Rigidbody2D rb;
|
|
// private SpriteRenderer sr;
|
|
// private Animator animator;
|
|
// private Collider2D colliderEnemy;
|
|
|
|
// [Header("攻击,间隔")]
|
|
// public float attackDamage = 20;
|
|
// public float attackDuration = 1.5f;
|
|
// public LayerMask playerLayer;
|
|
|
|
// private void Awake()
|
|
// {
|
|
// rb = transform.parent.GetComponent<Rigidbody2D>();
|
|
// colliderEnemy = transform.parent.GetComponent<Collider2D>();
|
|
// sr = GetComponent<SpriteRenderer>();
|
|
// animator = GetComponent<Animator>();
|
|
// enemy = transform.parent.GetComponent<Enemy>();
|
|
// }
|
|
// private void Start()
|
|
// {
|
|
// enemy.OnAttack += OnAttack;
|
|
// }
|
|
|
|
// private void FixedUpdate()
|
|
// {
|
|
// if(!isDead)
|
|
// {
|
|
// OnMove();
|
|
// }
|
|
// SetAnimation();
|
|
// }
|
|
// private void OnMove()
|
|
// {
|
|
// if (MoveInput.magnitude > 0.1f && currentSpeed > 0)
|
|
// {
|
|
// rb.velocity = MoveInput * currentSpeed;
|
|
// if(MoveInput.x<0)
|
|
// {
|
|
// sr.flipX = false;
|
|
// }
|
|
// if (MoveInput.x > 0)
|
|
// {
|
|
// sr.flipX = true;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// rb.velocity = Vector2.zero;
|
|
// }
|
|
// }
|
|
// void OnAttack()
|
|
// {
|
|
// if(isAttack)
|
|
// {
|
|
// isAttack = false;
|
|
// StartCoroutine(nameof(AttackCoroutine));
|
|
// }
|
|
// }
|
|
// IEnumerator AttackCoroutine()
|
|
// {
|
|
// animator.SetTrigger("Attack");
|
|
|
|
// yield return new WaitForSeconds(attackCollDuration);
|
|
// isAttack = true;
|
|
// }
|
|
|
|
// public void EnemyHurt()
|
|
// {
|
|
// animator.SetTrigger("Hurt");
|
|
// }
|
|
// public void EnemyDead()
|
|
// {
|
|
// rb.velocity = Vector2.zero;
|
|
// isDead = true;
|
|
// colliderEnemy.enabled = false;
|
|
// }
|
|
// void SetAnimation()
|
|
// {
|
|
// animator.SetBool("isWalk",MoveInput.magnitude>0);
|
|
// animator.SetBool("isDead", isDead);
|
|
// }
|
|
// public void DestoryEnemy()
|
|
// {
|
|
// Destroy(transform.parent.gameObject);
|
|
// }
|
|
|
|
// public void MelleeAttackAnimEvent()
|
|
// {
|
|
// Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, enemy.attackDistance, playerLayer);
|
|
|
|
|
|
// foreach (Collider2D hitInfo in hitColliders)
|
|
// {
|
|
// hitInfo.transform.root.GetComponentInChildren<CharacterCombat>().TakeDamage();
|
|
// }
|
|
// }
|
|
// public void YuanChengAttackAnimEvent(string name)
|
|
// {
|
|
// Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, enemy.attackDistance, playerLayer);
|
|
|
|
// foreach (Collider2D hitInfo in hitColliders)
|
|
// {
|
|
// GameObject go=Instantiate(attackVFX,transform.position,Quaternion.identity);
|
|
// go.AddComponent<VFXMove>();
|
|
// }
|
|
// }
|
|
|
|
// public void Protected(string name)
|
|
// {
|
|
// string monster = "Perfab/Monsters/" + name;
|
|
// UnityEngine.Object go =Resloader.Load<GameObject>(monster);
|
|
// if(go!=null)
|
|
// {
|
|
// GameObject m= (GameObject)Instantiate(go,transform.root);
|
|
// }
|
|
// }
|
|
//}
|