2024-04-04 12:05:18 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2024-04-05 14:45:41 +02:00
|
|
|
|
using System.ComponentModel;
|
2024-04-04 12:05:18 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class NPC_Behavior : MonoBehaviour
|
|
|
|
|
{
|
2024-04-04 12:14:58 +02:00
|
|
|
|
[SerializeField] private double _caffeineLevel = 0.0; // max 100, min 0
|
|
|
|
|
[SerializeField] private double _hungerLevel = 0.0; // max 100, min 0
|
|
|
|
|
[SerializeField] private double _happinessLevel = 100.0; // max 100, min 0
|
2024-04-05 13:18:15 +02:00
|
|
|
|
[SerializeField] private double _baseDevelopementPower = 100.0; // max 100, min 0
|
2024-04-04 12:14:58 +02:00
|
|
|
|
[SerializeField] private double _developementPower = 100.0; // max unlimited, min 0
|
|
|
|
|
[SerializeField] double eventRate = 1.0; // max 60, min 0 -> how many events are requested per minute
|
2024-04-04 12:05:18 +02:00
|
|
|
|
|
2024-04-05 13:18:15 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gibt das Koffeinlevel des Entwicklers zur<75>ck
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double CaffeineLevel => _caffeineLevel;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gibt das Hungerlevel des Entwicklers zur<75>ck
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double HungerLevel => _hungerLevel;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gibt das Zufriedenheitslevel des Entwicklers zur<75>ck
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double HappnessLevel => _happinessLevel;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gibt die Basisentwicklungskraft des Entwicklers zur<75>ck
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double BaseDevelopementPower => _baseDevelopementPower;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gibt die jetzige Entwicklungskraft des Entwicklers zur<75>ck
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double DevelopmentPower => _developementPower;
|
|
|
|
|
|
2024-04-05 14:08:45 +02:00
|
|
|
|
private GameManager _gameManager;
|
|
|
|
|
private DeveloperNeeds _developerNeeds;
|
2024-04-05 14:45:41 +02:00
|
|
|
|
[SerializeField] private float _timer;
|
|
|
|
|
private float _timeBetweenEvents;
|
2024-04-05 13:18:15 +02:00
|
|
|
|
|
2024-04-04 12:05:18 +02:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2024-04-05 13:18:15 +02:00
|
|
|
|
_gameManager = GameManager.Instance;
|
2024-04-05 14:08:45 +02:00
|
|
|
|
_developerNeeds = GetComponent<DeveloperNeeds>();
|
2024-04-05 14:45:41 +02:00
|
|
|
|
ResetTimer();
|
2024-04-04 12:05:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2024-04-05 14:45:41 +02:00
|
|
|
|
_timer -= Time.deltaTime;
|
|
|
|
|
|
|
|
|
|
if (_timer <= 0)
|
|
|
|
|
{
|
|
|
|
|
List<string> needs = new List<string>() { "coffee", "mate", "toilet" };
|
|
|
|
|
_developerNeeds.spawnNeed(needs[UnityEngine.Random.Range(0, needs.Count)]);
|
|
|
|
|
ResetTimer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResetTimer()
|
|
|
|
|
{
|
|
|
|
|
if (eventRate <= 0)
|
|
|
|
|
{
|
|
|
|
|
_timeBetweenEvents = float.MaxValue;
|
|
|
|
|
}
|
|
|
|
|
else
|
2024-04-05 13:18:15 +02:00
|
|
|
|
{
|
2024-04-05 14:45:41 +02:00
|
|
|
|
_timeBetweenEvents = 60f / (float)eventRate;
|
|
|
|
|
_timer = Random.Range(0.5f * _timeBetweenEvents, 1.5f * _timeBetweenEvents);
|
2024-04-05 13:18:15 +02:00
|
|
|
|
}
|
2024-04-04 12:05:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, double> GetStats()
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<string, double>
|
|
|
|
|
{
|
2024-04-04 12:14:58 +02:00
|
|
|
|
{ "Caffine", _caffeineLevel },
|
|
|
|
|
{ "Hunger", _hungerLevel },
|
|
|
|
|
{ "Happiness", _happinessLevel },
|
|
|
|
|
{ "Developement Power", _developementPower }
|
2024-04-04 12:05:18 +02:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetStats(Dictionary<string, double> stats)
|
|
|
|
|
{
|
|
|
|
|
foreach (string key in stats.Keys)
|
|
|
|
|
{
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
|
|
|
|
case "Caffine":
|
2024-04-04 12:14:58 +02:00
|
|
|
|
_caffeineLevel = stats[key];
|
2024-04-04 12:05:18 +02:00
|
|
|
|
break;
|
|
|
|
|
case "Hunger":
|
2024-04-04 12:14:58 +02:00
|
|
|
|
_hungerLevel = stats[key];
|
2024-04-04 12:05:18 +02:00
|
|
|
|
break;
|
|
|
|
|
case "Happiness":
|
2024-04-04 12:14:58 +02:00
|
|
|
|
_happinessLevel = stats[key];
|
2024-04-04 12:05:18 +02:00
|
|
|
|
break;
|
|
|
|
|
case "Developement Power":
|
2024-04-04 12:14:58 +02:00
|
|
|
|
_developementPower = stats[key];
|
2024-04-04 12:05:18 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Debug.LogError("Unknown Stat/Key");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|