} //end f'n void SpawnEnemiesAtPosition(Vector3, GameObject, int) /**A function to spawn the given enemy [prefab] at the given position; if there are more */ public void SpawnEnemiesAtPosition(Spawner enemy_spawner, Vector3 position, EnemyName enemy_name, int number_of_enemies) { // Debug.Log ("Do we make it this far, at least? Enemy name: " + enemy_name.ToString()); if (this.m_EnemyContainer == null) { this.m_EnemyContainer = new GameObject(); this.m_EnemyContainer.name = enemy_name.ToString() + "Container"; } //For consistency, though the empty's position really doesn't matter. this.m_EnemyContainer.transform.position = position; //for however many enemies are needed... for (int index = 0; index < number_of_enemies; index++) { //Spawn the enemy // GameObject enemy_obj = GameObject.Instantiate(prefab, this.m_EnemyContainer.transform); GameObject enemy_obj = enemy_spawner.SpawnEnemy(enemy_name, this.m_EnemyContainer.transform); //Position the enemy enemy_obj.transform.position = position; // this.m_EnemyContainer.transform.enemy_obj //Adjust position with respect to number of enemies //? //Then extract the Enemy component and store it in the target list, to be checked later DefaultEnemy enemy = enemy_obj.GetComponent <DefaultEnemy>(); //if the enemy component isn't in the object, it's in one of the children if (enemy == null) { enemy = enemy_obj.GetComponentInChildren <DefaultEnemy> (); enemy.m_Spawner = this.m_EnemyLootSpawner; } this.m_Targets.Add(enemy); } //end for } //end f'n void SpawnEnemiesAtPosition(Spawner, Vector3, EnemyName, int)
/// <summary> /// Loads scene- and gameObject-related information /// </summary> /// <param name="battleID">0+</param> /// <param name="nameSuffix">used when there are multiple enemies of the same kind</param> /// <param name="obj">gameObject referenced by this class</param> /// <param name="pos">original placement in the scene</param> /// <param name="boss">whether or not this enemy is the boss</param> public void LoadObjs(int battleID, int nameSuffix, GameObject obj, Vector2 pos, bool boss) { this.battleID = battleID; // create the display name by adding a suffix NameNumber = nameSuffix; string idAddendum = ""; if (NameNumber > 0) { idAddendum = " " + NameNumber; } fullName = (enemyName.ToString() + idAddendum).Replace("_", " "); gameObject = obj; position = pos; obj.transform.position = position; isBoss = boss; }