// Update is called once per frame void Update() { for (int i = 0; i < 11; i++) { rw = obj.list[list2[i]].GetComponent <RedWin>(); if (rw == null) { //do nothing } else { Panel.SetActive(true); Winningmessage.text = "Red Won!"; rw = null; } bw = obj.list[list1[i]].GetComponent <BlueWin>(); if (bw == null) { //do nothing } else { Panel.SetActive(true); Winningmessage.text = "Blue Won!"; bw = null; } } }
// Update is called once per frame void Update() { //check if neighbours are red and assign the red win script to them too for (int i = 0; i < obj.list.Length; i++) { //checks if neighbours are red and creates a list of those neighbours if (Vector3.Distance(this.transform.position, obj.list[i].transform.position) < 2 && (obj.list[i].GetComponent <Renderer>().material.color == Color.red) && obj.list[i].name != this.name) { if (!n.Contains(obj.list[i])) { n.Add(obj.list[i]); } } } //assigns red win script to them for (int i = 0; i < n.Count; i++) { //avoid multiple time attachement of the same script on any hex game object RedWin rw = n[i].GetComponent <RedWin>(); if (rw == null) { n[i].AddComponent(typeof(RedWin)); } else { } } }
// Update is called once per frame void Update() { //check if those hex game objects have turned red for (int i = 0; i < 11; i++) { if (gameObjectListManager.list[list1[i]].GetComponent <Renderer>().material.color == Color.red) { // this helpes in avoiding a condition in which red script gets assigned to a hex game object multiple times RedWin rw = gameObjectListManager.list[list1[i]].GetComponent <RedWin>(); if (rw == null) { //if they are red then assign red win script gameObjectListManager.list[list1[i]].AddComponent(typeof(RedWin)); } else { //do nothing } } } }