/// <summary> /// Attached to pause options button /// </summary> public void OpenOptionsMenu() { PausedMenuPanel.SetActive(false); OptionsMenuPanel.SetActive(true); mmusGameManagerScript.EnterSettingsMenuState(); SaveAndSettingsHelper.ApplySettingsToOptionsMenu(); }
// Use this for initialization void Start() { // Disable all but main menu panel. Makes scene starting panel not reliant on scene settings DisableAllPanels(); MainUIPanel.SetActive(true); SaveAndSettingsHelper.ApplyGameSettings(); //gameObject.GetComponent<TooltipDisplayController>().AttachTooltipToObject(gameObject, "Main"); }
/// <summary> /// Attached to Save settings button /// </summary> public void SaveGameSettings() { SaveAndSettingsHelper.SaveSettingsFromOptionsMenu(); mmusGameManagerScript.HotKeyManager.LoadHotkeyProfile(); InputScript.RefreshHotkeyProfile(); mmusMenuPanelController.SetButtonText(); SaveAndSettingsHelper.ApplyGameSettings(); mmusGameManagerScript.ReturnToPauseMenu(); }
/// <summary> /// Delet a given save file. /// Method attached to delete button on save file info buttons /// </summary> /// <param name="pstrFilePath"></param> public void DeleteSaveFile(string pstrFilePath) { if (SaveAndSettingsHelper.DeleteSaveFile(pstrFilePath)) { // File successfully deleted, recreate save file buttons DestroySaveFileButtons(); CreateSaveFileButtons(); } }
/// <summary> /// Plays an animation before transitioning into management mode /// Makes the jump from main menu to management mode less jarring /// </summary> /// <returns></returns> private IEnumerator PlayLoadSaveAnimation(string pstrFilePath, GameInfo pmusGameInfo) { Animator uniAnimation = GetComponent <Animator>(); uniAnimation.SetTrigger("Fade"); yield return(new WaitForSeconds(uniAnimation.GetCurrentAnimatorStateInfo(0).length * 2)); SaveAndSettingsHelper.LoadSceneFromFile(pstrFilePath, pmusGameInfo); }
public void OptionsMenuCancelButtonClicked() { if (SaveAndSettingsHelper.CheckForChangesInOptionsMenu()) { ConfirmationBoxScript.AttachCallbackToConfirmationBox( mmusGameManagerScript.ReturnToPauseMenu, "Unsaved changes will be lost. Are you sure you don't want to save?", "Don't Save", "Cancel"); } else { mmusGameManagerScript.ReturnToPauseMenu(); } }
/// <summary> /// Method when close is clicked in the options menu, check if any unsaved changes exist /// If there are unsaved changes, display a confirmation box to warn player /// </summary> public void CloseOptionsMenu() { bool blnUnsavedChanges = SaveAndSettingsHelper.CheckForChangesInOptionsMenu(); if (blnUnsavedChanges) { // Unsaved changes, show confirmation ConfirmationBoxScript.AttachCallbackToConfirmationBox( OpenMainUI, "Unsaved changes will be lost. Are you sure you don't want to save?", "Don't Save", "Cancel"); } else { // No changes, close normally OpenMainUI(); } }
/// <summary> /// Check the inputs in the Settings menu state. Only keycode input is to return to pause menu. /// </summary> private void CheckSettingsMenuStateInputs() { if (Input.GetKeyDown(mmusHotKeyManager.HotKeys["EscapeKeyCode"]) && muniCurrentKeyDown != mmusHotKeyManager.HotKeys["EscapeKeyCode"]) { // Check for changes in options before closing muniCurrentKeyDown = mmusHotKeyManager.HotKeys["EscapeKeyCode"]; if (SaveAndSettingsHelper.CheckForChangesInOptionsMenu()) { ConfirmationBoxScript.AttachCallbackToConfirmationBox( mmusGameManagerScript.ReturnToPauseMenu, "Unsaved changes will be lost. Are you sure you don't want to save?", "Don't Save", "Cancel"); } else { mmusGameManagerScript.ReturnToPauseMenu(); } } }
/// <summary> /// Attached to game over load last save button /// </summary> public void LoadLastSave() { SaveAndSettingsHelper.LoadLastSave(Application.persistentDataPath + "/SaveFiles", mmusGameManagerScript.GameInfo); }
/// <summary> /// Method attached to save settins button /// </summary> public void SaveSettings() { SaveAndSettingsHelper.SaveSettingsFromOptionsMenu(); SaveAndSettingsHelper.ApplyGameSettings(); }
/// <summary> /// Method for creating save file button objects that player can click on to load files /// Save file buttons are dynamically generated based on info from save and number of saves in save folder /// Allows an undefined number of saves to be loaded, no limit for player on number of saves /// </summary> public void CreateSaveFileButtons() { List <FileInfo> arrSaveFileInfos = new List <FileInfo>(); Button untButtonComponent = null; GameObject uniButtonGameObject = null; GameObject uniDeleteButtonGameObject = null; TextMeshProUGUI uniButtonTextComponent = null; marrButtonObjects = new List <GameObject>(); FileInfo[] arrSavedFileInfo = null; SaveData musLoadedSaveData = null; DirectoryInfo sysSaveDirectoryInfo = null; string strSaveFileInfoText = string.Empty; if (Directory.Exists(mstrGameSaveFileDirectory)) { sysSaveDirectoryInfo = new DirectoryInfo(mstrGameSaveFileDirectory); arrSavedFileInfo = sysSaveDirectoryInfo.GetFiles().OrderByDescending(file => file.LastWriteTimeUtc).ToArray(); foreach (FileInfo sysFileInfo in arrSavedFileInfo) { // Load all "undergods" ugs files from save directory if (sysFileInfo.Extension.Equals(".ugs")) { arrSaveFileInfos.Add(sysFileInfo); } } } // Load information about each save and create a load button foreach (FileInfo sysFileInfo in arrSaveFileInfos) { uniButtonGameObject = (GameObject)Instantiate(SaveButtonPrefab); uniButtonGameObject.transform.SetParent(LoadMenuScrollPanel.transform); untButtonComponent = uniButtonGameObject.GetComponent <Button>(); uniButtonTextComponent = uniButtonGameObject.GetComponentInChildren <TextMeshProUGUI>(); untButtonComponent.onClick.AddListener(() => LoadSaveGame(sysFileInfo.FullName)); untButtonComponent.onClick.AddListener(() => SoundManager.PlaySound("GameStart")); // Add callback to delete save file to callback of confirmation box // Callbacks within Callbacks, we javascript now uniDeleteButtonGameObject = uniButtonGameObject.transform.GetChild(1).gameObject; uniDeleteButtonGameObject.GetComponent <Button>().onClick.AddListener( () => SoundManager.PlaySound("MouseClick")); uniDeleteButtonGameObject.GetComponent <Button>().onClick.AddListener( () => ConfirmationBoxScript.AttachCallbackToConfirmationBox( () => DeleteSaveFile(sysFileInfo.FullName), "Are you sure you want do delete this file?", "Delete")); // Buttons created dynamically, sound effects must also be added dynamically SoundManager.AttachOnHoverSoundToObject("MouseHover", uniDeleteButtonGameObject); musLoadedSaveData = SaveAndSettingsHelper.LoadSaveData(sysFileInfo.FullName); strSaveFileInfoText = string.Format("{0} God of {1}\nCurrentTier: {2}\n{3}", musLoadedSaveData.PlayerFaction.GodName, musLoadedSaveData.PlayerFaction.Type.ToString(), musLoadedSaveData.CurrentTier + 1, sysFileInfo.LastWriteTimeUtc.ToLocalTime().ToShortDateString() + " " + sysFileInfo.LastWriteTimeUtc.ToLocalTime().ToShortTimeString()); uniButtonTextComponent.text = strSaveFileInfoText; uniButtonGameObject.transform.localScale = new Vector3(1, 1, 1); marrButtonObjects.Add(uniButtonGameObject); } }
/// <summary> /// Method linked to open options menu button /// </summary> public void OpenOptionsMenu() { DisableAllPanels(); OptionsPanel.SetActive(true); SaveAndSettingsHelper.ApplySettingsToOptionsMenu(); }