MAAC3601-TD-Game/Assets/Scripts/LevelController.cs

31 lines
880 B
C#
Raw Normal View History

2023-02-16 19:07:21 -04:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class LevelController : MonoBehaviour {
public GameObject artist;
public GameObject enemy;
public GameObject[] waypoints;
private Queue<GameObject> enemies = new();
// Start is called before the first frame update
void Start() {
spawnEnemy(enemy, waypoints[0].transform.position);
}
// Update is called once per frame
void Update() {
if (Input.GetMouseButtonDown(0)) {
Instantiate(artist, Camera.main.ScreenToWorldPoint(Input.mousePosition) + Vector3.forward, Quaternion.identity);
}
}
private void spawnEnemy(GameObject enemyIn, Vector3 position) {
var e = Instantiate(enemyIn, position, Quaternion.identity);
var ec = e.GetComponent<GenerationController>();
ec.setWaypoints(waypoints);
enemies.Enqueue(e);
}
}