//Spawn 3 smaller Group minions when one dies private IEnumerator SpawnGrouplings() { InheritedBehaviour parentBehaviour = new InheritedBehaviour(this.transform.position + new Vector3(0.4f, 0, 0), this.destination, this.attackOrientation, this.endZone); GameManager.Instance.SpawnEnemy("Groupling Enemy", "", parentBehaviour); parentBehaviour.SpawnPoint = this.transform.position + new Vector3(0.4f, 0.4f, 0); GameManager.Instance.SpawnEnemy("Groupling Enemy", "", parentBehaviour); parentBehaviour.SpawnPoint = this.transform.position + new Vector3(0.4f, 0.4f, 0.4f); GameManager.Instance.SpawnEnemy("Groupling Enemy", "", parentBehaviour); yield return(null); }
public void SpawnEnemy(string enemyType, string position, InheritedBehaviour parentBehaviour = null) { GameObject enemyObject = Pool.GetObject(enemyType); string orientation, endZone; GameObject spawnPos; GameObject endPos; switch (position) { case "top": spawnPos = TopStartZone; endPos = TopEndZone; orientation = "vertical"; endZone = "bottom"; break; case "bottom": spawnPos = BottomStartZone; endPos = BottomEndZone; orientation = "vertical"; endZone = "top"; break; case "right": spawnPos = RightStartZone; endPos = RightEndZone; orientation = "horizontal"; endZone = "left"; break; case "left": spawnPos = LeftStartZone; endPos = LeftEndZone; orientation = "horizontal"; endZone = "right"; break; default: spawnPos = null; endPos = null; orientation = ""; endZone = ""; break; } //Initialize minion behaviour from parent (Group minion behaviour inherited by Groupling) if (parentBehaviour != null) { enemyObject.transform.position = parentBehaviour.SpawnPoint; enemyObject.GetComponent <EnemyAI>().SetDestination(parentBehaviour.Destination); enemyObject.GetComponent <EnemyAI>().SetAttackOrientation(parentBehaviour.Orientation); enemyObject.GetComponent <EnemyAI>().SetEndZone(parentBehaviour.EndZone); } //Initialize minion behaviour when spawned at spawnpoint else { enemyObject.transform.position = spawnPos.transform.position; enemyObject.GetComponent <EnemyAI>().SetDestination(endPos.transform.position); enemyObject.GetComponent <EnemyAI>().SetAttackOrientation(orientation); enemyObject.GetComponent <EnemyAI>().SetEndZone(endZone); } enemyObject.GetComponent <EnemyAI>().onDeath += Pool.ReturnGameObject; enemyObject.GetComponent <EnemyAI>().onDeath += SessionData.IncrementMinion; }