// Use this for initialization void Start() { player = GameObject.FindWithTag("Player").gameObject; BGMBox.SetActive(false); mixer.SetFloat("BGM2Volume", 0); //UIたちの初期化 level = levelUI.GetComponent <Text> (); score = scoreUI.GetComponent <Text> (); resultScore = resultScoreUI.GetComponent <Text> (); highScore = highScoreUI.GetComponent <Text> (); resultUI.SetActive(false); Enums.Level = 0; Enums.Score = 0; //敵を生成 for (int i = 0; i < enemys.Length; i++) { enemys [i] = Instantiate(enemy) as GameObject; enemys [i].transform.parent = transform; enemys [i].SetActive(false); } //HP回復玉を生成 HPBall = Instantiate(healHP) as GameObject; HPBall.transform.parent = transform; HPBall.SetActive(false); StartCoroutine(isEnemy()); }
//Enemyをスポーン void Spawn() { enemyList.Clear(); levelBase = Enums.Level / phase; enemyCount = Random.Range(levelBase + 4, levelBase + 6); int t; for (int i = -1; i < enemyCount; i++) { do { t = Random.Range(0, 16); } while(enemyList.Contains(t)); enemyList.Add(t); int x = (t / 4 % 2 == 0) ? Random.Range(1, 4) : Random.Range(4, 7); int y = (t / 8 == 0) ? Random.Range(1, 4) : Random.Range(4, 7); if (t % 2 == 0) { x *= -1; } if (t % 4 < 2) { y *= -1; } if (i == -1) { if (!HPBall.activeInHierarchy) { HPBall.SetActive(true); HPBall.transform.position = new Vector3(x * 3, 0, y * 3); } else { continue; } } else { enemys [i].SetActive(true); enemys [i].transform.position = new Vector3(x * 3, 0, y * 3); } } sound_Spawn.Play(); }