43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using SepCore.AsyncTask;
|
|
using SepCore.Definition;
|
|
using SepCore.Entity;
|
|
using UnityEngine;
|
|
|
|
public abstract class EnemyBase : TargetableObject
|
|
{
|
|
protected Transform _target;
|
|
|
|
public abstract override ImpactData GetImpactData();
|
|
public virtual float AttackRange => 1f;
|
|
|
|
public virtual void SetTarget(Transform target) => _target = target;
|
|
|
|
protected EnemyData _enemyData;
|
|
|
|
|
|
protected override void OnDead(EntityBase attacker)
|
|
{
|
|
if (Random.value < _enemyData.DropPercent)
|
|
{
|
|
var data = new CoinData(_enemyData.DropCoin, GameEntry.Entity.NextId(), 10001)
|
|
{
|
|
Position = this.CachedTransform.position
|
|
};
|
|
GameEntry.Entity.ShowCoinAsync(data).Forget();
|
|
}
|
|
|
|
if (Random.value < _enemyData.DropPercent)
|
|
{
|
|
var data = new ExpData(_enemyData.DropExp, GameEntry.Entity.NextId(), 10002)
|
|
{
|
|
Position = this.CachedTransform.position
|
|
};
|
|
GameEntry.Entity.ShowExpAsync(data).Forget();
|
|
}
|
|
|
|
base.OnDead(attacker);
|
|
}
|
|
}
|
|
|