IEnumerator RespawnEnemy(SpawnResultBush sr) { float r = UnityEngine.Random.Range(4f, 8f); yield return new WaitForSeconds(r); int r1 = UnityEngine.Random.Range(1, 4); switch (r1) { case 1: sr.source.typeOfStatDrop = TypeOfStatIncrease.HP; break; case 2: sr.source.typeOfStatDrop = TypeOfStatIncrease.ATK; break; case 3: sr.source.typeOfStatDrop = TypeOfStatIncrease.DEF; break; default: sr.source.typeOfStatDrop = TypeOfStatIncrease.HP; break; } float y = sr.source.spawnLocation.position.y; ScaleToYaxis(y, sr.source); SpawnResultBush result = new SpawnResultBush(); var bush = CreateBush(sr.source.prefab, sr.source.spawnLocation.position, HP_Median, Atk_Median, Def_Median, sr.source.amountOfStatToGive, sr.source.typeOfStatDrop); bush.Spawner = this; result.enemy = bush; result.source = sr.source; spawnResults[spawnResults.IndexOf(sr) >= 0 ? spawnResults.IndexOf(sr) : 0] = result; }
IEnumerator SpawnBushesNow() { foreach (SpawnAreaBush area in spawnAreas) { for (int i = 0; i < area.row*2; i+=2) { for (int j = 0; j < area.col*2; j+=2) { int r = UnityEngine.Random.Range(1, 4); switch (r) { case 1: area.typeOfStatDrop = TypeOfStatIncrease.HP; break; case 2: area.typeOfStatDrop = TypeOfStatIncrease.ATK; break; case 3: area.typeOfStatDrop = TypeOfStatIncrease.DEF; break; default: area.typeOfStatDrop = TypeOfStatIncrease.HP; break; } float y = area.spawnLocation.position.y; ScaleToYaxis(y, area); SpawnAreaBush tempBush = new SpawnAreaBush(); if (y < 20f) tempBush = ScaleEnemyToWeaponType(1, area); else if (y > 20f && y < 80f) // moderate tempBush = ScaleEnemyToWeaponType(2, area); else if (y > 80f && y < 170f) // hard tempBush = ScaleEnemyToWeaponType(3, area); else if (y > 170f) tempBush = ScaleEnemyToWeaponType(4, area); SpawnResultBush result = new SpawnResultBush(); Vector3 tempPos = area.spawnLocation.position + new Vector3(i, j, 0f); var bush = CreateBush(area.prefab, tempPos, HP_Median, Atk_Median, Def_Median, tempBush.amountOfStatToGive, area.typeOfStatDrop); if (firstBush) firstBush = false; //SpawnAreaBush sab = new SpawnAreaBush(); //sab = area; //sab.spawnLocation.position = tempPos; bush.Spawner = this; result.enemy = bush; result.source = area; // reference this area values for respawning spawnResults.Add(result); // add enemy to the list of spawned enemies } } yield return null; } }
IEnumerator SpawnBushesNow() { //foreach (SpawnAreaBush area in spawnAreas) //{ Vector3 startingPos = spawnAreas[0].spawnLocation.position; for (int u = 0; u < spawnAreas.Count; u++) { for (int i = 0; i < spawnAreas[u].row*2; i+=2) { for (int j = 0; j < spawnAreas[u].col*2; j+=2) { int r = UnityEngine.Random.Range(1, 4); switch (r) { case 1: spawnAreas[u].typeOfStatDrop = TypeOfStatIncrease.HP; break; case 2: spawnAreas[u].typeOfStatDrop = TypeOfStatIncrease.ATK; break; case 3: spawnAreas[u].typeOfStatDrop = TypeOfStatIncrease.DEF; break; default: spawnAreas[u].typeOfStatDrop = TypeOfStatIncrease.HP; break; } float y = spawnAreas[u].spawnLocation.position.y; //ScaleToYaxis(y, spawnAreas[u]); SpawnAreaBush tempBush = new SpawnAreaBush(); if (y < 20f) tempBush = ScaleEnemyToWeaponType(1, spawnAreas[u]); else if (y > 20f && y < 80f) // moderate tempBush = ScaleEnemyToWeaponType(1.25f, spawnAreas[u]); else if (y > 80f && y < 170f) // hard tempBush = ScaleEnemyToWeaponType(1.75f, spawnAreas[u]); else if (y > 170f) tempBush = ScaleEnemyToWeaponType(2.5f, spawnAreas[u]); SpawnResultBush result = new SpawnResultBush(); Vector3 tempPos = startingPos + new Vector3(i, j, 0f); var bush = CreateBush(spawnAreas[u].prefab, tempPos, HP_Median, Atk_Median, Def_Median, tempBush.amountOfStatToGive, spawnAreas[u].typeOfStatDrop); if (firstBush) firstBush = false; spawnAreas[u].spawnLocation.position = tempPos; bush.Spawner = this; result.enemy = bush; result.source = spawnAreas[u]; // reference this area values for respawning spawnResults.Add(result); // add enemy to the list of spawned enemies } } yield return null; } }