private void Update() { attackCoolTime -= Time.fixedDeltaTime; // 공격 if (attackCoolTime <= 0) { List <GallagEnemy> enemyScriptList = new List <GallagEnemy>(); for (int i = 0; i < enemyList.Count; i++) { GallagEnemy enemyScript = enemyList[i].GetComponent <GallagEnemy>(); if (enemyScript.curState == GallagEnemy.state.NONE) { enemyScriptList.Add(enemyScript); } } if (enemyScriptList.Count > 0) { int random = Random.Range(0, enemyScriptList.Count); enemyScriptList[random].curState = GallagEnemy.state.ATTACK; random = Random.Range(0, enemyScriptList.Count); enemyScriptList[random].curState = GallagEnemy.state.ATTACK; random = Random.Range(0, enemyScriptList.Count); enemyScriptList[random].curState = GallagEnemy.state.ATTACK; random = Random.Range(0, enemyScriptList.Count); enemyScriptList[random].curState = GallagEnemy.state.ATTACK; attackCoolTime = 3; } } }
private void OnTriggerEnter2D(Collider2D collision) { // 맵 밖으로 나간 경우. if (collision.CompareTag("Map_Bottom")) { GallagPlayer.instance.ReturnBullet(gameObject); } // 플레이어가 맞은 경우. else if (collision.CompareTag("Player")) { GallagEnemy.ReturnBullet(gameObject); } }