Mehr reden

This commit is contained in:
2024-04-06 20:02:57 +02:00
parent f202aace09
commit 2f5f25d0bd
7 changed files with 120 additions and 20 deletions

View File

@ -93,17 +93,6 @@ public class Developer : MonoBehaviour
public double CurrentEfficiency => _currentEfficiency;
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,10 +268,10 @@ 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;
if (_caffeineLevel < GameManager.Instance.NeedNotificationThreshold && _caffeineNeed == null)
{
// TODO: Wir können hier anhand von Präferenz gewichten.
@ -351,13 +350,33 @@ 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);