public override bool InstantExecute(GameObject target, IAction[] actions, int index) { Character _character = this.character.GetCharacter(target); if (_character == null) { return(true); } CharacterLocomotion locomotion = _character.characterLocomotion; CharacterController controller = locomotion.characterController; switch (this.mounted) { case true: _character.enabled = false; if (controller != null) { controller.detectCollisions = false; } break; case false: if (controller != null) { controller.detectCollisions = true; } _character.enabled = true; break; } return(true); }
public override IEnumerator Execute(GameObject target, IAction[] actions, int index, params object[] parameters) { WaitForSeconds wait = new WaitForSeconds(this.duration); yield return(wait); if (this.cacheCharacter != null) { CharacterLocomotion locomotion = this.cacheCharacter.characterLocomotion; locomotion.SetIsControllable(this.wasControllable); } yield return(0); }
public override bool InstantExecute(GameObject target, IAction[] actions, int index) { Character characterTarget = this.character.GetCharacter(target); if (characterTarget == null) { return(true); } CharacterLocomotion locomotion = characterTarget.characterLocomotion; CharacterAnimator animator = characterTarget.GetCharacterAnimator(); Vector3 moveDirection = Vector3.zero; switch (this.direction) { case Direction.CharacterMovement: moveDirection = locomotion.GetMovementDirection(); break; case Direction.TowardsTarget: Transform targetTransform = this.target.GetTransform(target); if (targetTransform != null) { moveDirection = targetTransform.position - characterTarget.transform.position; moveDirection.Scale(PLANE); } break; case Direction.TowardsPosition: Vector3 targetPosition = this.position.GetPosition(target); moveDirection = targetPosition - characterTarget.transform.position; moveDirection.Scale(PLANE); break; } Vector3 charDirection = Vector3.Scale( characterTarget.transform.TransformDirection(Vector3.forward), PLANE ); float angle = Vector3.SignedAngle(moveDirection, charDirection, Vector3.up); AnimationClip clip = null; if (angle <= 45f && angle >= -45f) { clip = this.dashClipForward; } else if (angle < 135f && angle > 45f) { clip = this.dashClipLeft; } else if (angle > -135f && angle < -45f) { clip = dashClipRight; } else { clip = this.dashClipBackward; } if (clip != null && animator != null) { animator.CrossFadeGesture(clip, 1f, null, 0.05f, 0.5f); } characterTarget.Dash( moveDirection.normalized, this.impulse.GetValue(target), this.duration.GetValue(target), this.drag ); return(true); }
// PUBLIC METHODS: ------------------------------------------------------------------------ public void Setup(CharacterLocomotion characterLocomotion) { this.characterLocomotion = characterLocomotion; }