using UnityEngine;
using System.Collections;

public class EnemySpawner : MonoBehaviour {
    public GameObject enemy;
    public GameObject spawnParent;
    public int enemyCount = 20;
    private GameManager gameManager;

    void Start() {
        gameManager = FindObjectOfType<GameManager>();

        for (int i = 0; i < enemyCount; i++) {
            Vector3 pos = new Vector3(Random.Range(gameManager.levelStart.transform.localPosition.x + 40f, gameManager.levelEnd.transform.localPosition.x - 5f), 0, -8.85f);
            GameObject go = Instantiate(enemy);
            go.transform.parent = spawnParent.transform;
            go.transform.localPosition = pos;
        }
    }
}
