예제 #1
0
 private void OnHit(UnitHitEvent unitHit)
 {
     if (GetParent().Name == unitHit.target.Name)
     {
         //Reduce the tanks health with the given amount
         health -= unitHit.damage;
         //Broadcast the health after it has been modified to anyone who is listening
         HealthEvent hei = new HealthEvent();
         hei.health = health;
         hei.target = unitHit.target;
         hei.FireEvent();
         //Check if the health has gone down to zero
         CheckHealth();
     }
 }
예제 #2
0
 public override void _ExitTree()
 {
     UnitHitEvent.UnregisterListener(OnHit);
 }
예제 #3
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     UnitHitEvent.RegisterListener(OnHit);
 }