From 496a54c8780db1c4c9140242ebbd404cd0739322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Thu, 4 Apr 2024 18:13:08 +0200 Subject: [PATCH] =?UTF-8?q?Grundlagen=20f=C3=BCr=20Effizienz=20und=20Arbei?= =?UTF-8?q?tssicherheit=20geschaffen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3d Prototyp/Assets/Scripts/Developer.cs | 53 +++++++++++++++++++++-- 3d Prototyp/Assets/Scripts/GameManager.cs | 2 +- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/3d Prototyp/Assets/Scripts/Developer.cs b/3d Prototyp/Assets/Scripts/Developer.cs index 5844c954..1075225d 100644 --- a/3d Prototyp/Assets/Scripts/Developer.cs +++ b/3d Prototyp/Assets/Scripts/Developer.cs @@ -1,16 +1,63 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Serialization; public class Developer : MonoBehaviour { + private string _name; + /// - /// Gibt die Effizienz des Entwicklers in Prozent zurück. + /// Manche Entwickler sind einfach effizienter als andere. /// - public float Efficiency => 1.0f; + [SerializeField] + private double _baseEfficiency = 1.0; + [SerializeField, ShowOnly] + private double currentCurrentEfficiency = 1.0; + + /// + /// Ich hoffe, dass der Entwickler eine Arbeitsunfähigkeitsversicherung hat. + /// + [SerializeField] + private int _fingersLeft = 10; + + /// + /// Gibt die Grundeffizienz des Entwicklers zurück. + /// + public double BaseEfficiency => _baseEfficiency; + + /// + /// Gibt die Anzahl der Finger zurück. + /// + public int FingersLeft => _fingersLeft; + + /// + /// Gibt die aktuelle Effizienz des Entwicklers in Prozent zurück. + /// + public double CurrentEfficiency => currentCurrentEfficiency; + + public string Name => _name; + public void UpdateEfficiency() { - // TODO: Implement + currentCurrentEfficiency = _baseEfficiency * (_fingersLeft / 10.0); + } + + /// + /// Der Entwickler wird verletzt und der Idiot bricht sich ausgerechnet einen Finger... + /// + public void Hurt() + { + _fingersLeft--; + + // Ob er stirbt oder nicht, für uns hat er auf jeden Fall seinen Nutzen verloren. + if (_fingersLeft == 0) + Die(); + } + + private void Die() + { + Debug.Log($"{Name} ist verreckt."); } } diff --git a/3d Prototyp/Assets/Scripts/GameManager.cs b/3d Prototyp/Assets/Scripts/GameManager.cs index 2e883f96..95425aef 100644 --- a/3d Prototyp/Assets/Scripts/GameManager.cs +++ b/3d Prototyp/Assets/Scripts/GameManager.cs @@ -107,7 +107,7 @@ public class GameManager : MonoBehaviour foreach (Developer developer in _developers) { developer.UpdateEfficiency(); - developerEfficiency += developer.Efficiency; + developerEfficiency += developer.CurrentEfficiency; } _currentEfficiency = developerEfficiency;