GameVsJam/3d Prototyp/Assets/Scripts/DeveloperNeeds.cs

78 lines
3.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeveloperNeeds : MonoBehaviour
{
private Text2Speech _text2speech;
private AudioSource _audioSource;
// Start is called before the first frame update
void Start()
{
_text2speech = GetComponent<Text2Speech>();
_audioSource = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
}
// TODO: Enums statt strings verwenden
// TODO: Multiple Needs möglich übereinander anzeigen?
public GameObject SpawnCoffeeNeed(int numNeeds) => spawnNeed("coffee", numNeeds);
public GameObject SpawnMateNeed(int numNeeds) => spawnNeed("mate", numNeeds);
public GameObject SpawnToiletNeed(int numNeeds) => spawnNeed("toilet", numNeeds);
public GameObject SpawnHungerNeed(int numNeeds) => spawnNeed("hunger", numNeeds);
public GameObject SpawnMoneyNeed(int numNeeds) => spawnNeed("money", numNeeds);
public GameObject spawnNeed(string needName, float numNeeds)
{
GameObject spawnedNeed = null;
string context = "";
switch (needName)
{
case "coffee":
spawnedNeed = Instantiate(GameManager.Instance.Needs[0], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), GameManager.Instance.Needs[0].transform.rotation);
context = "The Developer wants Gottfried to bring him a coffee";
break;
case "mate":
spawnedNeed = Instantiate(GameManager.Instance.Needs[1], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), GameManager.Instance.Needs[0].transform.rotation);
context = "The Developer wants Gottfried to bring him a Blub Mate (Yes, its a drink called Blub Mate)";
break;
case "toilet":
spawnedNeed = Instantiate(GameManager.Instance.Needs[2], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), GameManager.Instance.Needs[0].transform.rotation);
context = "The Developer wants to go to the toilet";
break;
case "hunger":
spawnedNeed = Instantiate(GameManager.Instance.Needs[3], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), GameManager.Instance.Needs[0].transform.rotation);
context = "The Developer wants Gottfried to bring him a pizza";
break;
case "money":
spawnedNeed = Instantiate(GameManager.Instance.Needs[3], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), GameManager.Instance.Needs[0].transform.rotation);
context = "The Developer wants a raise, The Developer needs more money";
break;
default:
Debug.LogError($"Unbekannter need \"{needName}\"");
break;
}
if (spawnedNeed != null)
{
spawnedNeed.transform.SetParent(transform, false);
spawnedNeed.transform.localScale = new Vector3(0.4f, 0.01f, 0.4f);
if (!_audioSource.isPlaying)
{
_text2speech.Generate(context, 1);
}
return spawnedNeed;
}
return null;
}
}