Esempio n. 1
0
    //Finds the settings manager in the scene and takes the player input and sends that data to the manager.
    public void SaveSettings()
    {
        SettingsManager settingsManager = (SettingsManager)FindObjectOfType(typeof(SettingsManager));

        fullscreen = (Toggle)FindObjectOfType(typeof(Toggle));
        volume     = (Slider)FindObjectOfType(typeof(Slider));
        screenSize = (Dropdown)FindObjectOfType(typeof(Dropdown));
        settingsManager.fullscreen = fullscreen.isOn;
        settingsManager.volume     = volume.value;
        if (screenSize.value == 0)
        {
            settingsManager.screenWidth  = 1920;
            settingsManager.screenHeight = 1080;
        }
        else if (screenSize.value == 1)
        {
            settingsManager.screenWidth  = 1366;
            settingsManager.screenHeight = 768;
        }
        else if (screenSize.value == 2)
        {
            settingsManager.screenWidth  = 1600;
            settingsManager.screenHeight = 900;
        }
        settingsManager.ApplySettings();
    }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Register services
            Services.AddService(_graphicsDeviceManager);
            Services.AddService(_gameInfo);
            Services.AddService(_settingsManager);
            Services.AddService(_audioManager);
            Services.AddService(_inputManager);
            Services.AddService(_actorRegistry);

            // Initialize the components
            Components.ForEach(c => c.Initialize());

            // Load content for this game and the components
            LoadContent();

            // Apply settings
            GameSettings settings = _settingsManager.LoadSettings() ?? _settingsManager.GetDefaultSettingsCopy();

            _settingsManager.ApplySettings(settings);
            _settingsManager.SaveSettings();

            // Set the initial state of the game
            _gameInfo.State = GameState.InMenu;
        }
Esempio n. 3
0
        // Applies the gameplay settings and starts the game
        private void Play()
        {
            GameSettings settings = _settingsManager.GetSettingsCopy();

            Tuple <Type, Type> paddleTypes = (Tuple <Type, Type>)_playersItem.SelectedValue;

            settings.Gameplay.LeftPaddleType  = paddleTypes.Item1;
            settings.Gameplay.RightPaddleType = paddleTypes.Item2;
            settings.Gameplay.ScoreLimit      = (int)_scoreLimitItem.SelectedValue;
            settings.Gameplay.TimeLimit       = (TimeSpan)_timeLimitItem.SelectedValue;
            settings.Gameplay.BallCount       = (int)_ballCountItem.SelectedValue;

            // When 'auto increase' has been selected as speed, enabled it and start at the default speed
            if (_gameSpeedItem.SelectedValue == null)
            {
                settings.Gameplay.GameSpeed         = SettingsConstants.GameSpeedMinValue;
                settings.Gameplay.AutoIncreaseSpeed = true;
            }
            else
            {
                settings.Gameplay.GameSpeed         = (float)_gameSpeedItem.SelectedValue;
                settings.Gameplay.AutoIncreaseSpeed = false;
            }

            _settingsManager.ApplySettings(settings);
            _settingsManager.SaveSettings();

            // Change the game's state to start the game
            _gameInfo.State = GameState.InProgress;

            Close();
        }
Esempio n. 4
0
        // Applies the audio settings
        private void Apply()
        {
            GameSettings settings = _settingsManager.GetSettingsCopy();

            settings.Audio.Enabled = (bool)_enabledItem.SelectedValue;
            settings.Audio.Volume  = (int)_volumeItem.SelectedValue;
            settings.Audio.SfxSet  = (int)_sfxSetItem.SelectedValue;

            _settingsManager.ApplySettings(settings);
            _settingsManager.SaveSettings();

            Close();
        }
Esempio n. 5
0
        // Applies the controls
        private void Apply()
        {
            GameSettings settings = _settingsManager.GetSettingsCopy();

            settings.Controls.LeftPaddle.MoveUp    = (Keys)_leftUpItem.SelectedValue;
            settings.Controls.LeftPaddle.MoveDown  = (Keys)_leftDownItem.SelectedValue;
            settings.Controls.RightPaddle.MoveUp   = (Keys)_rightUpItem.SelectedValue;
            settings.Controls.RightPaddle.MoveDown = (Keys)_rightDownItem.SelectedValue;

            _settingsManager.ApplySettings(settings);
            _settingsManager.SaveSettings();

            Close();
        }
Esempio n. 6
0
        // Applies the video settings
        private void Apply()
        {
            GameSettings originalSettings = _settingsManager.GetSettingsCopy();
            GameSettings newSettings      = originalSettings.Clone();

            newSettings.Video.Resolution = (Vector2)_resolutionsItem.SelectedValue;
            newSettings.Video.VSync      = (bool)_vSyncItem.SelectedValue;
            newSettings.Video.FullScreen = (bool)_fullScreenItem.SelectedValue;

            // Simply close the page when nothing has changed
            if (originalSettings.Video.Equals(newSettings.Video))
            {
                Close();
                return;
            }

            _settingsManager.ApplySettings(newSettings);

            // Setup and open the confirmation page and revert the changes when no confirmation has been given

            ConfirmationMenuPage confirmationPage = new ConfirmationMenuPage();

            confirmationPage.Confirm += (sender, args) =>
            {
                _settingsManager.SaveSettings();
                Close();
            };

            confirmationPage.Cancel += (sender, args) =>
            {
                _settingsManager.ApplySettings(originalSettings);
                _settingsManager.SaveSettings();
                Close();
            };

            OpenSubPage(confirmationPage);
        }
Esempio n. 7
0
    private void DrawConfigGUI(int windowId)
    {
        if (GUILayout.Button("Restart"))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        GUILayout.BeginHorizontal();
        if (settings != null)
        {
            GUI.changed = false;
            bool tutorialsEnabled = GUILayout.Toggle(settings.tutorialsEnabled, "Tutorials");
            if (GUI.changed)
            {
                settings.tutorialsEnabled = tutorialsEnabled;
                settings.ApplySettings();
            }
        }
        if (debugView != null)
        {
            GUI.changed = false;
            bool debugViewActive = GUILayout.Toggle(debugView.activeSelf, "Debug View");
            if (GUI.changed)
            {
                debugView.SetActive(debugViewActive);
            }
        }
        GUILayout.EndHorizontal();
        if (mapHandle != null)
        {
            mapHandle.mapConfiguration.hazards.hazardsEnabled = GUILayout.Toggle(mapHandle.mapConfiguration.hazards.hazardsEnabled, "Hazards");
        }

        GUILayout.Label("Timescale:");
        GUILayout.BeginHorizontal();
        GUILayout.Label(locationHandle.timeScale.ToString("0.##"), GUILayout.Width(64));
        float slider = PowLeaveSign(locationHandle.timeScale, 1 / 5f);

        slider = GUILayout.HorizontalSlider(slider, -Mathf.Pow(10000, 1 / 5f), Mathf.Pow(10000, 1 / 5f));
        locationHandle.timeScale = Mathf.Pow(slider, 5f);
        GUILayout.EndHorizontal();

        GUILayout.Label("Time control:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("+1 h"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddHours(1);
        }
        if (GUILayout.Button("+1 d"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddDays(1);
        }
        if (GUILayout.Button("+1 m"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddMonths(1);
        }
        if (GUILayout.Button("+1 y"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddYears(1);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("-1 h"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddHours(-1);
        }
        if (GUILayout.Button("-1 d"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddDays(-1);
        }
        if (GUILayout.Button("-1 m"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddMonths(-1);
        }
        if (GUILayout.Button("-1 y"))
        {
            locationHandle.location.dateTimeOffset = locationHandle.location.dateTimeOffset.AddYears(-1);
        }
        GUILayout.EndHorizontal();

        GUI.DragWindow();
    }
Esempio n. 8
0
 private void OnTutorialsToggleChanged(bool val)
 {
     settings.tutorialsEnabled = val;
     settings.ApplySettings();
 }