72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
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);
|
|
}
|
|
} |