Example #1
0
 void OpenAudio()
 {
     MainMenu.Active(false);
     AudioMenu.Active(true);
     State = MenuState.AudioOpened;
     AudioBackgroundLayer.Visible = true;
     MainBackgroundLayer.Visible  = false;
     SetMenuSize(new Vector2(AudioBackground.Texture.Width, AudioBackground.Texture.Height));
 }
        public static void CreateLanguageDropdown(this AudioMenu __instance)
        {
            Type[] searchParameters = new Type[] {
                typeof(string),
                typeof(Func <string>),
                typeof(Action <string>),
                typeof(string),
                typeof(KeyValuePair <string, string>[])
            };
            MethodInfo[] methods = typeof(GeneralMenu).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (MethodInfo method in methods)
            {
                if (method.Name == "TweakEnum")
                {
                    MethodInfo      genericMethod    = method.MakeGenericMethod(typeof(string));
                    ParameterInfo[] methodParameters = genericMethod.GetParameters();
                    if (methodParameters.Length == searchParameters.Length)
                    {
                        for (int index = 0; index < searchParameters.Length; index++)
                        {
                            if (methodParameters[index].ParameterType != searchParameters[index])
                            {
                                continue;
                            }
                        }

                        Func <string> LangGet = delegate
                        {
                            return(CurrentPlugin.Configuration["SubtitlesLanguage"].ToString());
                        };

                        Action <string> LangSet = delegate(string lang)
                        {
                            Configuration["SubtitlesLanguage"] = lang;
                            Configuration.Save();

                            Language.Reload();
                        };

                        object[] args =
                        {
                            "SUBTITLES LANGUAGE",
                            LangGet,
                            LangSet,
                            "",
                            LanguageFiles.ToArray()
                        };

                        genericMethod.Invoke(__instance, args);

                        return;
                    }
                }
            }
        }
Example #3
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #4
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));
            }
        }
Example #5
0
    void musicMenu()
    {
        DontDestroyOnLoad(this);

        if (instanceAudio == null)
        {
            instanceAudio = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
Example #6
0
    public void Awake()
    {
        _menuNavigator = GameObject.FindGameObjectWithTag(Tags.Menus).GetComponent<MenuNavigator>();
        _audioMenu = GameObject.FindGameObjectWithTag(Tags.Menus).GetComponent<AudioMenu>();

        GameObject[] gameController = GameObject.FindGameObjectsWithTag(Tags.GameController);
        if (gameController.Length == 0) return;
        GameControllerInput input = gameController[0].GetComponent<GameControllerInput>();
        if (input == null) return;
        _hasInputController = input.isActiveAndEnabled;

        returned = false;
    }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
Example #8
0
        protected override void OnLoad(ContentManager content, GraphicsDevice gd)
        {
            AddChild(PlacementLayer);

            PlacementLayer.AddChild(MainMenu, 2);
            PlacementLayer.AddChild(AudioMenu, 2);
            PlacementLayer.AddChild(VideoMenu, 2);
            PlacementLayer.AddChild(MainBackgroundLayer, 1);
            PlacementLayer.AddChild(AudioBackgroundLayer, 1);
            PlacementLayer.AddChild(VideoBackgroundLayer, 1);
            PlacementLayer.AddChild(ExitLayer, 1);

            VideoBackgroundLayer.AddChild(VideoBackground, 1);
            VideoBackgroundLayer.AddChild(new DrawableLabel()
            {
                Text     = "*Changes will take effect after the next restart.",
                Scale    = new Vector2(0.6f, 0.6f),
                Position = new Vector2(20, 150)
            });

            VideoBackgroundLayer.AddChild(GearVideo, 0);
            VideoBackgroundLayer.AddChild(GearVideo2, 0);

            AudioBackgroundLayer.AddChild(AudioBackground, 1);
            AudioBackgroundLayer.AddChild(GearAudio, 0);

            MainBackgroundLayer.AddChild(GearMain, 0);
            MainBackgroundLayer.AddChild(GearMiniMain, 0);
            MainBackgroundLayer.AddChild(MainBackground, 1);

            ExitLayer.AddChild(ExitBackground, 1);
            ExitLayer.AddChild(new DrawableLabel()
            {
                Text = "Do you really want to quit?", Position = new Vector2(30, 25)
            });
            ExitLayer.AddChild(ExitMenu, 2);
            ExitLayer.AddChild(GearExit, 0);
            ExitLayer.AddChild(GearExit2, 0);
            ExitLayer.AddChild(GearExitMini, 0);

            inputManager.RegisterEvent(InputActions.Escape, new EventHandler(OpenOrCloseMainMenu));

            MainMenu.Active(false);
            AudioMenu.Active(false);
            VideoMenu.Active(false);
            ExitMenu.Active(false);

            SetMenuSize(new Vector2(MainBackground.Texture.Width, MainBackground.Texture.Height));
        }
Example #9
0
    //public GameObject reproductorAudio;

    void Awake()
    {
        Debug.Log("control awake1");
        GetComponent <AudioSource>().Play();

        if (audioMenu == null)
        {
            Debug.Log("control awake2");
            //this hace referencia a la estancia del componente que esta ejecutando este codigo
            audioMenu = this;
            DontDestroyOnLoad(gameObject);
        }
        //si es distinto de la estancia actual se destruye
        else if (audioMenu != this)
        {
            Debug.Log("control awake3");
            Destroy(gameObject);
        }
    }
 public void Awake()
 {
     _audioMenu = GameObject.FindGameObjectWithTag(Tags.Menus).GetComponent<AudioMenu>();
 }
Example #11
0
 public void Awake()
 {
     _menuNavigator = GameObject.FindGameObjectWithTag(Tags.Menus).GetComponent<MenuNavigator>();
     _audioMenu = GameObject.FindGameObjectWithTag(Tags.Menus).GetComponent<AudioMenu>();
 }
        public void Initialize(ScreenManager screenManager)
        {
            this.screenManager = screenManager;
            GraphicsDevice     = screenManager.GraphicsDevice;
            _content           = new ContentManager(screenManager.ServiceProvider, "Content");

            //Background
            settingsMenu = new Sprite2D(_content.Load <Texture2D>("Sprites/SettingsMenu"), new Rectangle(100, 50, 1080, 620));

            audioSettings    = Settings.Instance.Audio.Clone() as AudioSettings;
            controlsSettings = Settings.Instance.Controls.Clone() as ControlsSettings;
            graphicsSettings = Settings.Instance.Graphics.Clone() as GraphicsSettings;
            rubiksSettings   = Settings.Instance.RubiksCube.Clone() as RubiksCubeSettings;


            SpriteFont font       = _content.Load <SpriteFont>("Fonts/Arial24");
            Texture2D  boxTexture = _content.Load <Texture2D>("Sprites/Transparent");

            ButtonAnimation hover         = new ButtonAnimation(null, null, new Color(0, 255, 255, 150));
            ButtonAnimation unHoverUnMark = new ButtonAnimation(null, null, Color.Transparent);
            ButtonAnimation mark          = new ButtonAnimation(null, null, new Color(0, 180, 255, 250));


            //
            //Buttons
            //

            //
            //Controls
            //
            controlsBtn                  = new OptionsButton(new Sprite2D(boxTexture, new Rectangle(115, 120, 225, 75)));
            controlsBtn.Color            = Color.Transparent;
            controlsBtn.HoverAnimation   = hover;
            controlsBtn.UnHoverAnimation = unHoverUnMark;
            controlsBtn.UnMarkAnimation  = unHoverUnMark;
            controlsBtn.MarkAnimation    = mark;
            controlsBtn.TextMessege      = new Text(categoriesName[0], font);
            controlsBtn.TextMessege.Center(controlsBtn.Bounds);


            //
            //Audio
            //
            audioBtn                  = new OptionsButton(new Sprite2D(boxTexture, new Rectangle(115, 195, 225, 75)));
            audioBtn.Color            = Color.Transparent;
            audioBtn.HoverAnimation   = hover;
            audioBtn.UnHoverAnimation = unHoverUnMark;
            audioBtn.UnMarkAnimation  = unHoverUnMark;
            audioBtn.MarkAnimation    = mark;
            audioBtn.TextMessege      = new Text(categoriesName[1], font);
            audioBtn.TextMessege.Center(audioBtn.Bounds);



            //
            //Window
            //
            windowBtn                  = new OptionsButton(new Sprite2D(boxTexture, new Rectangle(115, 270, 225, 75)));
            windowBtn.Color            = Color.Transparent;
            windowBtn.HoverAnimation   = hover;
            windowBtn.UnHoverAnimation = unHoverUnMark;
            windowBtn.UnMarkAnimation  = unHoverUnMark;
            windowBtn.MarkAnimation    = mark;
            windowBtn.TextMessege      = new Text(categoriesName[2], font);
            windowBtn.TextMessege.Center(windowBtn.Bounds);


            //
            //Rubiks
            //
            rubiksBtn                  = new OptionsButton(new Sprite2D(boxTexture, new Rectangle(115, 345, 225, 75)));
            rubiksBtn.Color            = Color.Transparent;
            rubiksBtn.HoverAnimation   = hover;
            rubiksBtn.UnHoverAnimation = unHoverUnMark;
            rubiksBtn.UnMarkAnimation  = unHoverUnMark;
            rubiksBtn.MarkAnimation    = mark;
            rubiksBtn.TextMessege      = new Text(categoriesName[3], font);
            rubiksBtn.TextMessege.Center(rubiksBtn.Bounds);


            //
            //Menus
            //
            audioMenu = new AudioMenu(audioSettings);
            audioMenu.Initialize(_content, GraphicsDevice);
            audioMenu.Location = new Vector2(375, 65);
            audioMenu.Show     = false;

            rubiksMenu = new RubiksCubeMenu(rubiksSettings);
            rubiksMenu.Initialize(_content, GraphicsDevice);
            rubiksMenu.Location = new Vector2(375, 65);
            rubiksMenu.Show     = false;

            controlsMenu = new ControlsMenu(controlsSettings);
            controlsMenu.Initialize(_content, GraphicsDevice);
            controlsMenu.Location = new Vector2(375, 65);
            controlsMenu.Show     = false;

            graphicsMenu = new GraphicsMenu(graphicsSettings);
            graphicsMenu.Initialize(_content, GraphicsDevice);
            graphicsMenu.Location = new Vector2(375, 65);
            graphicsMenu.Show     = false;


            //
            //Panel
            //
            categories = new MarkableButtonPanel();
            categories.Add(controlsBtn);
            categories.Add(audioBtn);
            categories.Add(windowBtn);
            categories.Add(rubiksBtn);
            categories.SetMarked(0);

            audioBtn.Click    += new EventHandler((s, e) => { audioMenu.Show = true; rubiksMenu.Show = false; controlsMenu.Show = false; graphicsMenu.Show = false; });
            windowBtn.Click   += new EventHandler((s, e) => { audioMenu.Show = false; rubiksMenu.Show = false; controlsMenu.Show = false; graphicsMenu.Show = true; });
            rubiksBtn.Click   += new EventHandler((s, e) => { audioMenu.Show = false; rubiksMenu.Show = true; controlsMenu.Show = false; graphicsMenu.Show = false; });
            controlsBtn.Click += new EventHandler((s, e) => { audioMenu.Show = false; rubiksMenu.Show = false; controlsMenu.Show = true; graphicsMenu.Show = false; });

            //
            //Btns
            //
            backBtn        = new Button(new Sprite2D(_content.Load <Texture2D>("Sprites/BackBtn"), new Rectangle(85, 630, 100, 75)));
            backBtn.Click += On_ExitButtonClick;

            applyBtn        = new Button(new Sprite2D(_content.Load <Texture2D>("Sprites/ApplyBtn"), new Rectangle(1050, 630, 150, 75)));
            applyBtn.Click += On_ApplySettings;

            resetBtn        = new Button(new Sprite2D(_content.Load <Texture2D>("Sprites/ResetBtn"), new Rectangle(825, 630, 150, 75)));
            resetBtn.Click += On_ResetSettings;
        }