added spawns for slimes, boss slime added. blocker for final area added + key to unlock
This commit is contained in:
36
Assets/Project Files/Scripts/JonasB/SlimeSpawner.cs
Normal file
36
Assets/Project Files/Scripts/JonasB/SlimeSpawner.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SlimeSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private List<GameObject> slimeTypes;
|
||||
[SerializeField]
|
||||
private List<Transform> spawnLocations;
|
||||
[SerializeField]
|
||||
private int maxAmount = 5;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
InvokeRepeating("SpawnSlime", 5, 5);
|
||||
}
|
||||
public void SpawnSlime()
|
||||
{
|
||||
int alive = GameObject.FindGameObjectsWithTag("Slime").Length;
|
||||
|
||||
if (alive == maxAmount)
|
||||
{
|
||||
// Max amount of slimes reached.
|
||||
Debug.LogWarning("Maximum reached");
|
||||
}
|
||||
else
|
||||
{
|
||||
float slimeRandom = Random.Range(0, slimeTypes.Count);
|
||||
float spawnRandom = Random.Range(0, spawnLocations.Count);
|
||||
Instantiate(slimeTypes[Mathf.RoundToInt(slimeRandom)], spawnLocations[Mathf.RoundToInt(spawnRandom)].position, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Project Files/Scripts/JonasB/SlimeSpawner.cs.meta
Normal file
11
Assets/Project Files/Scripts/JonasB/SlimeSpawner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dedb6213844c8e4085010a75a637d3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user