private void AttackMulti(StateController controller) { var controlledObject = controller.controlledObject; // if cannot attack multi, fallback to single attack if (!controlledObject.CanAttackMulti()) { // AttackUtil.SetClosestEnemyAsTarget(controller); AttackUtil.HandleSingleModeAttack(controller); return; } Vector3 currentPosition = controlledObject.transform.position; List <WorldObject> reachableEnemies = controller.nearbyEnemies .Where(p => { Vector3 currentEnemyPosition = WorkManager.GetTargetClosestPoint(controlledObject, p); Vector3 direction = currentEnemyPosition - currentPosition; return(direction.sqrMagnitude < controlledObject.weaponRange * controlledObject.weaponRange); }) .ToList(); controller.attacking = reachableEnemies.Count > 0; controlledObject.PerformAttackToMulti(reachableEnemies); }
protected override void DoAction(UnitStateController controller) { Unit unit = controller.unit; var chaseTarget = AttackUtil.SetClosestEnemyAsTarget(controller); if (chaseTarget && !unit.holdingPosition && !WorkManager.ObjectCanReachTarget(unit, chaseTarget)) { var newDestination = WorkManager.FindDistinationPointByTarget(controller.chaseTarget, unit); if (newDestination.HasValue) { unit.StartMove(newDestination.Value); } } else { controller.unit.StopMove(); } }
private void Attack(StateController controller) { AttackUtil.HandleSingleModeAttack(controller); }