noch mehr sprechen
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
using Microsoft.VisualStudio.Utilities;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Utility;
|
||||
@ -97,31 +99,51 @@ public class Developer : MonoBehaviour
|
||||
[SerializeField]
|
||||
private GameObject _caffeineNeed;
|
||||
|
||||
[SerializeField] private WantedConsumable _wantedDrink;
|
||||
[SerializeField]
|
||||
private WantedConsumable _wantedDrink;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject _hungerNeed;
|
||||
|
||||
[SerializeField] private WantedConsumable _wantedFood;
|
||||
[SerializeField]
|
||||
private WantedConsumable _wantedFood;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject _toiletNeed;
|
||||
|
||||
private AudioSource _audioSource;
|
||||
private float _talkPauseTime = 15.0f;
|
||||
private List<GameObject> _needList = new List<GameObject>();
|
||||
private bool _isDead = false;
|
||||
|
||||
/// <summary>
|
||||
/// indicates wether the Dev is dead or not
|
||||
/// </summary>
|
||||
public bool IsDead => _isDead;
|
||||
|
||||
[SerializeField]
|
||||
private int _maxPrivateContextBufferSize = 2;
|
||||
[SerializeField]
|
||||
private CircularBuffer<string> _privateContextBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the private Context Buffer
|
||||
/// </summary>
|
||||
public CircularBuffer<string> PrivateContextBuffer => _privateContextBuffer;
|
||||
|
||||
// stuff for talking
|
||||
[SerializeField, ShowOnly]
|
||||
private float _talkTimer;
|
||||
private AudioSource _audioSource;
|
||||
private float _talkPauseTime = 15.0f;
|
||||
private bool _hasTalkedWhileHyperactive = false;
|
||||
private bool _hasTalkedWhileOvercaffeinated = false;
|
||||
|
||||
private List<GameObject> _needList = new List<GameObject>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
_developerNeeds = gameObject.GetComponent<DeveloperNeeds>();
|
||||
_audioSource = GetComponent<AudioSource>();
|
||||
_talkTimer = UnityEngine.Random.Range(5.0f, 15.0f);
|
||||
_talkTimer = 2.0f; //Random.Range(5.0f, 15.0f);
|
||||
_fingersLeft = _baseStats.Fingers;
|
||||
_privateContextBuffer = new CircularBuffer<string>(_maxPrivateContextBufferSize);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -138,6 +160,12 @@ public class Developer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Hurt him")]
|
||||
private void TestHurt()
|
||||
{
|
||||
Hurt();
|
||||
}
|
||||
|
||||
[ContextMenu("Give Coffee")]
|
||||
private void TestCoffee()
|
||||
{
|
||||
@ -183,12 +211,14 @@ 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()}");
|
||||
Talk($"The Developer thanks Gottfried for the {drinkType.GetAsString()}", 1);
|
||||
_privateContextBuffer.Add($"The Developer is greatful for the {drinkType.GetAsString()} Gottfried recently brought him");
|
||||
_happiness += 0.2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Talk($"The Devolper blames Gottfried for bringing {drinkType.GetAsString()} but he actaully wanted a {_wantedDrink.GetAsString()}");
|
||||
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()}");
|
||||
_happiness -= 0.2;
|
||||
}
|
||||
}
|
||||
@ -214,9 +244,10 @@ public class Developer : MonoBehaviour
|
||||
_needList.Remove(_hungerNeed);
|
||||
NeedFullfilled(_hungerNeed);
|
||||
_hungerNeed = null;
|
||||
Talk("The Developer thanks Gottfried for the Pizza");
|
||||
Talk("The Developer thanks Gottfried for the Pizza", 1);
|
||||
_privateContextBuffer.Add($"The Developer is greatful for the Pizza Gottfried recently brought him");
|
||||
}
|
||||
|
||||
|
||||
if (_wantedFood != WantedConsumable.None)
|
||||
{
|
||||
if (foodType == _wantedFood)
|
||||
@ -247,7 +278,8 @@ public class Developer : MonoBehaviour
|
||||
_needList.Remove(_toiletNeed);
|
||||
NeedFullfilled(_toiletNeed);
|
||||
_toiletNeed = null;
|
||||
Talk("The Developer finally can go to the toilet");
|
||||
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");
|
||||
}
|
||||
|
||||
if (onToilet)
|
||||
@ -309,6 +341,8 @@ public class Developer : MonoBehaviour
|
||||
|
||||
if (_hungerLevel <= 0.0)
|
||||
{
|
||||
if (!_isDead)
|
||||
Talk($"The developer is starving, The developer is dying, The developer blames Gottfried for letting him starve with his last words", 0, true);
|
||||
Die();
|
||||
}
|
||||
}
|
||||
@ -414,11 +448,27 @@ public class Developer : MonoBehaviour
|
||||
|
||||
// Ob er stirbt oder nicht, für uns hat er auf jeden Fall seinen Nutzen verloren.
|
||||
if (_fingersLeft == 0)
|
||||
{
|
||||
if (!_isDead)
|
||||
Talk($"The developer lost all his fingers duo to an attack by a monster, The developer is dying, The developer gives a short speech with his last words, The developer blames Gottfried for his death", 0, true);
|
||||
Die();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_fingersLeft == 9)
|
||||
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)
|
||||
_privateContextBuffer.Add($"The developer cries for his {10 - _fingersLeft} lost fingers");
|
||||
else
|
||||
_privateContextBuffer.Add($"The developer is greatful he still has {_fingersLeft} fingers");
|
||||
}
|
||||
}
|
||||
|
||||
private void Die()
|
||||
{
|
||||
_isDead = true;
|
||||
Debug.Log($"{Name} ist verreckt.");
|
||||
}
|
||||
|
||||
@ -426,31 +476,52 @@ public class Developer : MonoBehaviour
|
||||
{
|
||||
float distanceToPlayer = Vector3.Distance(transform.position, GameManager.Instance.PlayerTransform.position);
|
||||
return distanceToPlayer <= _talkRange;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the context stored in the contextBuffer seperated with ',' as a string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPrivateContextAsString()
|
||||
{
|
||||
if (_privateContextBuffer.Count != 0)
|
||||
{
|
||||
string output = "";
|
||||
foreach (string context in _privateContextBuffer)
|
||||
{
|
||||
output += context + ", ";
|
||||
}
|
||||
return output;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts talking when player is near to the Dev.
|
||||
/// </summary>
|
||||
public void TalkIfInRange()
|
||||
{
|
||||
if (IsGottfriedInRange())
|
||||
if (IsGottfriedInRange() && !_isDead)
|
||||
{
|
||||
Talk();
|
||||
string context = GetPrivateContextAsString();
|
||||
context += GameManager.Instance.GetContextAsString();
|
||||
Talk(context);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dev starts talking.
|
||||
/// </summary>
|
||||
public void Talk(string context = null)
|
||||
public void Talk(string context, int shortnessLevel = 0, bool priority = false)
|
||||
{
|
||||
if (context == null)
|
||||
if (priority)
|
||||
{
|
||||
context = GameManager.Instance.GetContextAsString();
|
||||
_audioSource.Stop();
|
||||
_audioSource.clip = null;
|
||||
}
|
||||
if (!_audioSource.isPlaying)
|
||||
{
|
||||
GetComponent<Text2Speech>().Generate(context);
|
||||
{
|
||||
GetComponent<Text2Speech>().Generate(context, shortnessLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user