Beispiel #1
0
        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);
        }
Beispiel #2
0
        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));
            }
        }