Fix MissingRefException when monster calls method OnDestroy
Changes to Entity.cs to override Death method
This commit is contained in:
parent
def7c9f30d
commit
0ce0acae5e
@ -35,7 +35,7 @@ public abstract class Entity : LevelObject
|
||||
Animation.SpeedMultiplier = SpeedMultiplier;
|
||||
}
|
||||
//Start the animation of death and the fading of the entity
|
||||
public void Death()
|
||||
public virtual void Death()
|
||||
{
|
||||
_animation.PlayDieAnim();
|
||||
Invoke("Dying", 0.1f);
|
||||
|
||||
@ -23,7 +23,7 @@ public class Opponent : Entity
|
||||
_rigidbody = GetComponent<Rigidbody2D>();
|
||||
Animation = gameObject.AddComponent<AnimationEntity>();
|
||||
_observer = WaveObserver.Instance;
|
||||
_toughness = Mathf.Round((base.Hp / 10) / 2);
|
||||
_toughness = Mathf.Round((Hp / 10) / 2);
|
||||
_observerIndex = _observer.NotifyEnemy(transform.position.y, _toughness);
|
||||
}
|
||||
|
||||
@ -61,9 +61,10 @@ public class Opponent : Entity
|
||||
AttackSpeedWait += Time.deltaTime;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
public override void Death()
|
||||
{
|
||||
_observer.NotifyDies(_observerIndex, _toughness);
|
||||
base.Death();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user