// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1) && gameObject.tag == "DemonSpawner") { type = "Demon"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } if (Input.GetKeyDown(KeyCode.Alpha2) && gameObject.tag == "SpiderSpawner") { type = "Spider"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } if (Input.GetKeyDown(KeyCode.Alpha3) && gameObject.tag == "SkeletonSpawner") { type = "Skeleton"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1) && Time.time > nextFire) { nextFire = Time.time + firerate; type = "Demon"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } if (Input.GetKeyDown(KeyCode.Alpha2) && Time.time > nextFire) { nextFire = Time.time + firerate; type = "Spider"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } if (Input.GetKeyDown(KeyCode.Alpha3) && Time.time > nextFire) { nextFire = Time.time + firerate; type = "Skeleton"; enemy = factory.CreateEnemy(type); Instantiate(enemy, gameObject.transform.position, gameObject.transform.rotation); } }