86 lines
1.9 KiB
C#
86 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class Mouster : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform lockTra;
|
|
public int Attack => attack;
|
|
[SerializeField] private int attack;
|
|
public int HitPoints => hitPoints;
|
|
[SerializeField] private int hitPoints;
|
|
public int Strength => strength;
|
|
[SerializeField] private int strength;
|
|
public int Dxterity => dexterity;
|
|
[SerializeField] private int dexterity;
|
|
public int CriticalStrike => criticalStrike;
|
|
[SerializeField] private int criticalStrike;
|
|
[SerializeField]
|
|
private MousterEntity entity;
|
|
public void StartMove(Transform tra)
|
|
{
|
|
lockTra = tra;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 初始化新怪物
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void InitMousterData(MousterEntity _entity)
|
|
{
|
|
entity = _entity;
|
|
entity.DeathAction = () =>
|
|
{
|
|
DeathEvent();
|
|
};
|
|
}
|
|
|
|
public void Move(Transform point)
|
|
{
|
|
if (transform.position.y - point.position.y>entity._data.Range)
|
|
{
|
|
transform.Translate(-transform.up * entity._data.Move* Time.deltaTime,Space.World);
|
|
}
|
|
else
|
|
{
|
|
if (entity.nextAttack<BattleManager.ins.NowTime)
|
|
{
|
|
BattleManager.ins.SetInjured(attack);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetInjured(int attack)
|
|
{
|
|
entity.SetInjured(attack);
|
|
}
|
|
|
|
public void DeathEvent()
|
|
{
|
|
entity.DeathAction = null;
|
|
StartCoroutine(Death());
|
|
}
|
|
|
|
IEnumerator Death()
|
|
{
|
|
yield return null;
|
|
BattleManager.ins.RemoveMouster(this);
|
|
}
|
|
|
|
public void MoustEvent()
|
|
{
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|