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

66 lines
2.0 KiB
C#
Raw Normal View History

2024-04-05 13:18:15 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeveloperNeeds : MonoBehaviour
{
[SerializeField] List<GameObject> Needs = new List<GameObject>();
2024-04-05 13:18:15 +02:00
private Text2Speech _text2speech;
2024-04-05 18:11:26 +02:00
private AudioSource _audioSource;
2024-04-05 13:18:15 +02:00
// Start is called before the first frame update
void Start()
{
_text2speech = GetComponent<Text2Speech>();
2024-04-05 18:11:26 +02:00
_audioSource = GetComponent<AudioSource>();
2024-04-05 13:18:15 +02:00
}
// Update is called once per frame
void Update()
{
}
2024-04-05 16:14:51 +02:00
public GameObject spawnNeed(string needName)
{
2024-04-05 14:34:32 +02:00
GameObject spawnedNeed = null;
string context = "";
2024-04-05 14:34:32 +02:00
switch (needName)
{
case "coffee":
spawnedNeed = Instantiate(Needs[0], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
2024-04-05 18:11:26 +02:00
context = "The NPC wants coffee";
break;
case "mate":
spawnedNeed = Instantiate(Needs[1], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
2024-04-05 18:11:26 +02:00
context = "The NPC wants a Club Mate";
break;
case "toilet":
spawnedNeed = Instantiate(Needs[2], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
2024-04-05 18:11:26 +02:00
context = "The NPC wants to go to the toilet, toilet is clogged and dirty";
break;
case "money":
spawnedNeed = Instantiate(Needs[3], new Vector3(0.0f, 2f, 0.0f), Needs[0].transform.rotation);
2024-04-05 18:11:26 +02:00
context = "The NPC wants a raise, The NPC needs more money";
break;
default:
break;
}
2024-04-05 14:34:32 +02:00
if (spawnedNeed != null)
{
spawnedNeed.transform.SetParent(transform, false);
spawnedNeed.transform.localScale = new Vector3(0.4f, 0.01f, 0.4f);
2024-04-05 18:11:26 +02:00
if (!_audioSource.isPlaying)
{
_text2speech.Generate(context);
}
2024-04-05 16:14:51 +02:00
return spawnedNeed;
2024-04-05 14:34:32 +02:00
}
2024-04-05 16:14:51 +02:00
return null;
}
2024-04-05 13:18:15 +02:00
}