public void SetUp() { playerSpawnZone = gameObject.GetComponent <PlayerSpawnZone>(); enemySpawnZone = gameObject.GetComponent <EnemySpawnZone>(); StartCoroutine(AssignUnits()); StartCoroutine(AssignTurns()); }
/// <summary> /// 충돌체가 트리거 내부로 진입했습니다. /// </summary> /// <param name="other">자신이 아닌 충돌체 개체입니다.</param> void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("EnemySpawnZone")) { EnemySpawnZone zone = other.gameObject.GetComponent <EnemySpawnZone>(); zone.RequestDestroyEnemy(); } }
/// <summary> /// loops through the spawn request list and spawn all required enemies at a random position and adds them to the list of current /// enemies in the level /// /// enemies are also added to the turn order /// </summary> public void spawnEnemies() { enemySpawnZone = GetComponent <EnemySpawnZone>(); enemyList = new List <GameObject>(); foreach (SpawnRequest sq in enemySpawnRequestList) { for (int i = 0; i < sq.amount; i++) { try { enemyList.Add(Instantiate(sq.spawnObject, enemySpawnZone.getRandomPos(), Quaternion.identity, transform)); } catch (System.NullReferenceException _) { enemySpawnZone = GetComponent <EnemySpawnZone>(); enemyList.Add(Instantiate(sq.spawnObject, enemySpawnZone.getRandomPos(), Quaternion.identity, transform)); } } } addEnemiesToTurnOrder(); }