aboutsummaryrefslogtreecommitdiff
path: root/td/Assets/Scripts/EnemySpawner.cs
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2017-10-14 22:07:19 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2017-10-14 22:07:19 +0200
commitfae01da58dbea66af402807d7409fa53602f71fa (patch)
treed36ddc2874f4e9fa2e08d778731301591b4cf6ee /td/Assets/Scripts/EnemySpawner.cs
parent34d9955d2fcf232994ae6549b10e670c920b4ec9 (diff)
downloadTD-fae01da58dbea66af402807d7409fa53602f71fa.tar.gz
TD-fae01da58dbea66af402807d7409fa53602f71fa.zip
Finished wavesystem. Should improve graph for how many enemies should spawn each time
Diffstat (limited to 'td/Assets/Scripts/EnemySpawner.cs')
-rw-r--r--td/Assets/Scripts/EnemySpawner.cs49
1 files changed, 0 insertions, 49 deletions
diff --git a/td/Assets/Scripts/EnemySpawner.cs b/td/Assets/Scripts/EnemySpawner.cs
deleted file mode 100644
index a1a6b1f..0000000
--- a/td/Assets/Scripts/EnemySpawner.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class EnemySpawner : MonoBehaviour {
- /* This is a class that spawns an enemy with a random interval
- * it is not very good, but is what it needs to be for testing purposes */
- // TODO Add wave system with increasing difficulty
- public Enemy EnemyPrefab;
- public Transform PathWay;
- [Header("Scripting vars")]
- public Player Player; // Reference to the player object, should be set in designer
-
- private Transform _parentObject;
-
- private List<Vector3> _waypoints = new List<Vector3>();
- private int _next = 1;
- private int _n = 0;
-
- void Awake() {
- foreach (Transform child in PathWay) {
- _waypoints.Add (child.position);
- }
- }
-
- void Start() {
- _parentObject = transform.Find ("enemies").gameObject.GetComponent <Transform> ();
- }
-
- void Update () {
- if (Player.GameIsPaused()) { return; } // This ensures that the game stays paused
- _n++;
-
- if (_n == _next) {
- _n = 0;
- _next = (int)Random.Range (50, 400);
-
- Enemy newEnemy = Instantiate (EnemyPrefab, new Vector3(0, 0, 0), Quaternion.identity, _parentObject);
- Enemy script = newEnemy.GetComponent <Enemy> ();
- Transform transform = newEnemy.GetComponent <Transform>();
-
- script.Waypoints = _waypoints;
- script.Speed = Random.Range (0.3f, 1.2f);
- script.Player = Player;
- transform.position = new Vector3 (0.93f, 0.483f, 0f);
- }
-
- }
-}