From 34d9955d2fcf232994ae6549b10e670c920b4ec9 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sat, 14 Oct 2017 11:35:41 +0200 Subject: Started on waveSpawner --- td/Assets/Scripts/waveSpawner.cs | 44 +++++++++++----------------------------- 1 file 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 -- cgit v1.2.3