First project upload
This commit is contained in:
72
Assets/New Lowpoly Models/Scripts/CharacterSpawner.cs
Normal file
72
Assets/New Lowpoly Models/Scripts/CharacterSpawner.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject cat;
|
||||
[SerializeField] private GameObject cheetah;
|
||||
[SerializeField] private GameObject eagle;
|
||||
[SerializeField] private GameObject hm;
|
||||
[SerializeField] private GameObject hyena;
|
||||
[SerializeField] private GameObject rabbit;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
DisableAll();
|
||||
|
||||
string selected = CharacterSelectionData.Instance?.SelectedCharacter;
|
||||
|
||||
if (string.IsNullOrEmpty(selected))
|
||||
{
|
||||
string[] characters =
|
||||
{
|
||||
"Cat",
|
||||
"Cheetah",
|
||||
"Eagle",
|
||||
"Hm",
|
||||
"Hyena",
|
||||
"Rabbit"
|
||||
};
|
||||
|
||||
selected = characters[Random.Range(0, characters.Length)];
|
||||
|
||||
Debug.Log("No character selected. Randomly chose: " + selected);
|
||||
}
|
||||
|
||||
switch (selected)
|
||||
{
|
||||
case "Cat":
|
||||
cat.SetActive(true);
|
||||
break;
|
||||
|
||||
case "Cheetah":
|
||||
cheetah.SetActive(true);
|
||||
break;
|
||||
|
||||
case "Eagle":
|
||||
eagle.SetActive(true);
|
||||
break;
|
||||
|
||||
case "Hm":
|
||||
hm.SetActive(true);
|
||||
break;
|
||||
|
||||
case "Hyena":
|
||||
hyena.SetActive(true);
|
||||
break;
|
||||
|
||||
case "Rabbit":
|
||||
rabbit.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableAll()
|
||||
{
|
||||
cat.SetActive(false);
|
||||
cheetah.SetActive(false);
|
||||
eagle.SetActive(false);
|
||||
hm.SetActive(false);
|
||||
hyena.SetActive(false);
|
||||
rabbit.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user