From 9a00d03f80eee94c9fe52f832a0127d9375ad375 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 29 Sep 2017 01:12:27 +0200 Subject: Bytt ut eksempel med starten på et Tower Defence spill (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Startet på TD :) * Slett tulleprosjekt * Added enemy as a prefab * Fiksa stygge skygga * Fiksa stygge skygga på android * Tweaked design, cleanup of enemy script * Made enemy spawner, plus changed enemy color to red * Added pan and zoom (Pan is ugly still) * Veit itj ka som e endra :) --- td/Assets/Scripts/EnemySpawner.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 td/Assets/Scripts/EnemySpawner.cs (limited to 'td/Assets/Scripts/EnemySpawner.cs') diff --git a/td/Assets/Scripts/EnemySpawner.cs b/td/Assets/Scripts/EnemySpawner.cs new file mode 100644 index 0000000..eb0dd43 --- /dev/null +++ b/td/Assets/Scripts/EnemySpawner.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EnemySpawner : MonoBehaviour { + + public Enemy enemyPrefab; + public Transform pathWay; + public Transform gameWorld; + + int wave; + int next = 1; + int n = 0; + + void Update () { + n++; + + if (n == next) { + n = 0; + next = (int)Random.Range (50, 400); + + Enemy newEnemy = Instantiate (enemyPrefab, new Vector3(0, 0, 0), Quaternion.identity, gameWorld); + newEnemy.GetComponent ().pathWay = pathWay; + newEnemy.GetComponent ().speed = Random.Range (0.3f, 1.2f); + } + } +} -- cgit v1.2.3