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

32 lines
958 B
C#

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)) {
var a = Instantiate(artist, Camera.main.ScreenToWorldPoint(Input.mousePosition) + (Vector3.forward * 10), Quaternion.identity);
a.GetComponent<ArtistController>().setEnemyQueue(enemies);
}
}
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);
}
}