public override bool Work() { bool cannotAttack = target.CurrentHealth <= 0; if (!cannotAttack) { if (targetIsInRange()) { if (ticksSinceLastAttk % (unit.AttackTicks * 10) == 0) { unit.State = UnitComponent.UnitState.ATTACKING; updateUnitOrientation(); ticksSinceLastAttk = 0; target.CurrentHealth -= unit.Attack; if (target.CurrentHealth <= 0) { cannotAttack = true; } unit.createAttackEvent(target); if (target.PointLocation.Y > unit.PointLocation.Y) { if (target.PointLocation.X > unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.SE; } else if (target.PointLocation.X < unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.SW; } else { unit.UnitOrient = UnitComponent.Orient.S; } } else if (target.PointLocation.Y < unit.PointLocation.Y) { if (target.PointLocation.X > unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.NE; } else if (target.PointLocation.X < unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.NW; } else { unit.UnitOrient = UnitComponent.Orient.N; } } else if (target.PointLocation.X < unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.W; } else if (target.PointLocation.X > unit.PointLocation.X) { unit.UnitOrient = UnitComponent.Orient.E; } } ticksSinceLastAttk++; } else { cannotAttack = true; } } return(cannotAttack); }