// Update is called once per frame void Update() { if (tower.GetData() != null) { transform.localPosition = Camera.main.WorldToScreenPoint(tower.GetGameObject().transform.position + new Vector3(0, 12f, 0)) - new Vector3(Screen.width / 2, Screen.height / 2, 0); if (tower.GetData() is Tower) { progressBar.transform.localScale = new Vector3((float)TechTree.GetProgress(tower.GetData() as Tower) / ((tower.GetData() as Tower).GetCost()), 1f, 1f); } else { progressBar.transform.localScale = new Vector3((float)TechTree.GetProgress(tower.GetData() as Upgrade) / ((tower.GetData() as Upgrade).GetCost()), 1f, 1f); } } else { transform.position = new Vector3(-1000f, -1000f, 0f); } }
public void Act(TowerInstance t) { System.Object data = t.GetData(); if (data != null && data is Tower) { if (TechTree.GetAvailableTowers().Contains(data as Tower)) { t.SetData(null); StopParticles(t); } else { TechTree.ResearchTower(data as Tower); StartParticles(t); } } if (data != null && data is Upgrade) { if (TechTree.GetAvailableUpgrades().Contains(data as Upgrade)) { t.SetData(null); StopParticles(t); } else { TechTree.ResearchUpgrade(data as Upgrade); StartParticles(t); } } if (data == null) { StopParticles(t); } }