diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-07 22:57:48 +0200 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-07 22:57:48 +0200 |
commit | 09c0b2eed74a77010ba686061b147c9cace88ed6 (patch) | |
tree | 9b5c013fc7a679ccca3e2074773d29d7f1674bbc /td/Assets/Scripts/waveSpawner.cs | |
parent | 69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0 (diff) | |
download | TD-09c0b2eed74a77010ba686061b147c9cace88ed6.tar.gz TD-09c0b2eed74a77010ba686061b147c9cace88ed6.zip |
Trur æ la te VCS, ikke meninga, men æ trur itj de e nå problem egt
Diffstat (limited to 'td/Assets/Scripts/waveSpawner.cs')
-rw-r--r-- | td/Assets/Scripts/waveSpawner.cs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/td/Assets/Scripts/waveSpawner.cs b/td/Assets/Scripts/waveSpawner.cs index c3fada3..f79fb90 100644 --- a/td/Assets/Scripts/waveSpawner.cs +++ b/td/Assets/Scripts/waveSpawner.cs @@ -3,21 +3,21 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -public class waveSpawner : MonoBehaviour { +public class WaveSpawner : MonoBehaviour { public static int EnemiesAlive = 0; - public Wave[] waves; + public Wave[] Waves; - public Transform spawnPoint; + public Transform SpawnPoint; - public float timeBetweenWaves = 5f; - private float countdown = 2f; + public float TimeBetweenWaves = 5f; + private float _countdown = 2f; - public Text waveCountdownText; + public Text WaveCountdownText; - private int waveIndex = 0; + private int _waveIndex = 0; void Update () { @@ -26,51 +26,51 @@ public class waveSpawner : MonoBehaviour { return; } - if (waveIndex == waves.Length) + if (_waveIndex == Waves.Length) { // WIN LEVEL!!! this.enabled = false; } - if (countdown <= 0f) + if (_countdown <= 0f) { StartCoroutine(SpawnWave()); - countdown = timeBetweenWaves; + _countdown = TimeBetweenWaves; return; } - countdown -= Time.deltaTime; + _countdown -= Time.deltaTime; - countdown = Mathf.Clamp(countdown, 0f, Mathf.Infinity); + _countdown = Mathf.Clamp(_countdown, 0f, Mathf.Infinity); //waveCountdownText.text = string.Format("{0:00.00}", countdown); } IEnumerator SpawnWave () { - Wave wave = waves[waveIndex]; + Wave wave = Waves[_waveIndex]; - EnemiesAlive = wave.count; + EnemiesAlive = wave.Count; - for (int i = 0; i < wave.count; i++) + for (int i = 0; i < wave.Count; i++) { - SpawnEnemy(wave.enemy); - yield return new WaitForSeconds(1f / wave.rate); + SpawnEnemy(wave.Enemy); + yield return new WaitForSeconds(1f / wave.Rate); } - waveIndex++; + _waveIndex++; } void SpawnEnemy (GameObject enemy) { - Instantiate(enemy, spawnPoint.position, spawnPoint.rotation); + Instantiate(enemy, SpawnPoint.position, SpawnPoint.rotation); } } [System.Serializable] public class Wave { - public GameObject enemy; - public int count; - public float rate; + public GameObject Enemy; + public int Count; + public float Rate; }
\ No newline at end of file |