public void FetchTechnology() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; string realName = transform.Find("TechName").GetComponent <Text>().text; string techName = thisTechButton.name; Technology tech = State.GetTechnologies()[techName]; TechName.text = realName; HiddenName.text = tech.GetTechName(); TechPrestige.text = "Prestige: " + tech.GetPrestige().ToString(); Payment.text = "Payment: " + tech.GetPayment().ToString(); TechCost.text = "Cost: " + tech.GetCost().ToString(); if (tech.GetDiscovered()) { Nation discoverer = State.getNations()[tech.GetDiscoveredBy()]; DiscoveredBy.text = discoverer.getName(); } else { DiscoveredBy.text = "None"; } string description = tech.GetDescription()[0] + Environment.NewLine + tech.GetDescription()[1] + Environment.NewLine + "Requirements: " + Environment.NewLine; foreach (string item in tech.GetPreRequisites()) { description = description + item + ","; } description = description + Environment.NewLine; description = description.Remove(description.Length - 1); techDescriptionText.text = description; TechImage.sprite = Resources.Load <Sprite>("TechImages/" + techName); if (PlayerCalculator.hasTechPreRequisites(player, techName) && PlayerCalculator.canAffordTech(player, techName)) { ResearchButton.interactable = true; // PressToResearch.text = "Press to \n Research"; } else if (player.GetTechnologies().Contains(techName)) { ResearchButton.interactable = false; // PressToResearch.text = "Already \n researched"; } else { Debug.Log("Cannot be researched"); ResearchButton.interactable = false; // PressToResearch.text = "Cannot \n research"; } }
public void updateTechnologyTree() { App app = UnityEngine.Object.FindObjectOfType <App>(); Nation player = State.getNations()[app.GetHumanIndex()]; float researchPoints = player.Research; Debug.Log(techTreeConnector.name); // string realName = transform.Find("TechName").GetComponent<Text>().text; foreach (Transform tech in techTreeConnector.transform) { // string name = tech.transform.Find("TechName").GetComponent<Text>().text; string name = tech.name; Debug.Log(tech.name); if (name == "LineContainer") { continue; } Text tname = tech.transform.GetChild(0).GetComponentInChildren <Text>(); Text tcost = tech.transform.GetChild(1).GetComponentInChildren <Text>(); Debug.Log(name); Technology thisTech = State.GetTechnologies()[name]; Debug.Log(thisTech.GetTechName()); string techName = thisTech.GetTechName(); techName = techName.Replace('_', ' '); // tname.text = techName; tcost.text = thisTech.GetCost().ToString(); //Technology currentTech = State.technologies[name]; if (player.GetTechnologies().Contains(name)) { Image techImage = tech.GetComponent <Image>(); techImage.sprite = Resources.Load("AlchemistUITools/SteamContent/Sprites/Buttons/QuadroBtnBg", typeof(Sprite)) as Sprite; } //string cost = tech.transform.Find("TechCost").GetComponent<Text>().text; } }
public static void PayForTechnology(Nation player, string techName) { Technology tech = State.GetTechnologies()[techName]; player.Research = player.Research - tech.GetCost(); }