public void SetupEnemies() { visuals = new GameObject[enemyArea.Enemies.Length]; var enemies = enemyArea.Enemies; var positions = new Transform[enemies.Length]; for (var i = 0; i < enemies.Length; i++) { var enemyObject = Instantiate(enemies[i].Prefab, transform); var t = enemyObject.transform; t.position = transform.position + new Vector3(i * widthBetweenEnemies, (i % 2) * rowHeight, 0); positions[i] = t; } enemyArea.WithUiTransforms(positions); onSetupFinished.Publish(); }
public IEnumerator Setup() { active.ForEach(Destroy); active = new GameObject[enemyArea.Enemies.Length]; var enemies = enemyArea.Enemies; var positions = new Transform[enemies.Length]; for (var i = 0; i < enemies.Length; i++) { var enemyObject = Instantiate(enemies[i].Prefab, transform); active[i] = enemyObject; var t = enemyObject.transform; t.position = transform.position + new Vector3(i * widthBetweenEnemies, (i % 2) * rowHeight, 0); positions[i] = t; } enemyArea.WithUiTransforms(positions); yield break; }