コード例 #1
0
ファイル: Room.cs プロジェクト: masterkrombi/DrumbeatCity
    public IEnumerator GenerateEnemies()
    {
        if (!spawnedOnce)
        {
            spawnedOnce = true;
            if (enemyDL || enemyUL || enemyUR || enemyDR)
            {
                StartCoroutine(PlayerCombat.EnterCombat());
            }


            if (enemyDL)
            {
                enemies[0] = Instantiate(enemy, spawnDL.transform.position, spawnDL.transform.rotation);
                enemies[0].GetComponent <Enemy>().SetBeat(DLBeat);
                enemies[0].GetComponent <Enemy>().thisRoom = this;
                enemies[0].GetComponentInChildren <SpriteRenderer>().color = redEnemy;
                enemies[0].GetComponentInChildren <SpriteRenderer>().flipX = true;
                enemies[0].SetActive(false);
            }

            if (enemyUL)
            {
                enemies[1] = Instantiate(enemy, spawnUL.transform.position, spawnUL.transform.rotation);
                enemies[1].GetComponent <Enemy>().SetBeat(ULBeat);
                enemies[1].GetComponent <Enemy>().thisRoom = this;
                enemies[1].GetComponentInChildren <SpriteRenderer>().color = yellowEnemy;
                enemies[1].GetComponentInChildren <SpriteRenderer>().flipX = true;
                enemies[1].SetActive(false);
            }

            if (enemyUR)
            {
                enemies[2] = Instantiate(enemy, spawnUR.transform.position, spawnUR.transform.rotation);
                enemies[2].GetComponent <Enemy>().SetBeat(URBeat);
                enemies[2].GetComponent <Enemy>().thisRoom = this;
                enemies[2].GetComponentInChildren <SpriteRenderer>().color = blueEnemy;
                enemies[2].GetComponentInChildren <SpriteRenderer>().flipX = false;
                enemies[2].SetActive(false);
            }

            if (enemyDR)
            {
                enemies[3] = Instantiate(enemy, spawnDR.transform.position, spawnDR.transform.rotation);
                enemies[3].GetComponent <Enemy>().SetBeat(DRBeat);
                enemies[3].GetComponent <Enemy>().thisRoom = this;
                enemies[3].GetComponentInChildren <SpriteRenderer>().color = greenEnemy;
                enemies[3].GetComponentInChildren <SpriteRenderer>().flipX = false;
                enemies[3].SetActive(false);
            }
            yield return(new WaitForSeconds(SongManager.instance.nextBeatTime - SongManager.instance.currentDSPTime));

            if (enemyDL)
            {
                enemies[0].SetActive(true);
            }
            if (enemyUL)
            {
                enemies[1].SetActive(true);
            }
            if (enemyUR)
            {
                enemies[2].SetActive(true);
            }
            if (enemyDR)
            {
                enemies[3].SetActive(true);
            }
        }
    }