IEnumerator GetJson() { WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=getuser&token=" + MainResourcesController.userToken); yield return(www); result = JSON.Parse(www.text); MainResourcesController.timeNow = result["now"].AsLong; if (MainResourcesController.researchInProgress.Count != 0) { progressParrent.SetActive(true); researchInProgress = new ResearchInProgress(MainResourcesController.researchInProgress[0].userid, MainResourcesController.researchInProgress[0].techid, MainResourcesController.researchInProgress[0].timeToEnd - MainResourcesController.timeNow, MainResourcesController.researchInProgress[0].timeToEnd - MainResourcesController.researchInProgress[0].startTime); thisBlc = blocksParrent.transform.FindChild("Research_prefab_" + researchInProgress.techid).GetComponent <BlockController>(); queneName.text = thisBlc.title; queneAvatar.sprite = thisBlc.ava; goInstQuene = Instantiate(quenePrefab); goInstQuene.transform.SetParent(progressParrent.transform); goInstQuene.transform.localScale = new Vector3(1, 1, 1); QueneController qC = goInstQuene.GetComponent <QueneController>(); qC.queneId = researchInProgress.techid; qC.timeToEndBuild = researchInProgress.timeToEnd; qC.timeToEndTxt = goInstQuene.transform.FindChild("TimeValue_text").GetComponent <Text>(); qC.parrentBuilding = progressParrent; qC.progress = goInstQuene.transform.FindChild("Bg_image").GetComponent <Image>(); qC.progress.fillAmount = 1f - researchInProgress.timeToEnd / researchInProgress.startTime; qC.TickResearch(); } else { progressParrent.SetActive(false); } yield return(new WaitForSeconds(1f)); loadingPanel.SetActive(false); scrnM.ShowCurrentPanel(); }
IEnumerator AddResearch(string json_query, BlockController _blc) { WWW www = new WWW(json_query); yield return(www); if (www.error == null) { var result = JSON.Parse(www.text); JSONNode system = result["system"]; JSONNode current_user = result["user"]; JSONNode researchInProgress = current_user["tech"]; MainResourcesController.researchListIsFull = true; if (result["error"].Value != "") { Debug.Log("Json Building Error id: " + result["error"].Value); yield break; } else { parrentQuene_r.gameObject.SetActive(true); MainResourcesController.main_titan_value = system["titan"].AsDouble; MainResourcesController.main_silicone_value = system["silicon"].AsDouble; MainResourcesController.main_antimatter_value = system["antimatter"].AsDouble; MainResourcesController.energy_used = system["energy_used"].AsInt; MainResourcesController.timeNow = result["now"].AsLong; MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>(); mrc.ValOnTheirPlace(); if (parrentQuene_r.transform.FindChild("ProgressElement(Clone)")) { Destroy(parrentQuene_r.transform.FindChild("ProgressElement(Clone)").gameObject); } MainResourcesController.researchInProgress.Add(new ResearchInProgress( researchInProgress["user_id"].AsInt, researchInProgress["tech_id"].AsInt, researchInProgress["tech_end"].AsLong, researchInProgress["tech_start"].AsLong)); goInstQuene_r = Instantiate(quenePrefab_r); goInstQuene_r.transform.SetParent(parrentQuene_r); goInstQuene_r.transform.localScale = new Vector3(1, 1, 1); QueneController qC = goInstQuene_r.GetComponent <QueneController>(); qC.parrentBuilding = parentGOResearch.gameObject; qC.queneId = _blc.blockId; qC.timeToEndBuild = researchInProgress["tech_end"].AsLong - MainResourcesController.timeNow; //_blc.timetoend qC.timeToEndTxt = goInstQuene_r.transform.FindChild("TimeValue_text").GetComponent <Text>(); qC.progress = goInstQuene_r.transform.FindChild("Bg_image").GetComponent <Image>(); qC.progress.fillAmount = 1f - _blc.timeToBuild / (MainResourcesController.researchInProgress[0].timeToEnd - MainResourcesController.researchInProgress[0].startTime); qC.TickResearch(); yield break; } } else { Debug.Log(www.error); errorWindow.SetActive(true); yield break; } }