diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-14 11:35:41 +0200 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-14 11:35:41 +0200 |
commit | 34d9955d2fcf232994ae6549b10e670c920b4ec9 (patch) | |
tree | d04dad854abe652fa870ac21ae2f8657e911b4a1 /td/Assets/Scripts/waveSpawner.cs | |
parent | d77cd51742cb760f5f2e8f5f3c283e311ffffe1c (diff) | |
download | TD-34d9955d2fcf232994ae6549b10e670c920b4ec9.tar.gz TD-34d9955d2fcf232994ae6549b10e670c920b4ec9.zip |
Started on waveSpawner
Diffstat (limited to 'td/Assets/Scripts/waveSpawner.cs')
-rw-r--r-- | td/Assets/Scripts/waveSpawner.cs | 44 |
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 |