/// <summary> /// Updates current state. /// </summary> public void Update() { if (TimeLeftForNextStep >= -float.Epsilon) { TimeLeftForNextStep -= Time.deltaTime; } else { switch (Step) { case AimStep.Enter: Step = AimStep.Aiming; TimeLeftForNextStep = TimeAimToLeave; break; case AimStep.Aiming: if (LeaveAfterAiming) { Step = AimStep.None; LeaveAfterAiming = false; } break; } } }
/// <summary> /// Starts off a transition to aim, wait's for ImmediateAim() to finish it. /// </summary> /// <param name="angle">Degrees in world space to point the gun at.</param> public void WaitAim(float angle) { Angle = angle; if (Step == AimStep.Aiming) { LeaveAfterAiming = false; } else if (Step != AimStep.Enter) { Step = AimStep.Enter; TimeLeftForNextStep = 10000; } }
/// <summary> /// Starts off a transition to aim, used when in cover. /// </summary> /// <param name="angle">Degrees in world space to point the gun at.</param> public void CoverAim(float angle) { Angle = angle; if (Step == AimStep.Aiming) { LeaveAfterAiming = false; } else if (Step != AimStep.Enter) { Step = AimStep.Enter; TimeLeftForNextStep = TimeEnterToAim; } }
/// <summary> /// Immediately enters aiming without any transitions. /// </summary> public void ImmediateEnter() { LeaveAfterAiming = false; TimeLeftForNextStep = 0; Step = AimStep.Aiming; }
/// <summary> /// Turns on aiming immediately, used when not in cover. /// </summary> /// <param name="angle">Degrees in world space to point the gun at.</param> public void FreeAim(float angle) { Angle = angle; Step = AimStep.Aiming; }
/// <summary> /// Immediately cancels aiming without any transitions. /// </summary> public void ImmediateLeave() { LeaveAfterAiming = false; TimeLeftForNextStep = 0; Step = AimStep.None; }