mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 22:03:14 +02:00
sort of fix
This commit is contained in:
parent
42452e6e64
commit
28f7e76c0b
@ -21,7 +21,6 @@ public class Entity : MonoBehaviour
|
|||||||
|
|
||||||
[HideInInspector] public UnityEvent<Entity> OnDeath = new UnityEvent<Entity>();
|
[HideInInspector] public UnityEvent<Entity> OnDeath = new UnityEvent<Entity>();
|
||||||
|
|
||||||
|
|
||||||
public Team GetOwnTeam()
|
public Team GetOwnTeam()
|
||||||
{
|
{
|
||||||
return myTeam;
|
return myTeam;
|
||||||
@ -51,6 +50,18 @@ public class Entity : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Awake()
|
||||||
|
{
|
||||||
|
TickSystem.OnTick += HandleTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Die()
|
||||||
|
{
|
||||||
|
TickSystem.OnTick -= HandleTick;
|
||||||
|
OnDeath.Invoke(this);
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetOwnTeam(Team type)
|
public void SetOwnTeam(Team type)
|
||||||
{
|
{
|
||||||
myTeam = type;
|
myTeam = type;
|
||||||
@ -61,17 +72,16 @@ public class Entity : MonoBehaviour
|
|||||||
healthPoints -= damage;
|
healthPoints -= damage;
|
||||||
|
|
||||||
if (healthPoints <= 0)
|
if (healthPoints <= 0)
|
||||||
Destroy(gameObject);
|
Die();
|
||||||
|
|
||||||
UpdateHPDisplay();
|
UpdateHPDisplay();
|
||||||
Debug.Log("I took damage, my HP is now: " + healthPoints + " noooo!!!!", gameObject);
|
Debug.Log("I took damage, my HP is now: " + healthPoints + " noooo!!!!", gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Die()
|
protected virtual void HandleTick(TickSystem.OnTickEventArgs tickEventArgs)
|
||||||
{
|
{
|
||||||
OnDeath.Invoke(this);
|
|
||||||
Destroy(gameObject);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,19 +66,10 @@ public class Soldier : Entity
|
|||||||
else enemyType = Team.Ally;
|
else enemyType = Team.Ally;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awake()
|
protected override void HandleTick(TickSystem.OnTickEventArgs tickEventArgs)
|
||||||
{
|
|
||||||
TickSystem.OnTick += HandleTick;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Die()
|
|
||||||
{
|
{
|
||||||
TickSystem.OnTick -= HandleTick;
|
// base.HandleTick(tickEventArgs);
|
||||||
base.Die();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleTick(TickSystem.OnTickEventArgs tickEventArgs)
|
|
||||||
{
|
|
||||||
ref Queue<Action> queueToHandle = ref interrupts;
|
ref Queue<Action> queueToHandle = ref interrupts;
|
||||||
if (interrupts.Count < 1) // if no interrupt actions to do, handle regular queue
|
if (interrupts.Count < 1) // if no interrupt actions to do, handle regular queue
|
||||||
queueToHandle = actions;
|
queueToHandle = actions;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user