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.buildingInProgress.Count != 0) { progressParrent.SetActive(true); buildsInProgress = new BuildingsInProgress(MainResourcesController.buildingInProgress[0].sysId, MainResourcesController.buildingInProgress[0].buildId, MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.timeNow, MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.buildingInProgress[0].startTimeBuild); thisBlc = blocksParrent.transform.FindChild("Building_prefab_" + buildsInProgress.buildId).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 = buildsInProgress.buildId; qC.timeToEndBuild = buildsInProgress.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 - buildsInProgress.timeToEnd / buildsInProgress.startTimeBuild; qC.TickBuild(); } else { progressParrent.SetActive(false); } yield return(new WaitForSeconds(1f)); loadingPanel.SetActive(false); scrnM.ShowCurrentPanel(); }
IEnumerator AddBuildings(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 buildingsInProgress = result["system"]["building"]; MainResourcesController.buildingListIsFull = true; if (result["error"].Value != "") { Debug.Log("Json Building Error id: " + result["error"].Value); yield break; } else { parrentQuene.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.transform.FindChild("ProgressElement(Clone)")) { Destroy(parrentQuene.transform.FindChild("ProgressElement(Clone)").gameObject); } MainResourcesController.buildingInProgress.Add(new BuildingsInProgress( buildingsInProgress["system_id"].AsInt, buildingsInProgress["building_id"].AsInt, buildingsInProgress["building_end"].AsLong, buildingsInProgress["building_start"].AsLong)); goInstQuene = Instantiate(quenePrefab); goInstQuene.transform.SetParent(parrentQuene); goInstQuene.transform.localScale = new Vector3(1, 1, 1); QueneController qC = goInstQuene.GetComponent <QueneController>(); qC.parrentBuilding = parentGOBuildings.gameObject; qC.timeToEndBuild = buildingsInProgress["building_end"].AsLong - MainResourcesController.timeNow; // _blc.timetoend qC.queneId = _blc.blockId; qC.timeToEndTxt = goInstQuene.transform.FindChild("TimeValue_text").GetComponent <Text>(); qC.progress = goInstQuene.transform.FindChild("Bg_image").GetComponent <Image>(); qC.progress.fillAmount = 1f - _blc.timeToBuild / (MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.buildingInProgress[0].startTimeBuild); qC.TickBuild(); yield break; } } else { Debug.Log(www.error); errorWindow.SetActive(true); yield break; } }