// Update is called once per frame void Update() { int numberOfSheeps = GameObject.FindGameObjectsWithTag("Sheep").Length; int sheepsInPasture = safeZoneInfo.getNumberOfSheeps(); if (numberOfSheeps - sheepsInPasture == 0) { GameObject rndSpawn = spawnPlaces[Random.Range(0, spawnPlaces.Length - 1)]; GameObject instance = (GameObject)Instantiate(Sheep, rndSpawn.transform.position, Quaternion.identity); } }
// Update is called once per frame void Update() { GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); if (safeZoneInfo.getNumberOfSheeps() > 0) { numberOfEnemies = startingEnemies + safeZoneInfo.getNumberOfSheeps(); } if (enemies.Length < numberOfEnemies) { GameObject rndSpawn = spawnPlaces[Random.Range(0, spawnPlaces.Length - 1)]; GameObject instance = (GameObject)Instantiate(Enemy, rndSpawn.transform.position, Quaternion.identity); if (safeZoneInfo.getNumberOfSheeps() > 0) { if (Random.value < safeZoneInfo.getNumberOfSheeps() / 10) { EnemyController ec = instance.GetComponent <EnemyController>(); ec.setNavMeshAgentSpeed(ec.getNavMeshAgent().speed + 5); //Hardcoded value } } } }