you really gotta calm down, marisa...
This commit is contained in:
parent
13bb58ea03
commit
b9fb490dce
68 changed files with 990 additions and 44 deletions
31
Assets/Scripts/Entities/EnemySpawner.cs
Normal file
31
Assets/Scripts/Entities/EnemySpawner.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EnemySpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Marisa player;
|
||||
public Enemy[] enemiesToSpawn;
|
||||
public List<Transform> spawnPoints;
|
||||
public float spawnRate;
|
||||
[SerializeField] private float currentSpawnTime;
|
||||
[SerializeField] private Transform enemyFolder;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
currentSpawnTime -= Time.deltaTime;
|
||||
if (currentSpawnTime < 0)
|
||||
{
|
||||
currentSpawnTime = spawnRate;
|
||||
SpawnEnemy(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], spawnPoints[Random.Range(0, spawnPoints.Count)].position);
|
||||
}
|
||||
}
|
||||
|
||||
public void SpawnEnemy(Enemy enemy, Vector3 location)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, location, Quaternion.identity);
|
||||
newEnemy.transform.SetParent(enemyFolder);
|
||||
newEnemy.closestTarget = player; //idk if there's actually gonna be any other target lol
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue