private IEnumerator AimPhase(IPushable pushable, AimLogic aimLogic) { _visuals.Indicator.enabled = true; while (!pushable.IsPushed()) { AimState state = aimLogic.GetCurrentAimState(Time.time); _visuals.Indicator.UpdateState(state); yield return(null); } pushable.IsPushed(); yield return(null); }
private Func <float, Vector3> GetTrajectory(AimLogic logic, AimState state) { Func <float, Vector3> trajectory; bool hitted = !state.Missed; if (hitted) { Vector3 init = logic.GetHitPoint(state.ZoneIndex); Vector3 start = _visuals.AimTarget.Arrow.position; Vector3 end = _visuals.AimTarget.RelativePoint(init); trajectory = logic.KinematicTraject(start, end); // trajectory = logic.DirectTraject(start, end); } else { Vector3 start = _visuals.AimTarget.Arrow.position; Vector3 end = _visuals.AimTarget.RandomMissPoint(); Debug.DrawLine(start, end); trajectory = logic.KinematicTraject(start, end); } return(trajectory); }
public IEnumerator LifeCycle() { IPushable button = _visuals.MainButton; while (true) { //Start yield return(new WaitForPushable(button)); GoToNextState(); //Aiming var logic = new AimLogic(_settings.aim, Time.time); yield return(StartCoroutine(AimPhase(button, logic))); var state = logic.GetCurrentAimState(Time.time); var trajectory = GetTrajectory(logic, state); GoToNextState(); //Anim yield return(StartCoroutine(AnimPhase(trajectory))); GoToNextState(); //Score yield return(StartCoroutine(ShowScorePhase(state))); //Reset Reset(); yield return(null); GoToNextState(); } }