void Update() { if (finishedDownloading == false) { GetProgress(); return; } float xAxis = Input.GetAxis("Horizontal") * Time.deltaTime * 1.4f; float yAxis = Input.GetAxis("UpDown") * Time.deltaTime * 1.3f; float zAxis = Input.GetAxis("Vertical") * Time.deltaTime * 1.35f; transform.position = new Vector3(Mathf.Clamp(transform.position.x + xAxis, 0f, 120f), Mathf.Clamp(transform.position.y + yAxis, 0.5f, 3f), Mathf.Clamp(transform.position.z + zAxis, -0.5f, 0.5f)); if (gameCount < gameCardBoxes.Count) { if (gameCount < Mathf.Floor((transform.position.x * 2f + 2.2f))) { gameCardBoxes[gameCount].transform.position = new Vector3(gameCount * 0.5f + UnityEngine.Random.Range(-0.02f, 0.02f), 1f, 0f); gameCardBoxes[gameCount].SetActive(true); BoxLogic boxLogic = gameCardBoxes[gameCount].GetComponent <BoxLogic>(); boxLogic.HideText(); gameCount++; } } RaycastHit rayHit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out rayHit, 10f, 1 << 8)) { lastHitBoxLogic = rayHit.transform.GetComponent <BoxLogic>(); lastHitBoxLogic.ShowText(); } else { if (lastHitBoxLogic == null) { return; } lastHitBoxLogic.HideText(); lastHitBoxLogic = null; } }
IEnumerator DownloadAndProcessApiRequest(string url) { WWW xml = new WWW(url); yield return(xml); if (xml.text == "") { yield break; } string xmlText = xml.text; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlText); XmlNode errorNode = xmlDocument.GetElementsByTagName("error")[0]; if (errorNode.InnerText != "OK") { ShowError(errorNode.InnerText, "Retrieve Error"); StopAllCoroutines(); yield break; } XmlNode resultCount = xmlDocument.GetElementsByTagName("number_of_total_results")[0]; if (resultCount.InnerText == "0") { ShowError("No results founds", "Search Error"); StopAllCoroutines(); yield break; } XmlNodeList nodes = xmlDocument.GetElementsByTagName(SettingsManager.resourceType); foreach (XmlNode node in nodes) { XmlNode firstChild = node.FirstChild; if (firstChild == null) { continue; } XmlNodeList nodeList = firstChild.ChildNodes; if (nodeList == null) { continue; } string imageURL = ""; // Keep checking for the biggest image possible to download for (int c = Mathf.Min(nodeList.Count - 1, 4); c > 0; c--) { imageURL = nodeList.Item(c).InnerText; if (imageURL != "") { break; } } if (imageURL == "") { continue; } if (imageURL.Contains(".gif")) { continue; } if (SettingsManager.resourceType == "platform") { Debug.Log(node.ChildNodes[0].InnerText); } Debug.Log("Downloading image: " + node.ChildNodes[1].InnerText); Debug.Log(imageURL); // Instantiate the gameBox now since it will prevent the blocking of any image download requests GameObject gameBox = (GameObject)Instantiate(gameCardBase, Vector3.zero, Quaternion.identity); BoxLogic boxLogic = gameBox.GetComponent <BoxLogic>(); boxLogic.SetText(node.ChildNodes[1].InnerText); boxLogic.HideText(); gameCardBoxes.Add(gameBox); imageUrlList.Add(imageURL); } apiRequestsComplete++; }