Game Development Reference
In-Depth Information
//Spawn enemies in over time
for (int i = 0; i < enemyCount; i++)
{
var newEnemy = (GameObject)Instantiate(EnemyPrefabs[0]);
newEnemy.transform.position = new Vector3(10, -1, 0);
yield return StartCoroutine(
MoveCharacterToPoint(EnemySpawnPoints[i], newEnemy));
newEnemy.transform.parent =
EnemySpawnPoints[i].transform;
var controller =
newEnemy.GetComponent<EnemyController>();
controller.BattleManager = this;
var EnemyProfile =
ScriptableObject.CreateInstance<Enemy>();
EnemyProfile.Class = EnemyClass.Goblin;
EnemyProfile.Level = 1;
EnemyProfile.Damage = 1;
EnemyProfile.Health = 2;
EnemyProfile.Name = EnemyProfile.Class + " " +
i.ToString();
controller.EnemyProfile = EnemyProfile;
}
BattleStateManager.SetBool("BattleReady", true);
}
Now, as we loop through the number of enemies being added to the battle, we grab the
EnemyController class attached to the Goblin prefab, create a new EnemyProfile
class, give it some values, and finally initialize the controller with the new EnemyPro-
file class.
Ideally, you should change this generation to something that is a bit more structured in-
stead of just initializing it this way, but you should get the picture.
Now that we have a stronger opponent, let's select it and start with the attack.
Search WWH ::




Custom Search