maint: moving around methods to work better with Unit/Player/Enemy classes
This commit is contained in:
@@ -1,11 +1,51 @@
|
||||
using Reset.Core;
|
||||
using System;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class Enemy : Unit, ILockOnTarget{
|
||||
public class Enemy : Unit, ILockOnTarget, IKillable {
|
||||
public float lockonTargetRadius{ get; set; } = 10f;
|
||||
|
||||
public Animator testModelAnimator;
|
||||
|
||||
public override void UnitStart(){
|
||||
base.UnitStart();
|
||||
((IKillable)this).IKillableInitialize();
|
||||
}
|
||||
|
||||
public void OnTargetDelete(){
|
||||
GetComponent<ILockOnTarget>().SafelyDeleteTarget();
|
||||
}
|
||||
|
||||
public void TakeDamage(DamageSource[] sources){
|
||||
foreach (DamageSource source in sources) {
|
||||
TakeDamage(source);
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeDamage(DamageSource source){
|
||||
try {
|
||||
((IKillable)this).currentHealth -= source.damageDealt;
|
||||
|
||||
testModelAnimator.SetTrigger("Hit");
|
||||
|
||||
if (((IKillable)this).currentHealth <= 0) {
|
||||
Kill();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed TakeDamage on {this.name}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill(){
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
void Update(){
|
||||
GetComponent<IKillable>().DrawHealthDebug();
|
||||
}
|
||||
|
||||
public float maxHealth{ get; set; }
|
||||
public float currentHealth{ get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user