public void OnUse() { switch (CurrentState) { case State.SelectCar: if (PointedCar != null) { SelectedCar = PointedCar; PointedCar = null; HighlightCar(SelectedCar, skinningMaterial); CommsRadioController.PlayAudioFromRadio(SelectedCarSound, transform); SetState(State.SelectSkin); } break; case State.SelectSkin: if ((PointedCar != null) && (PointedCar == SelectedCar)) { // clicked on the selected car again, this means confirm ApplySelectedSkin(); CommsRadioController.PlayAudioFromRadio(ConfirmSound, transform); } else { // clicked off the selected car, this means cancel CommsRadioController.PlayAudioFromRadio(CancelSound, transform); } ResetState(); break; } }
private void SetState(State newState) { if (state == newState) { return; } state = newState; switch (state) { case State.EnterSpawnMode: SetStartingDisplay(); lcdArrow.TurnOff(); ButtonBehaviour = ButtonBehaviourType.Regular; break; case State.PickCar: if (trackUpdateCoro == null) { trackUpdateCoro = StartCoroutine(PotentialTracksUpdateCoro()); } ButtonBehaviour = ButtonBehaviourType.Override; CommsRadioController.PlayAudioFromRadio(spawnModeEnterSound, transform); break; case State.PickDestination: ButtonBehaviour = ButtonBehaviourType.Override; break; } }
private void PointToCar(TrainCar?car) { if (PointedCar != car) { if ((car != null) && CarTypes.IsLocomotive(car.carType)) { PointedCar = car; HighlightCar(PointedCar, selectionMaterial !); CommsRadioController.PlayAudioFromRadio(HoverCarSound, transform); } else { PointedCar = null; ClearHighlightedCar(); } } }
private void PointToCar(TrainCar car) { if (PointedCar != car) { if (car != null) { PointedCar = car; HighlightCar(PointedCar, selectionMaterial); CommsRadioController.PlayAudioFromRadio(HoverCarSound, transform); } else { PointedCar = null; ClearHighlightedCar(); } } }
public void OnUse() { switch (state) { case State.EnterSpawnMode: SetCarToSpawn(Main.CustomCarManagerInstance.CustomCarsToSpawn[selectedCarTypeIndex]); SetState(State.PickCar); break; case State.PickCar: if (carPrefabToSpawn == null) { Debug.LogError("carPrefabToSpawn is null! Something is wrong, can't spawn this car.", this); ClearFlags(); break; } if (canSpawnAtPoint) { SetState(State.PickDestination); CommsRadioController.PlayAudioFromRadio(confirmSound, transform); break; } ClearFlags(); CommsRadioController.PlayAudioFromRadio(cancelSound, transform); break; case State.PickDestination: if (canSpawnAtPoint) { var forward = closestPointOnDestinationTrack.Value.forward; if (!spawnWithTrackDirection) { forward = -forward; } var trainCar = CarSpawner.SpawnCar(carPrefabToSpawn, destinationTrack, (Vector3)closestPointOnDestinationTrack.Value.position + WorldMover.currentMove, forward, true); if (trainCar != null) { SingletonBehaviour <UnusedTrainCarDeleter> .Instance.MarkForDelete(trainCar); CommsRadioController.PlayAudioFromCar(spawnVehicleSound, trainCar); CommsRadioController.PlayAudioFromRadio(confirmSound, transform); canSpawnAtPoint = false; Main.CustomCarManagerInstance.CustomCarsToSpawn[selectedCarTypeIndex].Spawn(trainCar); break; } Debug.LogError("Couldn't spawn car!", carPrefabToSpawn); ClearFlags(); break; } ClearFlags(); CommsRadioController.PlayAudioFromRadio(cancelSound, transform); break; } }