// Update is called once per frame void Update() { if (stage.getphase() == 1 && phase == 0) { phase = 1; } if (phase == 1) { if (stage.getbase() == 0) { normalhiglight(select); phase = 2; } } else if (phase == 2) { if (stage.getmoney() == 0) { normalhiglight(select); phase = 3; } } else if (phase == 3) { if (stage.getphase() == 2) { normalhiglight(select); phase = 4; } } else if (phase == 4) { if (stage.getphase() == 3) { if (phase5resource == false) { phase5resource = true; stage.increasemoney(250); } phase = 5; } } else if (phase == 5) { if (stage.getphase() == 2) { phase = 6; } } else if (phase == 6) { if (stage.getphase() == 3) { if (phase7resource == false) { phase7resource = true; phase7missile = 0; stage.increasemoney(200); GameObject[] alltower = GameObject.FindGameObjectsWithTag("tower"); foreach (var item in alltower) { if (item.name == "Missile(Clone)") { phase7missile++; } } } phase = 7; } } else if (phase == 7) { int allmissile = 0; GameObject[] alltower = GameObject.FindGameObjectsWithTag("tower"); foreach (var item in alltower) { if (item.name == "Missile(Clone)") { allmissile++; } } if (allmissile - phase7missile == 2) { normalhiglight(select); phase = 8; } } else if (phase == 8) { if (stage.getphase() == 2) { normalhiglight(select); phase = 9; } } else if (phase == 9) { if (stage.getphase() == 3) { phase = 10; } } else if (phase == 10) { GameObject[] towerbutton = GameObject.FindGameObjectsWithTag("button"); GameObject[] alltower = GameObject.FindGameObjectsWithTag("tower"); phase10tower = alltower.Length; foreach (var item in towerbutton) { if (item.name == "tower button" && item.active) { select = item.GetComponent <Button>(); phase = 11; } } } else if (phase == 11) { GameObject[] alltower = GameObject.FindGameObjectsWithTag("tower"); if (phase10tower > alltower.Length) { select = null; Highlightime = 1; phase = 12; } } else if (phase == 12) { if (custompanel.active) { normalhiglight(select); phase = 13; } } else if (phase == 13) { GameObject coreclone = GameObject.Find("core2_1(Clone)"); if (coreclone != null) { normalhiglight(select); GameObject weaponbutton = GameObject.Find("Button weapon"); select = weaponbutton.GetComponent <Button>(); higlight(select); phase = 14; } } else if (phase == 14) { if (weaponpanel.active) { normalhiglight(select); phase = 15; } } else if (phase == 15) { GameObject alpha = GameObject.Find("tower alpha"); int weaponcount = 0; foreach (GameObject item in alpha.GetComponent <tower>().Towerweapon) { if (item != null) { weaponcount++; } } if (weaponcount == alpha.GetComponent <tower>().Towerweapon.Length) { GameObject build = GameObject.Find("build"); select = build.GetComponent <Button>(); higlight(select); phase = 16; } } else if (phase == 16) { if (custompanel.active == false) { normalhiglight(select); phase = 17; if (phase17resource == false) { phase17resource = true; stage.increasemoney(300); } } } else if (phase == 17) { playsceneUI ui = GameObject.Find("Canvas").GetComponent <playsceneUI>(); if (ui.Currenttower != null) { if (ui.Currenttower.name == "tower alpha") { normalhiglight(select); phase = 18; } } } else if (phase == 18) { GameObject custom = GameObject.Find("tower alpha(Clone)"); if (custom != null) { phase = 19; } } else if (phase == 19) { if (stage.getphase() == 2) { phase = 20; } } }
private void Update() { if (currenttower != null) { if (Input.GetMouseButtonDown(0) && currenttower.tag == "base") { RaycastHit hitInfo; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow); if (Physics.Raycast(ray, out hitInfo)) { bool found = false; foreach (var item in mygrid.map) { if (item.name == hitInfo.collider.gameObject.name) { Destroy(hitInfo.collider.gameObject.GetComponent <placer>().Mybase); item.Placer.SetActive(false); item.havebase = true; item.nodebase = place(item.position); stage.decreasebase(1); found = true; } } if (found) { GameObject[] allwaypoint = GameObject.FindGameObjectsWithTag("waypoint"); foreach (var item2 in allwaypoint) { for (int i = 0; i < item2.GetComponent <waypoint>().point.Count; i++) { if (hitInfo.collider.gameObject.transform.position == item2.GetComponent <waypoint>().point[i]) { item2.GetComponent <waypoint>().stackpoint = i - 1; } } } foreach (var point in allwaypoint) { point.GetComponent <waypoint>().intothegraph(); } } } } else if (Input.GetMouseButtonDown(0) && currenttower.tag == "tower") { RaycastHit hitInfo; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitInfo)) { if (hitInfo.collider.gameObject.tag == "base") { if (hitInfo.collider.gameObject.GetComponent <mybase>().havetower == false) { Destroy(hitInfo.collider.gameObject.GetComponent <mybase>().Hovertower); hitInfo.collider.gameObject.GetComponent <mybase>().havetower = true; Vector3 tmposition = hitInfo.collider.gameObject.transform.GetChild(0).transform.position; Vector3 useposition = new Vector3(tmposition.x, tmposition.y + 2, tmposition.z); GameObject buildtower = place(useposition); buildtower.GetComponent <tower>().mybase = hitInfo.collider.gameObject; hitInfo.collider.gameObject.GetComponent <mybase>().tower = buildtower; stage.decreasemoney(constructioncost); } } } } } else if (currenttower == null) { if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitInfo)) { if (hitInfo.collider.gameObject.tag == "tower") { GameObject selectobject = hitInfo.collider.gameObject; tower selecttower = selectobject.GetComponent <tower>(); selecttower.selectcircle.SetActive(!selecttower.selectcircle.active); selecttower.towerui.SetActive(!selecttower.towerui.active); } if (hitInfo.collider.gameObject.tag == "base") { if (stage.getphase() == 1) { GameObject selectobject = hitInfo.collider.gameObject; mybase selectbase = selectobject.GetComponent <mybase>(); selectbase.ui.SetActive(!selectbase.ui.active); } } } } } }