aboutsummaryrefslogtreecommitdiff
path: root/td/Assets
diff options
context:
space:
mode:
Diffstat (limited to 'td/Assets')
-rw-r--r--td/Assets/Scripts/waveSpawner.cs44
1 files changed, 12 insertions, 32 deletions
diff --git a/td/Assets/Scripts/waveSpawner.cs b/td/Assets/Scripts/waveSpawner.cs
index 1d361ef..73c0bc3 100644
--- a/td/Assets/Scripts/waveSpawner.cs
+++ b/td/Assets/Scripts/waveSpawner.cs
@@ -1,53 +1,40 @@
using System.Collections;
+using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WaveSpawner : MonoBehaviour {
-
- public static int EnemiesAlive = 0;
-
- public Wave[] Waves;
-
+
public Transform SpawnPoint;
-
- public float TimeBetweenWaves = 5f;
- private float _countdown = 2f;
-
public Text WaveCountdownText;
+ public float TimeBetweenWaves = 5f;
+ [Header("Scripting vars")]
+ public Player Player; // Reference to the player object, should be set in designer
-
+ public static int EnemiesAlive = 0;
+ private float _countdown = 2f;
private int _waveIndex = 0;
- void Update ()
- {
+ void Update () {
if (EnemiesAlive > 0) {
return;
}
- if (_waveIndex == Waves.Length)
- {
- // WIN LEVEL!!!
- this.enabled = false;
- }
-
- if (_countdown <= 0f)
- {
+ if (_countdown <= 0f) {
StartCoroutine(SpawnWave());
_countdown = TimeBetweenWaves;
return;
}
_countdown -= Time.deltaTime;
-
_countdown = Mathf.Clamp(_countdown, 0f, Mathf.Infinity);
-
//waveCountdownText.text = string.Format("{0:00.00}", countdown);
}
- IEnumerator SpawnWave ()
- {
- Wave wave = Waves[_waveIndex];
+ IEnumerator SpawnWave () {
+ int waveNum = 1;
+ int gdshj = Mathf.FloorToInt(10.64 * (Math.Pow(Math.E, (0.57 * waveNum)))));
EnemiesAlive = wave.Count;
@@ -65,11 +52,4 @@ public class WaveSpawner : MonoBehaviour {
Instantiate(enemy, SpawnPoint.position, SpawnPoint.rotation);
}
-}
-
-[System.Serializable]
-public class Wave {
- public GameObject Enemy;
- public int Count;
- public float Rate;
} \ No newline at end of file