// Update is called once per frame void Update() { Population = GameObject.FindGameObjectWithTag("Pop"); BluePop = GameObject.Find("BluePop"); RedPop = GameObject.Find("RedPop"); Text r = RedPop.GetComponent <Text>(); Text b = BluePop.GetComponent <Text>(); Text t = Population.GetComponent <Text>(); t.text = GameObject.FindGameObjectsWithTag("Slime").Length.ToString(); if (currentState != null) { currentState(); } if (GameObject.FindGameObjectsWithTag("Slime").Length > 100) { SlimeAi slimeAI = GameObject.FindGameObjectWithTag("Slime").gameObject.GetComponent <SlimeAi>(); if (slimeAI != null) { slimeAI.currentState = slimeAI.Death; } } foreach (GameObject l in GameObject.FindGameObjectsWithTag("Slime")) { if (l.GetComponent <SlimeAi>().CLAN == 1) { ri++; Red.Add(l); r.text = Red.ToArray().Length.ToString(); } else if (l.GetComponent <SlimeAi>().CLAN == 2) { bi++; Blu.Add(l); b.text = Blu.ToArray().Length.ToString(); } } ri = 0; bi = 0; Blu.Clear(); Red.Clear(); if (Input.GetKey(KeyCode.Q)) { SceneManager.LoadScene("Main"); } }
private void OnCollisionEnter(Collision collision) { List <GameObject> CantFight = new List <GameObject>(); SlimeAi slimeAI = collision.gameObject.GetComponent <SlimeAi>(); if (slimeAI != null && CLAN != slimeAI.CLAN) { if (!CantFight.Contains(collision.gameObject)) { if (collision.gameObject.GetComponent <SlimeAi>().strength > strength && collision.gameObject.tag == "Slime") { currentState = Death; } else if (collision.gameObject.GetComponent <SlimeAi>().strength < strength && collision.gameObject.tag == "Slime") { collision.gameObject.GetComponent <SlimeAi>().currentState = Death; } else if (strength == collision.gameObject.GetComponent <SlimeAi>().strength) { CantFight.Add(collision.gameObject); } } } }