Exemplo n.º 1
0
        public override void DoBehavior(CharacterMovementController controller)
        {
            Vector2 moveDirection = Vector2.zero;

            moveDirection += Input.GetKey(upKey) ? Vector2.up : Vector2.zero;
            moveDirection += Input.GetKey(downKey) ? Vector2.down : Vector2.zero;
            moveDirection += Input.GetKey(leftKey) ? Vector2.left : Vector2.zero;
            moveDirection += Input.GetKey(rightKey) ? Vector2.right : Vector2.zero;

            controller.MoveInDirection(moveDirection);
        }
        public override void DoBehavior(CharacterMovementController controller)
        {
            NavigationTargeter targeter = controller.GetComponent <NavigationTargeter>();

            if (targeter == null || targeter.waypoints == null)
            {
                return;
            }

            if (targeter.waypoints.Count > 0)
            {
                Vector2 destination   = targeter.waypoints.Peek();
                float   deltaDistance = ((Vector2)targeter.self.position - destination).magnitude;
                Vector2 nextPosition  = Vector2.MoveTowards(targeter.self.position, destination, Mathf.Min((controller.movementSpeed * Time.fixedDeltaTime), deltaDistance));
                Vector2 delta         = nextPosition - (Vector2)targeter.self.position;

                controller.MoveByDelta(delta);
            }
        }
Exemplo n.º 3
0
 public abstract void DoBehavior(CharacterMovementController controller);