From d5102b868d11d9aa17692f6a6b64c71126fcb1d6 Mon Sep 17 00:00:00 2001 From: klappstuhl24 Date: Sat, 6 Apr 2024 22:26:31 +0200 Subject: [PATCH] Kontextbasiertes Sprechen --- 3d Prototyp/Assets/Scenes/GameLoopTest.unity | 6 +++- 3d Prototyp/Assets/Scripts/Developer.cs | 36 ++++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/3d Prototyp/Assets/Scenes/GameLoopTest.unity b/3d Prototyp/Assets/Scenes/GameLoopTest.unity index 95e2a15a..f46d0b0e 100644 --- a/3d Prototyp/Assets/Scenes/GameLoopTest.unity +++ b/3d Prototyp/Assets/Scenes/GameLoopTest.unity @@ -1886,6 +1886,10 @@ PrefabInstance: propertyPath: _player value: objectReference: {fileID: 514859709} + - target: {fileID: 3650884189301972455, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3} + propertyPath: _maxContextBufferSize + value: 3 + objectReference: {fileID: 0} - target: {fileID: 3650884189301972455, guid: e1e33f0b2075b5c40817665dd8a86f31, type: 3} propertyPath: _developers.Array.size value: 1 @@ -2142,7 +2146,7 @@ MonoBehaviour: _hungerNeed: {fileID: 0} _wantedFood: 0 _toiletNeed: {fileID: 0} - _maxPrivateContextBufferSize: 5 + _maxPrivateContextBufferSize: 2 _talkTimer: 10 --- !u!82 &1814492795 AudioSource: diff --git a/3d Prototyp/Assets/Scripts/Developer.cs b/3d Prototyp/Assets/Scripts/Developer.cs index 79af2be2..5c21a469 100644 --- a/3d Prototyp/Assets/Scripts/Developer.cs +++ b/3d Prototyp/Assets/Scripts/Developer.cs @@ -136,12 +136,13 @@ public class Developer : MonoBehaviour private float _talkPauseTime = 15.0f; private bool _hasTalkedWhileHyperactive = false; private bool _hasTalkedWhileOvercaffeinated = false; + private bool _hasTalkedBeforeSleeping = false; void Start() { _developerNeeds = gameObject.GetComponent(); _audioSource = GetComponent(); - _talkTimer = 2.0f; //Random.Range(5.0f, 15.0f); + _talkTimer = Random.Range(5.0f, 15.0f); _fingersLeft = _baseStats.Fingers; _privateContextBuffer = new CircularBuffer(_maxPrivateContextBufferSize); } @@ -212,13 +213,13 @@ public class Developer : MonoBehaviour if (drinkType == _wantedDrink) { 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; } 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); - _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; } } @@ -245,7 +246,7 @@ public class Developer : MonoBehaviour NeedFullfilled(_hungerNeed); _hungerNeed = null; 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) @@ -279,7 +280,7 @@ public class Developer : MonoBehaviour NeedFullfilled(_toiletNeed); _toiletNeed = null; 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) @@ -382,18 +383,32 @@ public class Developer : MonoBehaviour private double CalculateCaffeineEfficiency() { 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; + } + else + { + _hasTalkedBeforeSleeping = false; + } if (_isHyperactive) { if (!_hasTalkedWhileHyperactive) { - Talk("The Developer is surprisingly productive right now duo to caffeine"); + GetComponent().speakingSpeed = 1.4f; + Talk("The Developer is surprisingly productive right now and feels an energyboost duo to caffeine", 0, true); _hasTalkedWhileHyperactive = true; } } else { + GetComponent().speakingSpeed = 1.1f; _hasTalkedWhileHyperactive = false; } @@ -401,7 +416,8 @@ public class Developer : MonoBehaviour { 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; } 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); 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); - if (Random.Range(0, 2) == 0) + if (Random.Range(0, 3) < 2) _privateContextBuffer.Add($"The developer cries for his {10 - _fingersLeft} lost fingers"); 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 /// public void TalkIfInRange() { - if (IsGottfriedInRange() && !_isDead) + if (IsGottfriedInRange() && !_isDead && !_isSleeping) { string context = GetPrivateContextAsString(); context += GameManager.Instance.GetContextAsString();