more enemy stuff

This commit is contained in:
myondev 2026-02-26 07:48:50 -08:00
parent 3b60583c76
commit d8c49317a3
235 changed files with 27781 additions and 3909 deletions

View file

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class EnemySpawner : MonoBehaviour
{
#region Statication
public static EnemySpawner instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
}
#endregion
[Header("Enemies")]
public bool canSpawn = true;
public Enemy[] enemiesToSpawn;
public List<Transform> spawnPoints;
public float spawnRate;
[SerializeField] private float currentSpawnTime;
[Header("Boss")]
public Enemy bossEnemy;
public Transform bossSpawnPoint;
[Header("Cache")]
[SerializeField] private Transform enemyFolder;
[SerializeField] private Marisa player;
private void Update()
{
if (canSpawn)
{
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
}
public void StartBoss()
{
SpawnEnemy(bossEnemy, bossSpawnPoint.position);
canSpawn = false;
}
}