void Update() { var pilotActionMap = _data.PilotActionMapProvider.ActionMap; var shouldRespawn = pilotActionMap.PollButtonEvent(WingsuitAction.Respawn) == ButtonEvent.Down; var shouldSwitchVehicleType = pilotActionMap.PollButtonEvent(WingsuitAction.UnfoldParachute) == ButtonEvent.Down; if (!_isRespawning) { if (_transitToParachuteEditor) { _transitToParachuteEditor = false; Machine.Transition(Playing.PlayingStates.EditingParachute, _environment); } else if (shouldRespawn) { _data.CoroutineScheduler.Run(RespawnWithFade()); } else if (shouldSwitchVehicleType) { Machine.Transition(Playing.PlayingStates.FlyingParachute, _environment); } else if (pilotActionMap.PollButtonEvent(WingsuitAction.ChangeCamera) == ButtonEvent.Down) { _environment = _environment.NextMount(); SwitchToMount(_environment.SelectedCameraMount); } else if (pilotActionMap.PollButtonEvent(WingsuitAction.ToggleSpectatorView) == ButtonEvent.Down) { Machine.Transition(Playing.PlayingStates.Spectating); } } }
void OnEnter(PlayingEnvironment environment) { _data.ParachuteEditor.Initialize(_editorState, _editorParachuteChanges); _environment = environment; var editLocation = _environment.Spawnpoint.AsParachuteLocation(); var pilot = environment.Pilot; pilot.TrajectoryVisualizer.Deactivate(); _data.ParachuteEditor.transform.Set(editLocation); _data.ParachuteEditor.gameObject.SetActive(true); _isConfigUpdated = false; _currentConfig = _activeParachuteConfig.Get(); CreateEditorChute(_activeParachuteConfig.Get(), editLocation); _disposeParachuteBuilder = _activeParachuteConfig.OnUpdate .Subscribe(config => { _currentConfig = config; _isConfigUpdated = true; }); _data.CameraManager.SwitchMount(_data.EditorCamera); _data.EditorCamera.Center(); OnResume(Maybe <RespawnRequest> .Nothing, transitToParachuteEditor: false); }
IEnumerator <WaitCommand> Respawn() { // TODO Respawning is just another state _isRespawning = true; yield return(_data.PlayerPilotSpawner.Respawn(_environment.Spawnpoint).AsWaitCommand()); _environment = _environment.UpdatePilot(_data.PlayerPilotSpawner.ActivePilot); if (_data.CameraManager.Rig.Shake != null) { _data.CameraManager.Rig.Shake.SetTarget(_data.PlayerPilotSpawner.ActivePilot); } _isRespawning = false; }
IEnumerator <WaitCommand> RespawnWithFade() { // TODO Respawning is just another state _isRespawning = true; yield return(FadeOut().AsWaitCommand()); yield return(_data.PlayerPilotSpawner.Respawn(_environment.Spawnpoint).AsWaitCommand()); _environment = _environment.UpdatePilot(_data.PlayerPilotSpawner.ActivePilot); _data.ThirdPersonCameraMount.Clear(); SwitchToMount(_environment.SelectedCameraMount); yield return(FadeIn().AsWaitCommand()); _isRespawning = false; }
IEnumerator <WaitCommand> OnEnter(SpawnpointLocation spawnpoint) { _data.ChallengeAnnouncerUi.enabled = true; _data.JoystickActivator.enabled = false; _data.ThirdPersonCameraController.enabled = true; // TODO Don't spawn the player this is now the responsisiblity of the wingsuit state //yield return _data.PlayerPilotSpawner.Respawn(spawnpoint).AsWaitCommand(); var environment = new PlayingEnvironment( spawnpoint: spawnpoint, pilot: null, parachuteConfig: _activeParachuteConfig.Get()); _playingStateMachine.Transition(PlayingStates.FlyingWingsuit, environment, Maybe.Just(new RespawnRequest())); yield return(WaitCommand.WaitRoutine(CameraTransitions.FadeIn(_data.CameraManager.Rig.ScreenFader, _data.MenuClock, _data.FaderSettings))); }
private IEnumerator <WaitCommand> OnEnter(PlayingEnvironment environment) { _environment = environment; _parachute = _data.ImmersionSpawner.Create(environment.ParachuteConfig, "ImmersionParachute"); _data.ParachuteController.Parachute = _parachute; _parachute.AttachToPilot(environment.Pilot, Parachute.InflightUnfoldOrientation, _data.GameSettingsProvider); // TODO This is a hack to compensate for the editor // that misuses the pilot for its own purposes. // We actually need a second pilot for editor purposes environment.Pilot.DisableWings(); environment.Pilot.SetPhysical(); environment.Pilot.PilotAnimator.SetState(PilotAnimatorState.Parachute); SwitchToMount(environment.SelectedCameraMount); _data.GameHud.SetTarget(_parachute.Pilot.FlightStatistics, AvatarType.Parachute); _data.GameHud.Activate(); _parachute.Deploy(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; if (_data.CameraManager.Rig.Shake) { _data.CameraManager.Rig.Shake.enabled = true; } _data.GameClock.Resume(); _data.FixedClock.Resume(); _data.SoundMixer.Unpause(SoundLayer.GameEffects); // Indicate that we have unfolded the parachute once, i.e. the player know how to do it if (_data.GameSettingsProvider.ActiveSettings.Tutorial.HasUnfoldedParachute != true) { var gameSettings = _data.GameSettingsProvider.ActiveSettings; gameSettings.Tutorial.HasUnfoldedParachute = true; _data.GameSettingsProvider.UpdateGameSettings(gameSettings); } yield return(WaitCommand.DontWait); }
private void Update() { var parachuteActionMap = _data.ParachuteActionMap.V; var pilotActionMap = _data.PilotActionMapProvider.ActionMap; var shouldRespawn = pilotActionMap.PollButtonEvent(WingsuitAction.Respawn) == ButtonEvent.Down; var shouldSwitchVehicleType = pilotActionMap.PollButtonEvent(WingsuitAction.UnfoldParachute) == ButtonEvent.Down; _data.GameHud.SetParachuteInput(_data.ParachuteController.Input); if (shouldRespawn || _isRespawnRequested) { _isRespawnRequested = false; Machine.Transition(Playing.PlayingStates.FlyingWingsuit, _environment, Maybe.Just(new RespawnRequest())); } else { if (_transitToEditor) { _transitToEditor = false; Machine.Transition(Playing.PlayingStates.EditingParachute, _environment); } else if (parachuteActionMap.ParachuteConfigToggle == ButtonEvent.Down) { TransitToEditingState(); } else if (shouldSwitchVehicleType) { Machine.Transition(Playing.PlayingStates.FlyingWingsuit, _environment, Maybe.Nothing <RespawnRequest>()); } else if (pilotActionMap.PollButtonEvent(WingsuitAction.ChangeCamera) == ButtonEvent.Down) { _environment = _environment.NextMount(); SwitchToMount(_environment.SelectedCameraMount); } else if (pilotActionMap.PollButtonEvent(WingsuitAction.ToggleSpectatorView) == ButtonEvent.Down) { Machine.Transition(Playing.PlayingStates.Spectating); } } }
IEnumerator <WaitCommand> OnEnter(PlayingEnvironment environment, Maybe <RespawnRequest> respawnRequest) { _environment = environment; // TODO Make sure if the player needs to be respawned yield return(OnResume(respawnRequest, transitToParachuteEditor: false).AsWaitCommand()); }