void TryToDismissUnit(PartyUnit unit) { // this depends on the fact if unit is dismissable // for example Capital guard is not dimissable // all other units normally are dismissable if (unit.IsDismissable) { // as for confirmation string confirmationMessage; // verify if this is party leader if (unit.IsLeader) { confirmationMessage = "Dismissing party leader will permanently dismiss whole party and all its members. Do you want to dismiss " + unit.GivenName + " " + unit.UnitName + " and whole party?"; } else { confirmationMessage = "Do you want to dismiss " + unit.UnitName + "?"; } // send actions to Confirmation popup, so he knows how to react on no and yes btn presses ConfirmationPopUp.Instance().Choice(confirmationMessage, new UnityAction(OnDismissYesConfirmation), new UnityAction(OnDismissNoConfirmation)); } else { // display error message NotificationPopUp.Instance().DisplayMessage("It is not possible to dismiss " + unit.GivenName + " " + unit.UnitName + "."); } }
public void DeleteSave() { Debug.Log("Delete save"); // querry toggle group for currently selected toggle selectedToggle = savesMenu.GetComponent <TextToggleGroup>().GetSelectedToggle(); // verify if there is any toggle selected now if (selectedToggle == null) { // no any save available // show error message string errMsg = "Error: no any save."; NotificationPopUp.Instance().DisplayMessage(errMsg); } else { // toggle is selected // get file name from selected save string fileName = selectedToggle.GetComponent <Save>().SaveName; // verify if file name is set if (fileName == "") { // file name is empty string errMsg = "Error: file name is empty."; NotificationPopUp.Instance().DisplayMessage(errMsg); } else { // construct full file name fullFilePath = ConfigManager.Instance.GameSaveConfig.GetSaveFullNameByFileName(fileName); // Application.persistentDataPath + "/" + fileName + fileExtension; Debug.Log("File name is " + fullFilePath + ""); // verify if file exists if (File.Exists(fullFilePath)) { // file exists // Ask user whether he wants to delete save ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance(); // set actions UnityAction YesAction = new UnityAction(OnDeleteSaveYesConfirmation); UnityAction NoAction = new UnityAction(OnDeleteSaveNoConfirmation); // set message string confirmationMessage = "Do you want to delete '" + selectedToggle.name + "' save?"; // send actions to Confirmation popup, so he knows how to react on no and yes btn presses confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction); } else { // display error message string errMsg = "Error: [" + fullFilePath + "] file not found. Please try to exit 'Load' menu and open it again."; NotificationPopUp.Instance().DisplayMessage(errMsg); // remove UI element Destroy(selectedToggle.gameObject); } } } }
public void AskQuitToTheMainMenuConfirmation() { // ask for confirmation // Ask user whether he wants to delete save ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance(); // set actions UnityAction YesAction = new UnityAction(OnQuitToTheMainMenuYesConfirmation); UnityAction NoAction = new UnityAction(OnQuitToTheMainMenuNoConfirmation); // set message string confirmationMessage = "Do you want to terminate current game? Not saved progress will be lost."; // send actions to Confirmation popup, so he knows how to react on no and yes btn presses confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction); }
public void UpgradeCity() { // get city City city = focusedObject.GetComponent <City>(); // verify if it is not null if (city != null) { // init city upgrade menu Debug.Log("Ugrading city"); // verify if city has not reached max level (normally button should be disabled, but just in case // verify if city has not reached max level or it is not capital city if (city.CityLevelCurrent >= ConfigManager.Instance.CityUpgradeConfig.maxCityLevel) { // Display notification that city has reached maximum level; NotificationPopUp.Instance().DisplayMessage("City has reached maximum level. No further upgrades are apossible."); } else { // get upgrade cost int cityUpgradeCost = ConfigManager.Instance.CityUpgradeConfig.cityUpgradeCostPerCityLevel[city.CityLevelCurrent + 1]; // verify if player has enough money if (TurnsManager.Instance.GetActivePlayer().TotalGold >= cityUpgradeCost) { // player has enough money // set confirmation message string confirmationMessage = "Do you want to spend " + cityUpgradeCost.ToString() + " gold to upgrade city to the next level?"; // display confirmation pop up asking player whether he wants to upgrade city ConfirmationPopUp.Instance().Choice(confirmationMessage, new UnityEngine.Events.UnityAction(OnCityUpgradeYesConfirmation), new UnityEngine.Events.UnityAction(OnCityUpgradeNoConfirmation)); } else { // player doesn't have enough money // Display notification that player doesn't have enough money NotificationPopUp.Instance().DisplayMessage("You don't have enough money for city upgrade. Required " + cityUpgradeCost.ToString() + " gold."); } } } else { Debug.LogWarning("City is null"); } }
public void Save() { // Open file // get file name from input field string fileName = saveNameInputField.text; // verify if file name is set if (fileName == "") { // file name is not set // show error message string errMsg = "Error: the name of save is not set. Please type new save name or select existing save to overwrite it."; NotificationPopUp.Instance().DisplayMessage(errMsg); } else { // construct full file name fullFilePath = ConfigManager.Instance.GameSaveConfig.GetSaveFullNameByFileName(fileName); Debug.Log("File name is " + fullFilePath + ""); // verify if file exists if (File.Exists(fullFilePath)) { // file exists // Ask user whether he wants to overwrite previous save ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance(); // set actions UnityAction YesAction = new UnityAction(OnOverwriteSaveYesConfirmation); UnityAction NoAction = new UnityAction(OnOverwriteSaveNoConfirmation); // set message string confirmationMessage = "Do you want to overwrite existing save with new data?"; // send actions to Confirmation popup, so he knows how to react on no and yes btn presses confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction); } else { // create file FileStream file = File.Create(fullFilePath); // write to a file and close it SaveGameData(file); } } }
public void Load() { Debug.Log("Load save"); // querry toggle group for currently selected toggle TextToggle selectedToggle = savesMenu.GetComponent <TextToggleGroup>().GetSelectedToggle(); // verify if there is any toggle selected now if (selectedToggle == null) { // no any save available // show error message string errMsg = "Error: no any save."; NotificationPopUp.Instance().DisplayMessage(errMsg); } else { // toggle is selected // get file name from selected save string fileName = selectedToggle.GetComponent <Save>().SaveName; // verify if file name is set if (fileName == "") { // file name is empty string errMsg = "Error: file name is empty."; NotificationPopUp.Instance().DisplayMessage(errMsg); } else { // construct full file name fullFilePath = ConfigManager.Instance.GameSaveConfig.GetSaveFullNameByFileName(fileName); // Application.persistentDataPath + "/" + fileName + fileExtension; //Debug.Log("File name is " + fullFilePath + ""); // verify if file exists if (File.Exists(fullFilePath)) { // file exists // verify if game is already running // check if there is a Chapter in World if (World.Instance.GetComponentInChildren <Chapter>(true) != null) { // game is already running // Ask user whether he wants to load new game ConfirmationPopUp confirmationPopUp = ConfirmationPopUp.Instance(); // set actions UnityAction YesAction = new UnityAction(OnLoadSaveYesConfirmation); UnityAction NoAction = new UnityAction(OnLoadSaveNoConfirmation); // set message string confirmationMessage = "Do you want to terminate current game and load saved game? Not saved progress will be lost."; // send actions to Confirmation popup, so he knows how to react on no and yes btn presses confirmationPopUp.Choice(confirmationMessage, YesAction, NoAction); } else { // game is not running yet // Load game data LoadGameData(); } } else { string errMsg = "Error: [" + fullFilePath + "] file not found. Please verify if file is present on disk drive."; NotificationPopUp.Instance().DisplayMessage(errMsg); } } } }