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