//waitTime is now a random Number; we can make it a propierty that changes with the game stats. public IEnumerator StartFightIE() { while (true) { GameObject npc1 = handlePeople.GetRandomNpc(); GameObject npc2 = handlePeople.GetRandomNpc(); Vector3 placeToFight = npc2.transform.position; GameObject thisCloudFight = Instantiate(cloudFigth, placeToFight - (0.12f * (placeToFight - npc1.transform.position)), Quaternion.identity); thisCloudFight.GetComponent <Fight>().AssignNpc1(npc1); thisCloudFight.GetComponent <Fight>().AssignNpc2(npc2); npc1.GetComponentInChildren <SpriteRenderer>().color = Color.red; npc2.GetComponentInChildren <SpriteRenderer>().color = Color.red; npc1.GetComponent <AutoMove>().MoveToFight(placeToFight - (0.25f * (placeToFight - npc1.transform.position))); npc2.GetComponent <AutoMove>().MoveToFight(placeToFight); if (onNewFight != null) { onNewFight(); } float waitTime = UnityEngine.Random.Range(10, 15f); yield return(new WaitForSeconds(waitTime)); } }
//waitTime is now a random Number; we can make it a propierty that changes with the game stats. public IEnumerator InstantiateVomitIE() { while (true) { GameObject npcToInstantiate = handlePeople.GetRandomNpc(); Instantiate(vomit, npcToInstantiate.transform.position, Quaternion.identity); float waitTime = Random.Range(2, 4f); yield return(new WaitForSeconds(waitTime)); } }