コード例 #1
0
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 private void Attack(StateController controller)
 {
     AttackUtil.HandleSingleModeAttack(controller);
 }