Mehr reden
This commit is contained in:
parent
f202aace09
commit
2f5f25d0bd
|
@ -94,17 +94,6 @@ public class Developer : MonoBehaviour
|
|||
|
||||
public string Name => _name;
|
||||
|
||||
[Serializable, Flags]
|
||||
public enum WantedConsumable
|
||||
{
|
||||
None,
|
||||
Food = 0x01,
|
||||
Drink = 0x02,
|
||||
Coffee = Drink | 0x04,
|
||||
Mate = Drink | 0x08,
|
||||
Pizza = Food | 0x10
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private GameObject _caffeineNeed;
|
||||
|
||||
|
@ -122,6 +111,8 @@ public class Developer : MonoBehaviour
|
|||
private float _talkPauseTime = 15.0f;
|
||||
[SerializeField, ShowOnly]
|
||||
private float _talkTimer;
|
||||
private bool _hasTalkedWhileHyperactive = false;
|
||||
private bool _hasTalkedWhileOvercaffeinated = false;
|
||||
|
||||
private List<GameObject> _needList = new List<GameObject>();
|
||||
|
||||
|
@ -191,9 +182,15 @@ public class Developer : MonoBehaviour
|
|||
{
|
||||
// TODO: Wie wäre es damit, das nicht fest zu coden?
|
||||
if (drinkType == _wantedDrink)
|
||||
{
|
||||
Talk($"The Devolper thanks Gottfried for the {drinkType.GetAsString()}");
|
||||
_happiness += 0.2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Talk($"The Devolper blames Gottfried for bringing {drinkType.GetAsString()} but he actaully wanted a {_wantedDrink.GetAsString()}");
|
||||
_happiness -= 0.2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -217,6 +214,7 @@ public class Developer : MonoBehaviour
|
|||
_needList.Remove(_hungerNeed);
|
||||
NeedFullfilled(_hungerNeed);
|
||||
_hungerNeed = null;
|
||||
Talk("The Developer thanks Gottfried for the Pizza");
|
||||
}
|
||||
|
||||
if (_wantedFood != WantedConsumable.None)
|
||||
|
@ -249,6 +247,7 @@ public class Developer : MonoBehaviour
|
|||
_needList.Remove(_toiletNeed);
|
||||
NeedFullfilled(_toiletNeed);
|
||||
_toiletNeed = null;
|
||||
Talk("The Developer finally can go to the toilet");
|
||||
}
|
||||
|
||||
if (onToilet)
|
||||
|
@ -269,7 +268,7 @@ public class Developer : MonoBehaviour
|
|||
_urgeToUrinateLevel = Math.Max(_urgeToUrinateLevel, 0.0);
|
||||
_happiness = Math.Max(_happiness, 0.0);
|
||||
|
||||
_isHyperactive = _caffeineLevel > 1.0;
|
||||
_isHyperactive = _caffeineLevel > 1.0 && _caffeineLevel <= 1.5;
|
||||
_isOvercaffeinated = _caffeineLevel > 1.5;
|
||||
_isSleeping = _caffeineLevel <= 0.0;
|
||||
|
||||
|
@ -351,12 +350,32 @@ public class Developer : MonoBehaviour
|
|||
if (_isSleeping)
|
||||
return 0.0;
|
||||
|
||||
// Die Formel hat schon recht vielversprechendes Verhalten im Bereich > 1
|
||||
//if (_isHyperactive)
|
||||
// return 1.0 + (_caffeineLevel - 1.0) * (_caffeineLevel - 1.0);
|
||||
if (_isHyperactive)
|
||||
{
|
||||
if (!_hasTalkedWhileHyperactive)
|
||||
{
|
||||
Talk("The Developer is surprisingly productive right now duo to caffeine");
|
||||
_hasTalkedWhileHyperactive = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasTalkedWhileHyperactive = false;
|
||||
}
|
||||
|
||||
if (_isOvercaffeinated)
|
||||
{
|
||||
if (!_hasTalkedWhileOvercaffeinated)
|
||||
{
|
||||
Talk("The Developer drank too much caffeine, The Developer needs a break immediately");
|
||||
_hasTalkedWhileOvercaffeinated = true;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hasTalkedWhileOvercaffeinated = false;
|
||||
}
|
||||
|
||||
// https://easings.net/#easeOutCubic
|
||||
return 1.0 - Math.Pow(1.0 - _caffeineLevel, 3.0);
|
||||
|
@ -423,9 +442,12 @@ public class Developer : MonoBehaviour
|
|||
/// <summary>
|
||||
/// Dev starts talking.
|
||||
/// </summary>
|
||||
public void Talk()
|
||||
public void Talk(string context = null)
|
||||
{
|
||||
string context = GameManager.Instance.GetContextAsString();
|
||||
if (context == null)
|
||||
{
|
||||
context = GameManager.Instance.GetContextAsString();
|
||||
}
|
||||
if (!_audioSource.isPlaying)
|
||||
{
|
||||
GetComponent<Text2Speech>().Generate(context);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DeveloperNeeds : MonoBehaviour
|
|||
break;
|
||||
case "toilet":
|
||||
spawnedNeed = Instantiate(Needs[2], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
|
||||
context = "The Developer wants to go to the toilet, toilet is clogged and dirty";
|
||||
context = "The Developer wants to go to the toilet";
|
||||
break;
|
||||
case "hunger":
|
||||
spawnedNeed = Instantiate(Needs[3], new Vector3(0.0f, 2f + (numNeeds * 0.5f), 0.0f), Needs[0].transform.rotation);
|
||||
|
|
|
@ -11,6 +11,7 @@ using OpenAI_API.Models;
|
|||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Google.Cloud.TextToSpeech.V1;
|
||||
|
||||
[Serializable]
|
||||
public class TextToSpeechResponse
|
||||
|
@ -21,12 +22,22 @@ public class TextToSpeechResponse
|
|||
|
||||
public class Text2Speech : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public string context = "going for a walk, falling, explosion, blood";
|
||||
[SerializeField]
|
||||
public string gender = "MALE";
|
||||
[SerializeField]
|
||||
public JToken voice = null;
|
||||
[SerializeField]
|
||||
public double speakingSpeed = 1.1;
|
||||
[SerializeField]
|
||||
public bool playSound = false;
|
||||
[SerializeField]
|
||||
public bool generate = false;
|
||||
[SerializeField]
|
||||
public bool newVoiceAndGenerate = false;
|
||||
[SerializeField]
|
||||
public string Voice;
|
||||
|
||||
private AudioSource _audioSource;
|
||||
|
||||
|
@ -60,6 +71,7 @@ public class Text2Speech : MonoBehaviour
|
|||
{
|
||||
GetRandomGermanVoice(gender, (v) => {
|
||||
voice = v;
|
||||
Voice = voice.ToString();
|
||||
//Debug.Log($"GoogleCloud: Choosen voice is\n{voice}");
|
||||
StartCoroutine(GenerateAndSynthesizeText(context));
|
||||
});
|
||||
|
@ -69,6 +81,13 @@ public class Text2Speech : MonoBehaviour
|
|||
StartCoroutine(GenerateAndSynthesizeText(context));
|
||||
}
|
||||
}
|
||||
if (newVoiceAndGenerate)
|
||||
{
|
||||
newVoiceAndGenerate = false;
|
||||
voice = null;
|
||||
Voice = null;
|
||||
generate = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Generate(string c)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"languageCodes": [
|
||||
"en-AU"
|
||||
],
|
||||
"name": "en-AU-News-G",
|
||||
"ssmlGender": "MALE",
|
||||
"naturalSampleRateHertz": 24000,
|
||||
"pitch": -2
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23e2a6475b913ee4b8746739f66bccfe
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
[Serializable, Flags]
|
||||
public enum WantedConsumable
|
||||
{
|
||||
None,
|
||||
Food = 0x01,
|
||||
Drink = 0x02,
|
||||
Coffee = Drink | 0x04,
|
||||
Mate = Drink | 0x08,
|
||||
Pizza = Food | 0x10
|
||||
}
|
||||
|
||||
public static class WantedConsumableExtension
|
||||
{
|
||||
|
||||
public static string GetAsString(this WantedConsumable wantedConsumable) =>
|
||||
wantedConsumable switch
|
||||
{
|
||||
WantedConsumable.None => "None",
|
||||
WantedConsumable.Food => "Food",
|
||||
WantedConsumable.Drink => "Drink",
|
||||
WantedConsumable.Coffee => "Coffee",
|
||||
WantedConsumable.Mate => "Blub Mate",
|
||||
WantedConsumable.Pizza => "Pizza",
|
||||
_ => ""
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7aa5732bd4e078f4aafd3188c4976d5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue