IEnumerator FinishAction(string nameOfAction) { yield return(StartCoroutine(PlayerClass.CheckConn())); if (PlayerClass.conOk) { WWWForm form = new WWWForm(); form.AddField("playername", PlayerPrefs.GetString("PlayerName")); if (nameOfAction == "Learning") { form.AddField("schoolname", PlayerPrefs.GetString("SchoolWhereLearningNow")); form.AddField("selskill", PlayerPrefs.GetString("SelectedLearnedSkill")); UnityWebRequest www = UnityWebRequest.Post(URLs.Link("FinishLearning"), form); yield return(www.SendWebRequest()); Debug.Log(www.downloadHandler.text); string[] answer = www.downloadHandler.text.Split('^'); if (!www.isNetworkError) { for (int i = 0; i < answer.Length; i++) { if (answer[i] == "Skill learned") { PlayerPrefs.DeleteKey("IsLearningTimerDate"); GameStateManager.Message(Localize.LocalizeMessage("LearningComplete")); StartCoroutine(GameStateManager.ClearMessage()); } } yield return(PlayerClass.GetPlayerData("PassiveSkills")); Destroy(LearningTimer, 0.001f); if (GameObject.Find("MusicSchoolWindow") != null) { StartCoroutine(GameObject.Find("MusicSchoolWindow").GetComponent <LearningPlaces>().OnSchoolIconButtonPressed()); } } WWWForm formstat = new WWWForm(); formstat.AddField("playername", PlayerClass.GetPlayerName()); formstat.AddField("learningcomplete", 1); formstat.AddField("schoolname", PlayerPrefs.GetString("SchoolWhereLearningNow")); UnityWebRequest wwwstat = UnityWebRequest.Post(URLs.Link("UpdateStatistic"), formstat); yield return(wwwstat.SendWebRequest()); Debug.Log(wwwstat.downloadHandler.text); } else if (nameOfAction == "Upgrading") { form.AddField("itemname", PlayerPrefs.GetString("SelectedItemToUpgrade")); form.AddField("finish", "yes"); UnityWebRequest www = UnityWebRequest.Post(URLs.Link("UpgradeItem"), form); yield return(www.SendWebRequest()); Debug.Log(www.downloadHandler.text); string[] answer = www.downloadHandler.text.Split('^'); if (!www.isNetworkError) { for (int i = 0; i < answer.Length; i++) { if (answer[i] == "Upgrade finished") { PlayerPrefs.DeleteKey("IsUpgradingTimerDate"); PlayerPrefs.DeleteKey("SelectedItemToUpgrade"); GameStateManager.Message(Localize.LocalizeMessage("ItemUpdatingComplete")); StartCoroutine(GameStateManager.ClearMessage()); } } yield return(PlayerClass.GetPlayerData("Items")); Destroy(UpgradeTimer, 0.001f); UserInterfControl.GetPlayerData.Invoke(); if (GameObject.Find("ServisWindow") != null) { GameObject.Find("ServisWindow").GetComponent <ItemUpgrade>().OpenUpgradeWindow(); } } } else if (nameOfAction == "Compose" || nameOfAction == "Write") { string objectUid = ""; if (nameOfAction == "Compose") { foreach (Music music in PlayerClass.playerMusics.Values) { if (music.created == 0) { objectUid = music.uid; } } } if (nameOfAction == "Write") { foreach (Verse verse in PlayerClass.playerVerses.Values) { if (verse.created == 0) { objectUid = verse.uid; } } } form.AddField("uid", objectUid); UnityWebRequest www = UnityWebRequest.Post(URLs.Link("FinishCreatingMusicVerseSong"), form); yield return(www.SendWebRequest()); Debug.Log(www.downloadHandler.text); string[] answer = www.downloadHandler.text.Split('^'); if (!www.isNetworkError) { for (int i = 0; i < answer.Length; i++) { if (answer[i] == "Created finished") { if (nameOfAction == "Compose") { PlayerClass.playerMusics[objectUid].created = 1; GameStateManager.Message(Localize.LocalizeMessage("MusicCreateComplete")); } if (nameOfAction == "Write") { PlayerClass.playerVerses[objectUid].created = 1; GameStateManager.Message(Localize.LocalizeMessage("VerseCreateComplete")); } PlayerPrefs.DeleteKey(string.Format("Is{0}TimerDate", nameOfAction)); } else if (answer[i] == "Skill updated") { yield return(PlayerClass.GetPlayerData("PassiveSkills")); } } Destroy(GameObject.Find(string.Format("{0}Timer", nameOfAction)), 0.001f); StartCoroutine(GameStateManager.ClearMessage()); if (GameObject.Find("RehearsalPointWindow") != null) { GameObject.Find("RehearsalPointWindow").GetComponent <RehearsalPoint>().ResetTimeLine(nameOfAction); } } } } else { GameStateManager.Message(Localize.LocalizeMessage("ConnectionError")); yield return(GameStateManager.ClearMessage()); } }
public static IEnumerator StartAction(string nameOfAction, string playerName, string itemName, string timer) { yield return(PlayerClass.CheckConn()); if (PlayerClass.conOk) { WWWForm form = new WWWForm(); form.AddField("playername", playerName); form.AddField("itemname", itemName); UnityWebRequest www = UnityWebRequest.Post(URLs.Link("UpgradeItem"), form); yield return(www.SendWebRequest()); Debug.Log(www.downloadHandler.text); string[] answer = www.downloadHandler.text.Split('^'); if (!www.isNetworkError) { for (int i = 0; i < answer.Length; i++) { if (answer[i] == "Upgrade payed") { if (UpgradeTimer == null) { UpgradeTimer = GameObject.CreatePrimitive(PrimitiveType.Cube); } UpgradeTimer.name = string.Format("{0}Timer", nameOfAction); UpgradeTimer.AddComponent <TimerWithSpan>(); UpgradeTimer.GetComponent <TimerWithSpan>().zavTime = new int[] { int.Parse(timer.Substring(0, 2)), int.Parse(timer.Substring(5, 2)), int.Parse(timer.Substring(10, 2)) }; UpgradeTimer.GetComponent <TimerWithSpan>().targTime = new int[] { 00, 00, 00 }; UpgradeTimer.GetComponent <TimerWithSpan>().Reset = false; UpgradeTimer.GetComponent <TimerWithSpan>().zvon.AddListener(() => { FinishUpgrade.Invoke(); }); UpgradeTimer.GetComponent <TimerWithSpan>().runTimer = true; yield return(DayNightControl.GetTime()); PlayerPrefs.SetString("SelectedItemToUpgrade", itemName); PlayerPrefs.SetString("IsUpgradingTimerDate", "true" + string.Format("{0:00}{1:00}{2:00}", int.Parse(timer.Substring(0, 2)), int.Parse(timer.Substring(5, 2)), int.Parse(timer.Substring(10, 2))) + string.Format("{0,4}{1:00}{2:00}{3:00}{4:00}{5:00}", DayNightControl.timY, DayNightControl.timMo, DayNightControl.timD, DayNightControl.timH, DayNightControl.timMi, DayNightControl.timS)); PlayerPrefs.Save(); } } yield return(PlayerClass.GetPlayerData("Items")); } } else { GameStateManager.Message(Localize.LocalizeMessage("ConnectionError")); yield return(GameStateManager.ClearMessage()); } }