Kontextbasiertes Sprechen

This commit is contained in:
klappstuhl24 2024-04-06 22:26:31 +02:00
parent 2ecb40333c
commit d5102b868d
2 changed files with 31 additions and 11 deletions

View File

@ -1886,6 +1886,10 @@ PrefabInstance:
propertyPath: _player propertyPath: _player
value: value:
objectReference: {fileID: 514859709} objectReference: {fileID: 514859709}
- target: {fileID: 3650884189301972455, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
propertyPath: _maxContextBufferSize
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3650884189301972455, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3} - target: {fileID: 3650884189301972455, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3}
propertyPath: _developers.Array.size propertyPath: _developers.Array.size
value: 1 value: 1
@ -2142,7 +2146,7 @@ MonoBehaviour:
_hungerNeed: {fileID: 0} _hungerNeed: {fileID: 0}
_wantedFood: 0 _wantedFood: 0
_toiletNeed: {fileID: 0} _toiletNeed: {fileID: 0}
_maxPrivateContextBufferSize: 5 _maxPrivateContextBufferSize: 2
_talkTimer: 10 _talkTimer: 10
--- !u!82 &1814492795 --- !u!82 &1814492795
AudioSource: AudioSource:

View File

@ -136,12 +136,13 @@ public class Developer : MonoBehaviour
private float _talkPauseTime = 15.0f; private float _talkPauseTime = 15.0f;
private bool _hasTalkedWhileHyperactive = false; private bool _hasTalkedWhileHyperactive = false;
private bool _hasTalkedWhileOvercaffeinated = false; private bool _hasTalkedWhileOvercaffeinated = false;
private bool _hasTalkedBeforeSleeping = false;
void Start() void Start()
{ {
_developerNeeds = gameObject.GetComponent<DeveloperNeeds>(); _developerNeeds = gameObject.GetComponent<DeveloperNeeds>();
_audioSource = GetComponent<AudioSource>(); _audioSource = GetComponent<AudioSource>();
_talkTimer = 2.0f; //Random.Range(5.0f, 15.0f); _talkTimer = Random.Range(5.0f, 15.0f);
_fingersLeft = _baseStats.Fingers; _fingersLeft = _baseStats.Fingers;
_privateContextBuffer = new CircularBuffer<string>(_maxPrivateContextBufferSize); _privateContextBuffer = new CircularBuffer<string>(_maxPrivateContextBufferSize);
} }
@ -212,13 +213,13 @@ public class Developer : MonoBehaviour
if (drinkType == _wantedDrink) if (drinkType == _wantedDrink)
{ {
Talk($"The Developer thanks Gottfried for the {drinkType.GetAsString()}", 1); Talk($"The Developer thanks Gottfried for the {drinkType.GetAsString()}", 1);
_privateContextBuffer.Add($"The Developer is greatful for the {drinkType.GetAsString()} Gottfried recently brought him"); _privateContextBuffer.Add($"The Developer is greatful for the {drinkType.GetAsString()} Gottfried brought him a while ago");
_happiness += 0.2; _happiness += 0.2;
} }
else else
{ {
Talk($"The Developer is happy about the caffeine but he blames Gottfried for bringing {drinkType.GetAsString()} because he actaully wanted a {_wantedDrink.GetAsString()} instead", 0, true); Talk($"The Developer is happy about the caffeine but he blames Gottfried for bringing {drinkType.GetAsString()} because he actaully wanted a {_wantedDrink.GetAsString()} instead", 0, true);
_privateContextBuffer.Add($"The Developer is still annoyed about when Gottfried recently brought him {drinkType.GetAsString()} instead of {_wantedDrink.GetAsString()}"); _privateContextBuffer.Add($"The Developer is still annoyed and reminds Gottfried that he brought him {drinkType.GetAsString()} instead of {_wantedDrink.GetAsString()} a while ago");
_happiness -= 0.2; _happiness -= 0.2;
} }
} }
@ -245,7 +246,7 @@ public class Developer : MonoBehaviour
NeedFullfilled(_hungerNeed); NeedFullfilled(_hungerNeed);
_hungerNeed = null; _hungerNeed = null;
Talk("The Developer thanks Gottfried for the Pizza", 1); Talk("The Developer thanks Gottfried for the Pizza", 1);
_privateContextBuffer.Add($"The Developer is greatful for the Pizza Gottfried recently brought him"); _privateContextBuffer.Add($"The Developer is greatful for the Pizza Gottfried brought him a while ago");
} }
if (_wantedFood != WantedConsumable.None) if (_wantedFood != WantedConsumable.None)
@ -279,7 +280,7 @@ public class Developer : MonoBehaviour
NeedFullfilled(_toiletNeed); NeedFullfilled(_toiletNeed);
_toiletNeed = null; _toiletNeed = null;
Talk("The Developer finally can go to the toilet", 1); Talk("The Developer finally can go to the toilet", 1);
_privateContextBuffer.Add($"The developer is grateful that he went to the toilet a few minutes ago"); _privateContextBuffer.Add($"The developer is grateful that he went to the toilet a while ago");
} }
if (onToilet) if (onToilet)
@ -382,18 +383,32 @@ public class Developer : MonoBehaviour
private double CalculateCaffeineEfficiency() private double CalculateCaffeineEfficiency()
{ {
if (_isSleeping) if (_isSleeping)
{
if (!_hasTalkedBeforeSleeping)
{
Talk("The Developer is very sleepy right now duo to a lack of caffeine, The Developer takes a nap now", 0, true);
_privateContextBuffer.Add($"The developer took a refreshing nap but is annoyed that Gottfried forgot to bring him any caffeine before the nap");
_hasTalkedBeforeSleeping = true;
}
return 0.0; return 0.0;
}
else
{
_hasTalkedBeforeSleeping = false;
}
if (_isHyperactive) if (_isHyperactive)
{ {
if (!_hasTalkedWhileHyperactive) if (!_hasTalkedWhileHyperactive)
{ {
Talk("The Developer is surprisingly productive right now duo to caffeine"); GetComponent<Text2Speech>().speakingSpeed = 1.4f;
Talk("The Developer is surprisingly productive right now and feels an energyboost duo to caffeine", 0, true);
_hasTalkedWhileHyperactive = true; _hasTalkedWhileHyperactive = true;
} }
} }
else else
{ {
GetComponent<Text2Speech>().speakingSpeed = 1.1f;
_hasTalkedWhileHyperactive = false; _hasTalkedWhileHyperactive = false;
} }
@ -401,7 +416,8 @@ public class Developer : MonoBehaviour
{ {
if (!_hasTalkedWhileOvercaffeinated) if (!_hasTalkedWhileOvercaffeinated)
{ {
Talk("The Developer drank too much caffeine, The Developer needs a break immediately"); Talk("The Developer had too much caffeine, The Developer needs a break immediately", 0, true);
_privateContextBuffer.Add($"The developer overcaffeinated a while ago because Gottfried gave him too much caffeine");
_hasTalkedWhileOvercaffeinated = true; _hasTalkedWhileOvercaffeinated = true;
} }
return 0.0; return 0.0;
@ -459,10 +475,10 @@ public class Developer : MonoBehaviour
Talk($"The developer lost a finger duo to an attack by a monster, The developer has {_fingersLeft} left, The developer is in pain, The developer is irrevocably less productive now, The developer blames Gottfried for this", 0, true); Talk($"The developer lost a finger duo to an attack by a monster, The developer has {_fingersLeft} left, The developer is in pain, The developer is irrevocably less productive now, The developer blames Gottfried for this", 0, true);
else else
Talk($"The developer lost another finger duo to an attack by a monster, The developer has only {_fingersLeft} left, The developer is in pain, The developer is irrevocably less productive now, The developer blames Gottfried for this", 0, true); Talk($"The developer lost another finger duo to an attack by a monster, The developer has only {_fingersLeft} left, The developer is in pain, The developer is irrevocably less productive now, The developer blames Gottfried for this", 0, true);
if (Random.Range(0, 2) == 0) if (Random.Range(0, 3) < 2)
_privateContextBuffer.Add($"The developer cries for his {10 - _fingersLeft} lost fingers"); _privateContextBuffer.Add($"The developer cries for his {10 - _fingersLeft} lost fingers");
else else
_privateContextBuffer.Add($"The developer is greatful he still has {_fingersLeft} fingers"); _privateContextBuffer.Add($"The developer is greatful he still has {_fingersLeft} fingers even tho he had 10 once");
} }
} }
@ -501,7 +517,7 @@ public class Developer : MonoBehaviour
/// </summary> /// </summary>
public void TalkIfInRange() public void TalkIfInRange()
{ {
if (IsGottfriedInRange() && !_isDead) if (IsGottfriedInRange() && !_isDead && !_isSleeping)
{ {
string context = GetPrivateContextAsString(); string context = GetPrivateContextAsString();
context += GameManager.Instance.GetContextAsString(); context += GameManager.Instance.GetContextAsString();