public static void Update(BQE_Attack p_attackEvent, float d) { Anim_BattleAttack_Distance l_battleAttack = (Anim_BattleAttack_Distance)p_attackEvent.Context_UserObject; switch (l_battleAttack.State) { case Anim_BattleAttack_Distance_State.End: { if (p_attackEvent.Out_DamageSteps == null) { p_attackEvent.Out_DamageSteps = new List <BaseDamageStep>(); } p_attackEvent.Out_DamageSteps.Add(BaseDamageStep.build(p_attackEvent.Source, p_attackEvent.Target, p_attackEvent.Attack)); l_battleAttack.AnimatedTransform.transform.rotation = l_battleAttack.InitalAnimatedTransform_Rotation; p_attackEvent.HasEnded = true; } break; } }
public static void Update(BQE_Attack p_attackEvent, float delta) { Anim_BattleAttack_Default l_battleAttack = (Anim_BattleAttack_Default)p_attackEvent.Context_UserObject; switch (l_battleAttack.State) { case Anim_BattleAttack_Default_State.Preparing: { } break; case Anim_BattleAttack_Default_State.MovingForward: { float l_distance = Vector3.Distance(l_battleAttack.AnimatedTransform.transform.position, l_battleAttack.TargetPosition_MovingForward); if ((l_distance > l_battleAttack.LastFrameDistace) || (l_distance <= 0.001f)) { // We terminate the movement l_battleAttack.AnimatedTransform.transform.position = l_battleAttack.TargetPosition_MovingForward; if (p_attackEvent.Out_DamageSteps == null) { p_attackEvent.Out_DamageSteps = new List <BaseDamageStep>(); } p_attackEvent.Out_DamageSteps.Add(BaseDamageStep.build(p_attackEvent.Source, p_attackEvent.Target, p_attackEvent.Attack)); l_battleAttack.State = Anim_BattleAttack_Default_State.Slashing; l_battleAttack.LastFrameDistace = Vector3.Distance(l_battleAttack.InitalAnimatedTransform_Position, l_battleAttack.TargetPosition_MovingForward); return; } float l_distanceRatio = 1.0f - (l_distance / Vector3.Distance(l_battleAttack.TargetPosition_MovingForward, l_battleAttack.InitalAnimatedTransform_Position)); l_battleAttack.AnimatedTransform.transform.position += l_battleAttack.Movement_ForwardDirection * l_battleAttack.Conf.AnimatedTransform_Speed_V2.Evaluate(l_distanceRatio) * l_battleAttack.Conf.AnimatedTransform_Speed_Forward * delta; l_battleAttack.LastFrameDistace = l_distance; if (!l_battleAttack.IsSlashAnimationTriggered && l_distanceRatio >= l_battleAttack.Conf.DistanceRatio_MoveForward_StartMovingLegs) { l_battleAttack.IsSlashAnimationTriggered = true; l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_Slash); } } break; case Anim_BattleAttack_Default_State.Slashing: { if (l_battleAttack.IsSlashAnimationOver) { l_battleAttack.StandingStill_AfterSlash_Timer += delta; if (l_battleAttack.StandingStill_AfterSlash_Timer >= l_battleAttack.Conf.TimeStandingStill_AfterSlashing) { l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_MoveBackward); l_battleAttack.State = Anim_BattleAttack_Default_State.MovingBackward; Update(p_attackEvent, delta); } } } break; case Anim_BattleAttack_Default_State.MovingBackward: { float l_distance = Vector3.Distance(l_battleAttack.AnimatedTransform.transform.position, l_battleAttack.InitalAnimatedTransform_Position); if ((l_distance > l_battleAttack.LastFrameDistace) || (l_distance <= 0.001f)) { // We terminate the movement l_battleAttack.AnimatedTransform.transform.position = l_battleAttack.InitalAnimatedTransform_Position; l_battleAttack.AnimatedTransform.transform.rotation = l_battleAttack.InitalAnimatedTransform_Rotation; p_attackEvent.HasEnded = true; l_battleAttack.State = Anim_BattleAttack_Default_State.End; l_battleAttack.AnimatedTransform.AnimatorDispatcher.Animator.CrossFadeInFixedTime(AnimatorStateConstants.Attack_Close_Idle, 0.1f); return; } l_battleAttack.AnimatedTransform.transform.position += (-l_battleAttack.Movement_ForwardDirection) * l_battleAttack.Conf.AnimatedTransform_Speed_Backward * delta; l_battleAttack.LastFrameDistace = l_distance; } break; } return; }