private void Update() { switch (state) { case ZoomerState.ZoomingIn: timer += Time.deltaTime; if (timer >= zoomInTime) { timer -= zoomInTime; targetCamera.fieldOfView = originalFov + fovChange; state = ZoomerState.ZoomingOut; } else { targetCamera.fieldOfView = Mathf.Lerp(originalFov, originalFov + fovChange, timer / zoomInTime); } break; case ZoomerState.ZoomingOut: timer += Time.deltaTime; if (timer >= zoomOutTime) { timer -= zoomOutTime; targetCamera.fieldOfView = originalFov; state = ZoomerState.Waiting; } else { targetCamera.fieldOfView = Mathf.Lerp(originalFov + fovChange, originalFov, timer / zoomOutTime); } break; } }
public void Stop() { if (state != ZoomerState.Off) { targetCamera.fieldOfView = originalFov; state = ZoomerState.Off; Musician.Instance.OnBeat.RemoveListener(Zoom); } }
public void Run() { if (state == ZoomerState.Off) { timer = 0f; state = ZoomerState.Waiting; Musician.Instance.OnBeat.AddListener(Zoom); } }
private void Zoom() { timer = 0f; state = ZoomerState.ZoomingIn; }