Skip to content
Snippets Groups Projects
Commit e8da04ec authored by Sárközi Gergely János's avatar Sárközi Gergely János Committed by Bahil Botond
Browse files

Destroy unit even if destination castle is destroyed (closes #61)

parent b829898f
No related branches found
No related tags found
1 merge request!25Destroy unit even if destination castle is destroyed (closes #61)
...@@ -12,10 +12,12 @@ public class UnitDamagesCastleSystem : BaseSystem { ...@@ -12,10 +12,12 @@ public class UnitDamagesCastleSystem : BaseSystem {
private void On(UnitMovedTileEvent e) { private void On(UnitMovedTileEvent e) {
Unit unit = e.Unit; Unit unit = e.Unit;
Castle enemyCastle = unit.World.Overview.GetEnemyTeam(unit.Owner).Castle; Castle enemyCastle = unit.World.Overview.GetEnemyTeam(unit.Owner).Castle;
if (enemyCastle.Health <= 0) return;
if (unit.TilePosition.Equals(enemyCastle.Position)) { if (unit.TilePosition.Equals(enemyCastle.Position)) {
enemyCastle.Damage(unit, unit.Type.Damage); if (!enemyCastle.IsDestroyed) {
enemyCastle.Damage(unit, unit.Type.Damage);
}
unit.World.DestroyUnit(unit); unit.World.DestroyUnit(unit);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment