init
This commit is contained in:
commit
16da8e4dde
333 changed files with 109229 additions and 0 deletions
29
Assets/Scripts/Spawners/CircleEnemySpawner.cs
Normal file
29
Assets/Scripts/Spawners/CircleEnemySpawner.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CircleEnemySpawner : MonoBehaviour{
|
||||
|
||||
public string ObjectToSpawn;
|
||||
Vector2 whereToSpawn;
|
||||
GameController gameController;
|
||||
float nextSpawn;
|
||||
float spawnRate;
|
||||
|
||||
void Start(){
|
||||
gameController = FindObjectOfType<GameController>();
|
||||
spawnRate = gameController.actualCircleEnemySpawnRate;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
spawnRate = gameController.actualCircleEnemySpawnRate;
|
||||
if (Time.time > nextSpawn){
|
||||
nextSpawn = Time.time + spawnRate;
|
||||
float xPos = Random.Range(gameController.minSpawnPos.x, gameController.maxSpawnPos.x);
|
||||
float yPos = Random.Range(gameController.minSpawnPos.y, gameController.maxSpawnPos.y);
|
||||
whereToSpawn = new Vector2(xPos, yPos);
|
||||
ObjectPooler.Instance.SpawnFromPool(ObjectToSpawn, whereToSpawn, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue