From 09c0b2eed74a77010ba686061b147c9cace88ed6 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sat, 7 Oct 2017 22:57:48 +0200 Subject: Trur æ la te VCS, ikke meninga, men æ trur itj de e nå problem egt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- td/Assets/Scripts/waveSpawner.cs | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'td/Assets/Scripts/waveSpawner.cs') 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 -- cgit v1.2.3