public virtual void Reset() { bLookAt = false; priority = -1; directType = EDirectType.DT_WorldForward; duration_Move = 0.0f; duration_Rotate = 0.0f; velocity = Vector3.zero; angularVelocity = Vector3.zero; motionType = EMotionType.MT_Additive; rotateType = EMotionType.MT_Additive; }
//////////////////////////// ////////// Method ////////// //////////////////////////// ///////////////////////// ////////// API ////////// /// <summary> /// Initialize the motion state machine /// </summary> public void Initialize(ACharacterSystem cs) { if (_entryMotionState == null) { Debug.LogError("[MSM] There is no entry motion state to the motion state machine!"); } else { _currentMotionState = _entryMotionState; } _motionType = cs.GetType().IsSubclassOf(typeof(ACharacterSystem3D)) ? EMotionType.Motion3D : EMotionType.Motion2D; }
//////////////////////////// ////////// Method ////////// //////////////////////////// ///////////////////////// ////////// API ////////// /// <summary> /// Verify if the condition is complete /// </summary> public bool IsComplete(ACharacterSystem cs, MotionInformation mi, EMotionType motionType) { switch (motionType) { case EMotionType.Motion2D: return(IsComplete2D(cs as ACharacterSystem2D, mi)); case EMotionType.Motion3D: return(IsComplete3D(cs as ACharacterSystem3D, mi)); default: throw new ArgumentOutOfRangeException("motionType", motionType, null); } }
public void ApplyRotate(int priority, EMotionType rotateType, EDirectType asixType, float rotateAngle, float duration = 0.0f, AnimationCurve rotateCurve = null) { if (this.priority < priority) { Reset(); OnMotionStart?.Invoke(); } startTime_Rotate = Time.time; this.priority = priority; this.rotateType = rotateType; this.torque = GetTorque(asixType, rotateAngle); this.duration_Rotate = duration; this.rotateCurve = rotateCurve; }
public AbilityBuffMotionModifiers(AbilitySystemComponent abilitySystem, Editor_FMotionModifierData data) { this.abilitySystem = abilitySystem; priority = data.priority; duration = data.duration; moveType = data.moveType; distance = data.distance; direction = data.direction; rotateType = data.rotateType; rotateAxis = data.rotateAxis; rotateAngle = data.rotateAngle; moveCurve = AnimationCurveManager.Instance.GetCurve(data.moveCurve); rotateCurve = AnimationCurveManager.Instance.GetCurve(data.rotateCurve); }
/// <summary> /// Execute the movemement of the motion state /// </summary> public void Move(ACharacterSystem cs, MotionInformation mi, EMotionType motionType) { switch (motionType) { case EMotionType.Motion2D: Move2D(cs as ACharacterSystem2D, mi); break; case EMotionType.Motion3D: Move3D(cs as ACharacterSystem3D, mi); break; default: throw new ArgumentOutOfRangeException("motionType", motionType, null); } }
public void ApplyMotion(int priority, EMotionType motionType, EDirectType directType, float distance, float duration = 0.0f, AnimationCurve moveCurve = null) { if (this.priority < priority) { Reset(); OnMotionStart?.Invoke(); } startTime_Move = Time.time; this.priority = priority; this.motionType = motionType; this.directType = directType; this.direction = GetDirection(directType); this.distance = distance; this.duration_Move = duration; this.moveCurve = moveCurve; }
//////////////////////////// ////////// Method ////////// //////////////////////////// ///////////////////////// ////////// API ////////// /// <summary> /// Attempt to get the next motion state base on the motion transition of the current motion state /// </summary> public AMotionState AttemptToGetNextMotionState(ACharacterSystem cs, MotionInformation mi, EMotionType motionType) { foreach (var mt in _motionTransitions) { var nextMotionState = mt.GetResultingMotionState(cs, mi, motionType); if (nextMotionState != null) { return(nextMotionState); } } return(null); }
public void ApplyRotate(int priority, EMotionType rotateType, EDirectType asixType, float rotateAngle, float duration = 0.0f, AnimationCurve rotateCurve = null) { MotionClip.ApplyRotate(priority, rotateType, asixType, rotateAngle, duration, rotateCurve); }
public void ApplyMotion(int priority, EMotionType motionType, EDirectType directType, float distance, float duration = 0.0f, AnimationCurve moveCurve = null) { MotionClip.ApplyMotion(priority, motionType, directType, distance, duration, moveCurve); }
///////////////////////////// ////////// Service ////////// /// <summary> /// Check if all the conditions are met /// </summary> private bool AreConditionsMet(ACharacterSystem cs, MotionInformation mi, EMotionType motionType) { return(_motionConditions.All(mc => mc.IsComplete(cs, mi, motionType))); }
//////////////////////////// ////////// Method ////////// //////////////////////////// ///////////////////////// ////////// API ////////// /// <summary> /// Return either the motionStateOnSuccess or the motionStateOnFailure depending on the conditions result /// </summary> public AMotionState GetResultingMotionState(ACharacterSystem cs, MotionInformation mi, EMotionType motionType) { return(AreConditionsMet(cs, mi, motionType) ? _motionStateOnSuccess : _motionStateOnFailure); }