void PlaySound(Sounds s, Vec2 source = null) { var screen = (ScreenService)Services.GetService(typeof(ScreenService)); Sound.PlaySound(SoundsHelper.GetSoundPath(s), screen.GameWindowSize.X, screen.GameWindowSize.Y, source != null ? (Vector2?)GameLibHelper.ToVector2(source) : null); }
public void OpenOrCloseMainMenu(object sender, EventArgs e) { var screen = (ScreenService)GetServices().GetService(typeof(ScreenService)); var sound = (SoundService)GetServices().GetService(typeof(SoundService)); sound.PlaySound(SoundsHelper.GetSoundPath(Sounds.OpenMenu), screen.GameWindowSize.X, screen.GameWindowSize.Y); if (State == MenuState.AllClosed) { State = MenuState.MainOpened; MainBackgroundLayer.Visible = true; MainMenu.Active(true); SetMenuSize(new Vector2(MainBackground.Texture.Width, MainBackground.Texture.Height)); screenService.IsMouseVisible = true; } else if (State == MenuState.MainOpened) { State = MenuState.AllClosed; MainBackgroundLayer.Visible = false; MainMenu.UnselectItems(); MainMenu.Active(false); screenService.IsMouseVisible = false; } else if (State == MenuState.AudioOpened) { State = MenuState.MainOpened; AudioBackgroundLayer.Visible = false; MainBackgroundLayer.Visible = true; AudioMenu.Active(false); MainMenu.Active(true); SetMenuSize(new Vector2(MainBackground.Texture.Width, MainBackground.Texture.Height)); } else if (State == MenuState.VideoOpened) { State = MenuState.MainOpened; VideoBackgroundLayer.Visible = false; MainBackgroundLayer.Visible = true; VideoMenu.Active(false); MainMenu.Active(true); SetMenuSize(new Vector2(MainBackground.Texture.Width, MainBackground.Texture.Height)); } else if (State == MenuState.ExitOpened) { State = MenuState.MainOpened; ExitLayer.Visible = false; MainBackgroundLayer.Visible = true; ExitMenu.Active(false); MainMenu.Active(true); SetMenuSize(new Vector2(MainBackground.Texture.Width, MainBackground.Texture.Height)); } }
public TalkerToHuman(SoundsHelper soundsHelper, IAnimatedHead animatedHead) { _soundsHelper = soundsHelper; _animatedHead = animatedHead; }
private IEnumerator<ITask> InitializeGui() { var runWindow = this.wpfServicePort.RunWindow(() => new libguiwpf.MainWindow(_state.followDirectionPidControllerAngularSpeed, _state.followDirectionPidControllerLinearSpeed, SoundSkinFactory.soundsBasePathDefault)); yield return (Choice)runWindow; var exception = (Exception)runWindow; if (exception != null) { LogError(exception); StartFailed(); yield break; } // need double cast because WPF adapter doesn't know about derived window types var userInterface = ((Window)runWindow) as libguiwpf.MainWindow; if (userInterface == null) { var e = new ApplicationException("User interface was expected to be libguiwpf.MainWindow"); LogError(e); throw e; } _mainWindow = userInterface; _mainWindow.Closing += new CancelEventHandler(_mainWindow_Closing); _mainWindow.PowerScaleAdjusted += delegate { PowerScale = _mainWindow.PowerScale; Tracer.Trace("PowerScaleAdjusted: " + PowerScale); }; _mainWindow.PidControllersUpdated += delegate { Tracer.Trace("PidControllersUpdated - saving state"); SaveState(_state); }; // for convenience mark the initial robot position: DetectedObstacle dobst1 = new DetectedObstacle() { geoPosition = (GeoPosition)_mapperVicinity.robotPosition.Clone(), firstSeen = DateTime.Now.Ticks, lastSeen = DateTime.Now.Ticks, detectorType = DetectorType.NONE, objectType = DetectedObjectType.Mark, timeToLiveSeconds = 3600 }; dobst1.SetColorByType(); lock (_mapperVicinity) { _mapperVicinity.Add(dobst1); } _mainWindow.setMapper(_mapperVicinity, _routePlanner); _mainWindow.PowerScale = PowerScale; _soundsHelper = new SoundsHelper(_mainWindow); }