protected override void OnClick() { quest.QuestName = questName; quests.AddQuest(quest); QuestFileManager.SaveFile(quests); this.Close(); }
private void Start() { try { if (!isFirstTime) { Destroy(gameObject); return; } if (m_messageController == null || m_screens == null || m_controllers == null || SettingsPanel == null || SkyBoxMat == null || m_scenesMusicHandler == null || m_mainSceneSound == null || m_gameSceneSound == null || m_audioSource == null || volumeDown == null || volumeUp == null) { Debug.LogError("All fields must be initilized in MainController"); } isFirstTime = false; QuestFileManager.InitializePaths(); InitializeColors(); DontDestroyOnLoad(gameObject);// dont destroy menu SceneManager.sceneLoaded += SceneManager_sceneLoaded; } catch (Exception e) { PrintToLog(e.ToString(), LogType.Error); } }
public void OnLoginClicked() { /*m_mainController.SetCurrentPatient(new Patient() { FullName = "MY TEST p" }); * Therapist therapist = GetUser(); * therapist.FirstName = "Bar"; * therapist.LastName = "Attaly"; * therapist.Email = "*****@*****.**"; * m_mainController.SetLoggedInTherapist(therapist); * m_mainController.ShowScreen(ScreensIndex.TherapistScreen); * //return;*/ int UserName; m_statusText.text = ""; try { if (m_userNameField.text == string.Empty || m_realPassword == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on username field"; return; } Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath); if (existingUser != null) { if (existingUser.Password == GetUser().Password) { m_mainController.SetLoggedInTherapist(existingUser); m_mainController.ShowScreen(ScreensIndex.TherapistScreen); ClearScreen(); return; } m_statusText.text = "Wrong password"; return; } m_statusText.text = "User not found"; } catch (Exception e) { m_statusText.text = ""; // This is the first place that if we dont have the permission for some reason // an excetion will be thrown so we check that we have the permissions just in case: if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite) || !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)) { Permission.RequestUserPermission(Permission.ExternalStorageWrite); Permission.RequestUserPermission(Permission.ExternalStorageRead); } else { m_statusText.text = "Something went wrong. Please restart the application."; } PrintToLog(e.ToString(), MainController.LogType.Error); } }
private static void SendAllReportsInMailForThread(Therapist therapist) { try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(SystemEmail); mail.To.Add(therapist.Email); mail.Subject = therapist.FirstName + " " + therapist.LastName + ": All Patients Reports"; mail.Body = "All patients reports are attached as requested.\nIf the file is not displaying correctly, please open it via Google Docs or Notpad."; string[] patientsFiles = Directory.GetFiles(PinchConstants.PatientsDirectoryPath); foreach (string file in patientsFiles) { Patient patient = QuestFileManager.GetPatientFromFile(file); Attachment attachment = new Attachment(ReportsManager.GetPatientReport(patient), patient.Id + ReportExtention); mail.Attachments.Add(attachment); } SmtpServer.Send(mail); } catch (Exception e) { PrintToLog(e.ToString(), LogType.Error); } }
public void OnSearchClicked() { int id; try { m_statusText.text = ""; if (m_idField.text == string.Empty) { m_statusText.text = "Please enter patient ID"; return; } if (!int.TryParse(m_idField.text, out id)) { m_statusText.text = "Please enter only numbers on ID field"; return; } Patient patient = QuestFileManager.GetPatientFromFile(FilePath); //Patient patient = new Patient() { Id = m_idField.text, FullName = "Bar Attaly", Gender = "Female", Height = "172", Weight = "70" }; if (patient == null) { m_statusText.text = "Patient doesn't exists."; return; } m_mainController.SetCurrentPatient(patient); m_mainController.ShowScreen(ScreensIndex.PatientScreen); ClearScreen(); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
private void OnPopupAnswerFromDeleteInfo(MessageController.MessageAnswer answer) { if (answer == MessageController.MessageAnswer.Yes) { QuestFileManager.DeleteInformationLogFile(); m_mainController.ShowPopup(MessageController.MessageType.Succsess, "Information Log was deleted!"); } }
public void LogoutPatient(string filePath) { if (!QuestFileManager.UpdatePatientOnFile(CurrentPatient, filePath)) { PrintToLog("The patient " + CurrentPatient.FullName + " (" + CurrentPatient.Id + ") file could not be found in order to update.", LogType.Error); } CurrentPatient = null; ShowScreen(ScreensIndex.TherapistScreen); }
public void LogoutTherapist() { PrintToLog("Logout: " + LoggedInTherapist.FirstName + " " + LoggedInTherapist.LastName + " id:" + LoggedInTherapist.Username, LogType.Information); CurrentSettings.SkyBoxColor = DefaultSettings.SkyBoxColor; CurrentSettings.ButtonsColorBlock = DefaultSettings.ButtonsColorBlock; CurrentSettings.ButtonsTextColor = DefaultSettings.ButtonsTextColor; UpdateColors(); QuestFileManager.UpdateTherapistOnFile(LoggedInTherapist, PinchConstants.TherapistsDirectoryPath + LoggedInTherapist.Username); LoggedInTherapist = null; ShowScreen(ScreensIndex.Login); }
public void OnLoginClicked() { /*//m_mainController.SetCurrentPatient(new Patient() { FullName = "MY TEST p" }); * Therapist therapist = GetUser(); * therapist.FirstName = "Bar"; * therapist.LastName = "Attaly"; * therapist.Email = "*****@*****.**"; * //therapist.Settings = m_mainController.DefaultSettings; * therapist.Settings = new Settings * { * SkyBoxColor = m_mainController.DefaultSettings.SkyBoxColor, * ButtonsColorBlock = m_mainController.DefaultSettings.ButtonsColorBlock, * ButtonsTextColor = m_mainController.DefaultSettings.ButtonsTextColor, * SlidersColorBlock = m_mainController.DefaultSettings.SlidersColorBlock * }; * m_mainController.SetLoggedInTherapist(therapist); * m_mainController.ShowScreen(ScreensIndex.TherapistScreen); * return;*/ int UserName; try { if (m_userNameField.text == string.Empty || m_realPassword == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on username field"; return; } Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath); if (existingUser != null) { if (existingUser.Password == GetUser().Password) { m_mainController.SetLoggedInTherapist(existingUser); m_mainController.ShowScreen(ScreensIndex.TherapistScreen); ClearScreen(); return; } m_statusText.text = "Wrong password"; return; } m_statusText.text = "User not found"; } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public void OnConfirmClicked() { int UserName; try { m_statusText.text = string.Empty; if (m_userNameField.text == string.Empty || m_passwordField.text == string.Empty || m_firstNameField.text == string.Empty || m_lastNameField.text == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on ID field"; return; } if (!m_firstNameField.text.All(char.IsLetter) || !m_lastNameField.text.All(char.IsLetter)) { m_statusText.text = "Please enter only letters on Name fields"; return; } if (!IsValidEmail(m_emailField.text)) { m_statusText.text = "Please enter a valid email address"; return; } Therapist newTherapist = GetUserFromGui(); newTherapist.Settings = new Settings { SkyBoxColor = m_mainController.DefaultSettings.SkyBoxColor, ButtonsColorBlock = m_mainController.DefaultSettings.ButtonsColorBlock, ButtonsTextColor = m_mainController.DefaultSettings.ButtonsTextColor, }; if (!QuestFileManager.SaveTherapistToFile(newTherapist, FilePath)) { m_statusText.text = "Therapist already exists"; return; } m_mainController.ShowPopup(MessageController.MessageType.Succsess, "New therapist account has been created!", OnPopupAnswer); PrintToLog("New therapist account was created: " + newTherapist.FirstName + " " + newTherapist.LastName + ", id: " + newTherapist.Username + "." , MainController.LogType.Information); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
protected override void OnClick() { Quest newQuest = new Quest(); newQuest.QuestName = questName; foreach (Objective obj in quest.getObjectives()) { newQuest.addObjective(obj); } quests.UpdateQuest(quest, newQuest); QuestFileManager.SaveFile(quests); this.Close(); }
private void Start() { Button[] buttons; try { if (!isFirstTime) { Destroy(gameObject); return; } if (m_messageController == null || m_screens == null || m_controllers == null || SettingsPanel == null || SkyBoxMat == null) { Debug.LogError("All fields must be initilized in MainController"); } QuestFileManager.InitialPaths(); //ShowScreen(ScreensIndex.Login); buttons = Resources.FindObjectsOfTypeAll <Button>(); NonImageButtons = new List <Button>(); if (buttons != null) { foreach (Button button in buttons) { if (button.GetComponentInChildren <Image>().sprite != null) { if (button.GetComponentInChildren <Image>().sprite.name == "UISprite") { string test = button.GetComponentInChildren <TMP_Text>().text; if (button.GetComponentInChildren <TMP_Text>().text != string.Empty && button.GetComponentInChildren <TMP_Text>().text != "Ok" && button.GetComponentInChildren <TMP_Text>().text != "Yes" && button.GetComponentInChildren <TMP_Text>().text != "Cancel" && button.GetComponentInChildren <TMP_Text>().text != "Save Changes" && button.GetComponentInChildren <TMP_Text>().text != "Button") { NonImageButtons.Add(button); } } } } } InitializeColors(); isFirstTime = false; DontDestroyOnLoad(gameObject);// dont destroy menu SceneManager.sceneLoaded += SceneManager_sceneLoaded; } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public void UpdateQuest(Quest oldQuest, Quest newQuest) { int index = quests.FindIndex(quest => quest.QuestName == oldQuest.QuestName); if (index != -1) { quests[index] = newQuest; QuestFileManager.DeleteQuest(oldQuest); } else { Debug.LogException(new System.ArgumentException("Can't find quest: " + oldQuest.QuestName)); } }
public void OnConfirmClicked() { int id; try { m_statusText.text = string.Empty; if (m_fullNameField.text == string.Empty || m_heightField.text == string.Empty || m_weightField.text == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!m_fullNameField.text.All(char.IsLetter) && !m_fullNameField.text.Contains(" ")) { m_statusText.text = "Please enter only letters on full name field"; return; } if (!int.TryParse(m_heightField.text, out id)) { m_statusText.text = "Please enter only numbers on height field"; return; } if (!int.TryParse(m_weightField.text, out id)) { m_statusText.text = "Please enter only numbers on weight field"; return; } if (QuestFileManager.GetPatientFromFile(FilePath) == null) { m_statusText.text = "Patient doesn't exists"; return; } Patient patient = GetUserFromGui(); m_mainController.CurrentPatient.FullName = patient.FullName; m_mainController.CurrentPatient.Gender = patient.Gender; m_mainController.CurrentPatient.Height = patient.Height; m_mainController.CurrentPatient.Weight = patient.Weight; m_mainController.CurrentPatient.Hand = patient.Hand; QuestFileManager.UpdatePatientOnFile(m_mainController.CurrentPatient, FilePath); m_mainController.ShowPopup(MessageController.MessageType.Succsess, "Patient details has been updated!", OnPopupAnswerFromConfirm); m_statusText.text = string.Empty; PrintToLog("Patient's details update: " + m_mainController.CurrentPatient.FullName + " " + ", id: " + m_mainController.CurrentPatient.Id + ". Updated by the therapist: " + m_mainController.LoggedInTherapist.FirstName + " " + m_mainController.LoggedInTherapist.LastName + ", id: " + m_mainController.LoggedInTherapist.Username + ".", MainController.LogType.Information); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public void OnConfirmClicked() { int id; try { m_statusText.text = string.Empty; if (m_idField.text == string.Empty || m_fullNameField.text == string.Empty || m_heightField.text == string.Empty || m_weightField.text == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_idField.text, out id)) { m_statusText.text = "Please enter only numbers on ID field"; return; } if (!m_fullNameField.text.All(char.IsLetter) && !m_fullNameField.text.Contains(" ")) { m_statusText.text = "Please enter only letters on full name field"; return; } if (!int.TryParse(m_heightField.text, out id)) { m_statusText.text = "Please enter only numbers on height field"; return; } if (!int.TryParse(m_weightField.text, out id)) { m_statusText.text = "Please enter only numbers on weight field"; return; } if (!QuestFileManager.SaveNewPatientToFile(GetUserFromGui(), FilePath)) { m_statusText.text = "Patient already exists"; return; } m_mainController.SetCurrentPatient(GetUserFromGui()); m_mainController.ShowPopup(MessageController.MessageType.Succsess, "New patient account has been created!", OnPopupAnswer); PrintToLog("New patient account was created: " + m_mainController.CurrentPatient.FullName + " " + ", id: " + m_mainController.CurrentPatient.Id + ". Created by the therapist: " + m_mainController.LoggedInTherapist.FirstName + " " + m_mainController.LoggedInTherapist.LastName + ", id: " + m_mainController.LoggedInTherapist.Username + ".", MainController.LogType.Information); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public void OnConfirmClicked() { int UserName; try { m_statusText.text = ""; if (m_userNameField.text == string.Empty || m_passwordField.text == string.Empty || m_firstNameField.text == string.Empty || m_lastNameField.text == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on ID field"; return; } /*if (File.Exists(FilePath)) * { * m_statusText.text = "Therapist is already exists"; * return; * }*/ if (!m_firstNameField.text.All(char.IsLetter) || !m_lastNameField.text.All(char.IsLetter)) { m_statusText.text = "Please enter only letters on Name fields"; return; } if (!IsValidEmail(m_emailField.text)) { m_statusText.text = "Please enter a valid email address"; return; } if (!QuestFileManager.SaveTherapistToFile(GetUserFromGui(), FilePath)) { m_statusText.text = "Therapist already exists."; return; } m_mainController.ShowPopup(MessageController.MessageType.Succsess, "New therapist account has created!", OnPopupAnswer); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
private void LevelEnded() { m_mainController.m_audioSource.volume = 0.1f; try { m_floatTextController.UpdateFloatTextSettings(AnimationTypeIndex.BottomToTop, "Level up!", Color.green); } catch (Exception e) { MainController.PrintToLog("Can't do level up animation - " + e.ToString(), MainController.LogType.Error); } try { m_audioSource.clip = m_winningSound; m_audioSource.Play(); } catch (Exception e) { MainController.PrintToLog("Can't play winning sound - " + e.ToString(), MainController.LogType.Error); } m_mainController.CurrentPatient.TreatmentsHistory.Add(m_mainController.CurrentPatient.CurrentTreatment); int newTreatmentNumber = m_mainController.CurrentPatient.CurrentTreatment.TreatmentNumber + 1; int ST = 0; foreach (Challenge c in m_mainController.CurrentPatient.CurrentTreatment.Plan) { ST += c.ActionsList.Count; } m_mainController.CurrentPatient.CurrentTreatment = new TreatmentPlan() { TreatmentNumber = newTreatmentNumber, CreationTime = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), Plan = Algorithm.GenerateNewLevel(m_mainController.CurrentPatient.CurrentTreatment.Plan, PinchManager.PT, ST) }; PinchManager.PT = 0; try { QuestFileManager.UpdatePatientOnFile(m_mainController.CurrentPatient, PinchConstants.PatientsDirectoryPath + m_mainController.CurrentPatient.Id); } catch (Exception e) { MainController.PrintToLog("Can't update patient file in TherapyManager - " + e.ToString(), MainController.LogType.Error); } InitilizeSceneAccordingToPlan(); }
public void OnConfirmClicked() { int UserName; try { m_statusText.text = string.Empty; if (m_userNameField.text == string.Empty || m_passwordField.text == string.Empty || m_firstNameField.text == string.Empty || m_lastNameField.text == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on ID field"; return; } if (!m_firstNameField.text.All(char.IsLetter) || !m_lastNameField.text.All(char.IsLetter)) { m_statusText.text = "Please enter only letters on Name fields"; return; } if (!IsValidEmail(m_emailField.text)) { m_statusText.text = "Please enter a valid email address"; return; } if (QuestFileManager.GetTherapistFromFile(FilePath) == null) { m_statusText.text = "Therapist doesn't exists"; return; } Therapist therapist = GetUserFromGui(); m_mainController.LoggedInTherapist.Password = therapist.Password; m_mainController.LoggedInTherapist.FirstName = therapist.FirstName; m_mainController.LoggedInTherapist.LastName = therapist.LastName; m_mainController.LoggedInTherapist.Email = therapist.Email; QuestFileManager.UpdateTherapistOnFile(m_mainController.LoggedInTherapist, FilePath); m_mainController.ShowPopup(MessageController.MessageType.Succsess, "Therapist details has been updated!", OnPopupAnswer); PrintToLog("Therapist's details update: " + m_mainController.LoggedInTherapist.FirstName + " " + m_mainController.LoggedInTherapist.LastName + ", id: " + m_mainController.LoggedInTherapist.Username + ".", MainController.LogType.Information); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public static void SaveFile(QuestTree data) { List <Quest> quests = data.GetQuests(); if (!Directory.Exists(Application.dataPath + "/Quests/")) { Directory.CreateDirectory(Application.dataPath + "/Quests/"); } foreach (Quest quest in quests) { string path = Application.dataPath + "/Quests/" + filename + "_" + quest.QuestName + ".json"; File.Delete(path); StreamWriter writer = new StreamWriter(File.OpenWrite(path), System.Text.Encoding.UTF8); Debug.Log(QuestFileManager.serializeQuest(quest)); writer.Write(QuestFileManager.serializeQuest(quest)); writer.Close(); } }
public void LogoutTherapist() { try { PrintToLog("Therapist logout: " + LoggedInTherapist.FirstName + " " + LoggedInTherapist.LastName + ", id: " + LoggedInTherapist.Username + ".", LogType.Information); CurrentSettings.SkyBoxColor = DefaultSettings.SkyBoxColor; CurrentSettings.ButtonsColorBlock = DefaultSettings.ButtonsColorBlock; CurrentSettings.ButtonsTextColor = DefaultSettings.ButtonsTextColor; UpdateColors(); QuestFileManager.UpdateTherapistOnFile(LoggedInTherapist, PinchConstants.TherapistsDirectoryPath + LoggedInTherapist.Username); LoggedInTherapist = null; ShowScreen(ScreensIndex.Login); } catch (Exception e) { PrintToLog(e.ToString(), MainController.LogType.Error); } }
public void OnGUI() { if (quests.GetQuests().Count == 0) { quests = QuestFileManager.LoadFile(); } if (GUILayout.Button("Add quest", GUILayout.MaxWidth(100))) { AddQuest addQuestEditor = (AddQuest)EditorWindow.GetWindow(typeof(AddQuest)); addQuestEditor.setQuestTree(quests); addQuestEditor.Show(); } if (GUILayout.Button("Reset quest", GUILayout.MaxWidth(100))) { foreach (Quest quest in quests.GetQuests()) { QuestFileManager.DeleteQuest(quest); } quests.Empty(); } EditorGUILayout.BeginScrollView(new Vector2(0, 0), true, true); if (quests.GetQuests().Count != 0) { foreach (Quest quest in quests.GetQuests()) { if (GUILayout.Button(quest.QuestName, GUILayout.MaxWidth(100))) { EditQuest editQuest = (EditQuest)EditorWindow.GetWindow(typeof(EditQuest)); editQuest.setQuestTree(quests); editQuest.setQuest(quest); editQuest.Show(); } } } EditorGUILayout.EndScrollView(); }
public void OnLoginClicked() { int UserName; m_statusText.text = ""; try { if (m_userNameField.text == string.Empty || m_realPassword == string.Empty) { m_statusText.text = "Please fill all data"; return; } if (!int.TryParse(m_userNameField.text, out UserName)) { m_statusText.text = "Please enter only numbers on username field"; return; } Therapist existingUser = QuestFileManager.GetTherapistFromFile(FilePath); if (existingUser != null) { if (existingUser.Password == GetUser().Password) { m_mainController.SetLoggedInTherapist(existingUser); //in case this is an old user, and it doesn't have settings attribute if (m_mainController.LoggedInTherapist.Settings == null) { m_mainController.LoggedInTherapist.Settings = new Settings() { SkyBoxColor = m_mainController.DefaultSettings.SkyBoxColor, ButtonsColorBlock = m_mainController.DefaultSettings.ButtonsColorBlock, ButtonsTextColor = m_mainController.DefaultSettings.ButtonsTextColor, }; } m_mainController.ShowScreen(ScreensIndex.TherapistScreen); ClearScreen(); return; } m_statusText.text = "Wrong password"; return; } m_statusText.text = "User not found"; } catch (Exception e) { m_statusText.text = ""; // This is the first place that if we dont have the permission for some reason // an excetion will be thrown so we check that we have the permissions just in case: if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite) || !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)) { Permission.RequestUserPermission(Permission.ExternalStorageWrite); Permission.RequestUserPermission(Permission.ExternalStorageRead); } else { m_statusText.text = "Something went wrong. Please restart the application."; } PrintToLog(e.ToString(), MainController.LogType.Error); } }
private IEnumerator NextLevel() { isReady = false; float secondsToWait = 5; switch (stepNum)// the level that we just finished { case 0: StartCoroutine(PlayInstructionsSounds(3, 1)); m_2tipHand.SetActive(true); stopwatch.Start(); m_feedbackText.text = "Let's Start!"; yield return(new WaitForSeconds(secondsToWait)); break; case 1: m_2tipHand.SetActive(false); m_feedbackText.text = "Good job! 3 more"; yield return(new WaitForSeconds(secondsToWait)); m_3tipHand.SetActive(true); break; case 2: m_3tipHand.SetActive(false); m_feedbackText.text = "Good job! 2 more"; yield return(new WaitForSeconds(secondsToWait)); m_2padHand.SetActive(true); break; case 3: m_2padHand.SetActive(false); m_feedbackText.text = "Good job! 1 more"; yield return(new WaitForSeconds(secondsToWait)); m_3padHand.SetActive(true); break; case 4: StartCoroutine(PlayInstructionsSounds(2, 0)); m_3padHand.SetActive(false); m_feedbackText.text = "Finished!\nGoing back to main menu..."; m_mainController.CurrentPatient.MotionRange.IsCalibrated = true; try { QuestFileManager.UpdatePatientOnFile(m_mainController.CurrentPatient, PinchConstants.PatientsDirectoryPath + m_mainController.CurrentPatient.Id); } catch (Exception e) { MainController.PrintToLog("Can't update patient file in CalibrationManager - " + e.ToString(), MainController.LogType.Error); } yield return(new WaitForSeconds(secondsToWait + 2)); MainController.LoadMainScene(); break; } stepNum++; isReady = true; stopwatch.Reset(); stopwatch.Start(); }