public List <NotificationPopUp> GetAllTodayNotificationTime() { string sql = "SELECT t.Task_ID,n.Notify_Via,Task_Tittle,Task_Description,Notify_Time FROM NotifiyTime n,Tasks t where Notify_Date = '" + DateTime.Now.ToShortDateString() + "' and t.Task_ID = n.Task_ID and t.Task_Repeat_Date = n.Repeat_Task_ID"; List <NotificationPopUp> timeList = new List <NotificationPopUp>(); using (SqlDataReader reader = dataAccess.GetData(sql)) { if (reader.HasRows) { while (reader.Read()) { NotificationPopUp npu = new NotificationPopUp(); npu.Time = reader["Notify_Time"].ToString(); npu.Name = reader["Task_Tittle"].ToString(); npu.Description = reader["Task_Description"].ToString(); npu.Task_ID = (int)reader["Task_ID"]; npu.Notify_Via = (int)reader["Notify_Via"]; timeList.Add(npu); } } return(timeList); } }
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 + "."); } }
void BringHireUnitPnlButtonToTheFront() { transform.root.GetComponentInChildren <UIManager>().transform.Find("HireCommonUnitButtons").SetAsLastSibling(); // verify if notification pop-up window is active NotificationPopUp if (NotificationPopUp.Instance().NotificationPopUpGO.activeSelf) { // set nofiction pop-up as last sibling NotificationPopUp.Instance().NotificationPopUpGO.transform.SetAsLastSibling(); } }
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 static NotificationPopUp Instance() { if (!notificationPopUp) { notificationPopUp = FindObjectOfType(typeof(NotificationPopUp)) as NotificationPopUp; if (!notificationPopUp) { // Debug.LogError("There needs to be only one ConfirmationPopUp script on a GameObject in your scene."); } } return(notificationPopUp); }
private void CustomNotificationPopUp(NotificationPopUp obj) { notifyPopUp = obj; if (obj.Notify_Via == 1) { } else if (obj.Notify_Via == 2) { } else { } cs = new CustomNotificationPopUp(); cs.Top = 30; cs.Left = Screen.PrimaryScreen.Bounds.Width - cs.Width - 30; cs.setLabel(obj.Name, obj.Description); cs.Show(); }
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); } } }
private void CustomNotificationPopUp(NotificationPopUp obj) { notifyPopUp = obj; if (obj.Notify_Via == 1) { us = new UserSer(); string uEmail = us.GetUserEmail(LogIn.user_ID); string ms = obj.Name + "\n\n\n\n" + obj.Description; SendEMail(uEmail, ms); } else if (obj.Notify_Via == 2) { MessageBox.Show("This is Not Updated Yet. Bacause It has Money to get this service"); } else { cs = new CustomNotificationPopUp(); cs.Top = 30; cs.Left = Screen.PrimaryScreen.Bounds.Width - cs.Width - 30; cs.setLabel(obj.Name, obj.Description); cs.Show(); } }
void ExitChapter() { // idea: add option to continue playing this chapter and continue to next chapter or end game when player wish // .. Debug.Log("Exit chapter"); string messageText; if (failed) { NotificationPopUp.Instance().NotificationPopUpGO.GetComponentInChildren <NotificationPopUpOkButton>().SetOnClickFunc(EndGame); messageText = "You failed to complete this chapter. " + failureReason; } else if (completed) { if (activeChapter.ChapterData.lastChapter) { NotificationPopUp.Instance().NotificationPopUpGO.GetComponentInChildren <NotificationPopUpOkButton>().SetOnClickFunc(ShowCredits); messageText = "Congratulations! You have completed this game!"; } else { NotificationPopUp.Instance().NotificationPopUpGO.GetComponentInChildren <NotificationPopUpOkButton>().SetOnClickFunc(GoToNextChapter); messageText = "Congratulations! You have completed this chapter."; } } else { Debug.LogError("Unhandled condition"); messageText = "Unhandled condition"; } NotificationPopUp.Instance().SetMessage(messageText); NotificationPopUp.Instance().NotificationPopUpGO.SetActive(true); // reset variables to remove constant popups on Update() function call: failed = false; activeChapter.ChapterData.goalTargetCityCaptured = false; activeChapter.ChapterData.goalTargetHeroDestroyed = false; }
// context is destination unit slot public void OnUnitSlotLeftClickEvent(System.Object context) { // verify if context is correct if (context is UnitSlot) { // init unit slot from context UnitSlot unitSlot = (UnitSlot)context; // Verify if battle has not ended if (!BattleHasEnded) { //Debug.Log("UnitSlot ActOnClick in Battle screen"); // act based on the previously set by SetOnClickAction by PartyPanel conditions if (unitSlot.IsAllowedToApplyPowerToThisUnit) { // it is allowed to apply powers to the unit in this cell // Block mouse input InputBlocker.SetActive(true); // Trigger Event // Listeners: All active PartyPanelCell(s) battleApplyActiveUnitAbilityEvent.Raise(unitSlot); // tmp: //unitSlot.GetComponentInParent<PartyPanel>().ApplyPowersToUnit(unitSlot.GetComponentInChildren<PartyUnitUI>()); // set unit has moved flag ActiveUnitUI.LPartyUnit.HasMoved = true; // activate next unit ActivateNextUnit(); } else { // it is not allowed to use powers on this cell // display error message NotificationPopUp.Instance().DisplayMessage(unitSlot.ErrorMessage); } } } }
//public void ActOnHeroEnteringCity() //{ // // Instruct Focus panel to update info // transform.parent.Find("LeftFocus").GetComponent<FocusPanel>().OnChange(FocusPanel.ChangeType.Init); // // Disable Hire leader panel // transform.parent.Find("HireHeroPanel").gameObject.SetActive(false); //} #endregion States #region Hire Unit bool VerifyIfPlayerHasEnoughGoldToBuyUnit(PartyUnit hiredUnitTemplate) { bool result = false; int requiredGold = hiredUnitTemplate.UnitCost; // Verify if player has enough gold if (TurnsManager.Instance.GetActivePlayer().TotalGold >= requiredGold) { result = true; } else { // display message that is not enough gold if (hiredUnitTemplate.IsLeader) { NotificationPopUp.Instance().DisplayMessage("More gold is needed to hire this party leader."); } else { NotificationPopUp.Instance().DisplayMessage("More gold is needed to hire this party member."); } } return(result); }
public void OnDrop(PointerEventData eventData) { // verify if we are in city edit mode and not in hero edit mode EditPartyScreen cityScreen = transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>(); if (cityScreen != null) { // activate hire unit buttons again, after it was disabled cityScreen.SetHireUnitPnlButtonActive(true); } // verify if it is item being dragged if (InventoryItemDragHandler.itemBeingDragged != null) { // raise on item drop event (pass this slot as argument) itemHasBeenDroppedIntoTheUnitSlotEvent.Raise(this); //// verify if there is a unit in the slot //if (GetComponentInChildren<PartyUnitUI>() != null) //{ // // try to apply item to the unit // GetComponentInChildren<PartyUnitUI>().ActOnItemDrop(InventoryItemDragHandler.itemBeingDragged); //} // reset cursor to normal // CursorController.Instance.SetNormalCursor(); } // verify if it is party unit being dragged else if (UnitDragHandler.unitBeingDraggedUI != null) { // raise on unit drop event unitUIHasBeenDroppedIntoTheUnitSlotEvent.Raise(this); // act based on the previously set by OnDrag condition if (isDropAllowed) { // drop is allowed // act based on then draggable unit size // get actual unit, structure Cell-UnitCanvas(dragged->Unit link) PartyUnit draggedUnit = UnitDragHandler.unitBeingDraggedUI.GetComponent <PartyUnitUI>().LPartyUnit; Transform srcCellTr = UnitDragHandler.unitBeingDraggedUI.transform.parent.parent; Transform dstCellTr = transform.parent; if (draggedUnit.UnitSize == UnitSize.Single) { // single unit // possible states // src dst result // 1 free or occupied by single unit swap single cells // 1 occupied by double swap cells in horizontal panels // act based on destination cell size if (UnitSize.Single == cellSize) { // swap single cells SwapTwoCellsContent(srcCellTr, dstCellTr); } else { // swap 2 single cells in src panel with double cell in dest panel SwapSingleWithDouble(srcCellTr, dstCellTr, true); } } else { // double unit if (UnitSize.Single == cellSize) { // swap single with double cells SwapSingleWithDouble(srcCellTr, dstCellTr, false); } else { // swap 2 double cells SwapTwoCellsContent(srcCellTr, dstCellTr); } } // Instruct focus panels to be updated foreach (FocusPanel focusPanel in transform.root.GetComponentInChildren <UIManager>().GetComponentsInChildren <FocusPanel>()) { focusPanel.OnChange(FocusPanel.ChangeType.UnitsPositionChange); } //// drop unit if there is no other unit already present //if (!unit) //{ // PartyPanelMode panelMode = UnitDragHandler.unitBeingDragged.transform.parent.parent.parent.parent.GetComponent<PartyPanel>().GetPanelMode(); // if (PartyPanelMode.Garnizon == panelMode) // { // // enable hire unit button in the original parent cell and bring it to the front // // and it is not wide // // todo: add not wide condition check // } // // change parent of the dragged unit // Debug.Log("Drop unit from " + UnitDragHandler.unitBeingDraggedParentTr.parent.gameObject.name); // UnitDragHandler.unitBeingDragged.transform.SetParent(transform); // // disable hire unit button in the destination (this) cell, if it is garnizon panel // // structure 3PartyPanel-2Top/Middle/Bottom-1Front/Back/Wide-(this)UnitSlot // panelMode = transform.parent.parent.parent.GetComponent<PartyPanel>().GetPanelMode(); // if (PartyPanelMode.Garnizon == panelMode) // { // // todo: add not wide condition check // } // // trigger event // // ExecuteEvents.ExecuteHierarchy<IHasChanged>(gameObject, null, (x, y) => x.HasChanged()); //} } else { // drop is not allowed // display error message NotificationPopUp.Instance().DisplayMessage(errorMessage); } } else { Debug.LogWarning("Unknown object is being dragged"); } }
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); } } } }
private async void CallPopUp(Notification notification) { var popUp = new NotificationPopUp(notification.Title, notification.Description); await PopupNavigation.Instance.PushAsync(popUp); }