private IEnumerator SpawnHazard() { int asteroidCount = AsteroidSpawnCount; int enemyCount = EnemySpawnCount; int rand; while (true) { while (asteroidCount > 0 && enemyCount > 0) { rand = Random.Range(0, 100); Debug.Log(rand); if (rand < 65) // Asteroid { asteroidCount--; AsteroidMovement asteroid = asteroidPool.GetFromPool(Random.Range(0, 3)); asteroid.transform.position = new Vector3(Random.Range(SpawnPosXMin, SpawnPosXMax), 0, SpawnPosZ); } else // enemy { enemyCount--; EnemyController enemy = enemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(SpawnPosXMin, SpawnPosXMax), 0, SpawnPosZ); } yield return(new WaitForSeconds(SpawnTime)); } if (asteroidCount > 0) { for (int i = 0; i < asteroidCount; i++) { AsteroidMovement asteroid = asteroidPool.GetFromPool(Random.Range(0, 3)); asteroid.transform.position = new Vector3(Random.Range(SpawnPosXMin, SpawnPosXMax), 0, SpawnPosZ); yield return(new WaitForSeconds(SpawnTime)); } } else { for (int i = 0; i < enemyCount; i++) { EnemyController enemy = enemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(SpawnPosXMin, SpawnPosXMax), 0, SpawnPosZ); yield return(new WaitForSeconds(SpawnTime)); } } yield return(new WaitForSeconds(5)); asteroidCount = AsteroidSpawnCount; enemyCount = EnemySpawnCount; } }
private IEnumerator SpawnHazard() { WaitForSeconds PiointThree = new WaitForSeconds(0.3f); WaitForSeconds spawnRate = new WaitForSeconds(mSpawnRate); int enemyCount = 3; int astCount = 5; int CurrentEnemyCount; int CurrentAstCount; float ratio = 1f / 3; while (true) { CurrentAstCount = astCount; CurrentEnemyCount = enemyCount; while (CurrentAstCount > 0 && CurrentEnemyCount > 0) { float rand = Random.Range(0, 1f); // float rand = Random.value(0, 1f); if (rand < ratio) { Enemy enemy = mEemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); CurrentEnemyCount--; yield return(PiointThree); } else { AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); CurrentAstCount--; yield return(PiointThree); } } for (int i = 0; i < CurrentAstCount; i++) { AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); yield return(PiointThree); } for (int i = 0; i < CurrentEnemyCount; i++) { Enemy enemy = mEemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); yield return(PiointThree); } yield return(spawnRate); } }
private void SpawnAteroid() { AsteroidMovement temp = Asteroidp.GetFromPool(Random.Range(0, 3)); temp.transform.position = new Vector3(Random.Range(-5f, 5f), 0, 16); temp.gameObject.SetActive(true); }
private IEnumerator Hazards(float startTime, float stageGap) { WaitForSeconds gap = new WaitForSeconds(stageGap); WaitForSeconds spawnGap = new WaitForSeconds(.2f); yield return(new WaitForSeconds(startTime)); while (true) { int randInt = Random.Range(5, 11); int randEnem = Random.Range(3, 6); while (randInt > 0 || randEnem > 0) { if (randInt > 0 && randEnem > 0) { int val = Random.Range(0, 2); if (val == 0) { //GameObject temp = Instantiate(Asteroid[Random.Range(0, Asteroid.Length)]); AsteroidMovement temp = AsteroidP.GetFromPool(Random.Range(0, 3)); temp.gameObject.SetActive(true); float randPosX = Random.Range(-5f, 5f); temp.transform.position = new Vector3(randPosX, temp.transform.position.y, 16.5f); randInt--; } else { //GameObject temp = Instantiate(Enemy); EnemyController temp = EnemyP.GetFromPool(); temp.gameObject.SetActive(true); float randPosX = Random.Range(-5f, 5f); temp.transform.position = new Vector3(randPosX, temp.transform.position.y, 16.5f); randEnem--; } } else if (randInt <= 0) { EnemyController temp = EnemyP.GetFromPool(); temp.gameObject.SetActive(true); float randPosX = Random.Range(-5f, 5f); temp.transform.position = new Vector3(randPosX, temp.transform.position.y, 16.5f); randEnem--; } else if (randEnem <= 0) { //GameObject temp = Instantiate(Asteroid[Random.Range(0, Asteroid.Length)]); AsteroidMovement temp = AsteroidP.GetFromPool(Random.Range(0, 3)); temp.gameObject.SetActive(true); float randPosX = Random.Range(-5f, 5f); temp.transform.position = new Vector3(randPosX, temp.transform.position.y, 16.5f); randInt--; } yield return(spawnGap); } CurrentBossSpawnCount--; yield return(gap); if (CurrentBossSpawnCount <= 0) { BossController boss = BossP.GetFromPool(); boss.transform.position = new Vector3(0, boss.transform.position.y, 18.5f); boss.gameObject.SetActive(true); IsBossAlive = true; } while (IsBossAlive) { yield return(gap); } } }
private IEnumerator SpawnHazard() { int currentAstCount = AstSpawnCount; int currentEnemyCount = EnemySpawnCount; yield return(new WaitForSeconds(3)); while (true) { if (currentAstCount > 0 && currentEnemyCount > 0) { float randVal = Random.Range(0, 100f); if (randVal < 30) // enemy spawn { EnemyController enemy = enemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(SpawnXMin, SpawnXMax), 0, SpawnZPos); yield return(new WaitForSeconds(.4f)); currentEnemyCount--; } else // asteroid spawn { AsteroidMovement ast = asteroidPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(SpawnXMin, SpawnXMax), 0, SpawnZPos); yield return(new WaitForSeconds(.4f)); currentAstCount--; } } else if (currentAstCount > 0) { for (int i = 0; i < currentAstCount; i++) { AsteroidMovement ast = asteroidPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(SpawnXMin, SpawnXMax), 0, SpawnZPos); yield return(new WaitForSeconds(.4f)); } currentAstCount = 0; } else if (currentEnemyCount > 0) { for (int i = 0; i < currentEnemyCount; i++) { EnemyController enemy = enemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(SpawnXMin, SpawnXMax), 0, SpawnZPos); yield return(new WaitForSeconds(.4f)); } currentEnemyCount = 0; } else { mbBossAlive = true; boss.gameObject.SetActive(true); while (mbBossAlive) { yield return(new WaitForSeconds(0.5f)); } currentAstCount = AstSpawnCount; currentEnemyCount = EnemySpawnCount; yield return(new WaitForSeconds(3)); } } }
private IEnumerator SpawnHazard() { WaitForSeconds pointFive = new WaitForSeconds(.5f); WaitForSeconds period = new WaitForSeconds(mPeriod); int currentAST, currentEnemy; float AstRate; while (true) { yield return(period); currentAST = mASTSpawnCount + mRoundCount * (mRoundCount + 1) / 2; currentEnemy = mEnemySpawnCount + mRoundCount / 2; AstRate = (float)currentAST / (currentAST + currentEnemy); while (currentAST > 0 && currentEnemy > 0) { float rate = Random.Range(0, 1f); if (rate < AstRate) //운석 생성 { Asteroid ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16); currentAST--; } else // 적생성 { Enemy enemy = mEnemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16); currentEnemy--; } yield return(pointFive); } for (int i = 0; i < currentAST; i++) { Asteroid ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16); yield return(pointFive); } for (int i = 0; i < currentEnemy; i++) { Enemy enemy = mEnemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16); yield return(pointFive); } mRoundCount++; Item item = mItemPool.GetFromPool(Random.Range(2, 3)); item.transform.position = new Vector3(Random.Range(-5.5f, 5.5f), 0, 16); if (mRoundCount % 5 == 0) { mBoss.transform.position = new Vector3(0, 0, 20); mBoss.gameObject.SetActive(true); //StopCoroutine(mHazardRoutine); while (mBoss.IsAlive) { yield return(pointFive); } } } }
private IEnumerator SpawnHazard() { WaitForSeconds PointThree = new WaitForSeconds(0.3f); WaitForSeconds spawnRate = new WaitForSeconds(mSpawnRate); int enemyCount = 3; int astCount = 5; int CurrentEnemyCount; int CurrentAstCount; int CurrentItemWaveCount = 0; float ratio = 1f / 3; while (true) { CurrentAstCount = astCount; CurrentEnemyCount = enemyCount; while (CurrentAstCount > 0 && CurrentEnemyCount > 0) { float rand = Random.Range(0, 1f); // float rand = Random.value(0, 1f); if (rand < ratio) { Enemy enemy = mEemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); CurrentEnemyCount--; yield return(PointThree); } else { AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); CurrentAstCount--; yield return(PointThree); } } for (int i = 0; i < CurrentAstCount; i++) { AsteroidMovement ast = mAstPool.GetFromPool(Random.Range(0, 3)); ast.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); yield return(PointThree); } for (int i = 0; i < CurrentEnemyCount; i++) { Enemy enemy = mEemyPool.GetFromPool(); enemy.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); yield return(PointThree); } if (CurrentItemWaveCount >= mItemSpawnWaveCount - 1) { Item tem = mItemPool.GetFromPool(Random.Range(0, 3)); tem.transform.position = new Vector3(Random.Range(mSpawnXMin, mSpawnXMax), 0, mSpawnZ); CurrentItemWaveCount = 0; } else { CurrentItemWaveCount++; } yield return(spawnRate); mBossAppear++; if (mBossAppear >= mSpawnCount) { mBoss.gameObject.SetActive(true); while (mBoss.IsAlive) { yield return(PointThree); } mBossAppear = 0; yield return(spawnRate); } } }