diff --git a/3d Prototyp/Assets/Scenes/GameLoopTest.unity b/3d Prototyp/Assets/Scenes/GameLoopTest.unity index bacb6fb2..47241bd3 100644 --- a/3d Prototyp/Assets/Scenes/GameLoopTest.unity +++ b/3d Prototyp/Assets/Scenes/GameLoopTest.unity @@ -227,6 +227,7 @@ GameObject: m_Component: - component: {fileID: 283529458} - component: {fileID: 283529457} + - component: {fileID: 283529459} m_Layer: 0 m_Name: Game Manager m_TagString: Untagged @@ -243,13 +244,14 @@ MonoBehaviour: m_GameObject: {fileID: 283529456} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 54747ffb706c8df4bbb0c0ca3e60a560, type: 3} + m_Script: {fileID: 11500000, guid: 4c31bfd8f0f10f540b73de81aac6d46c, type: 3} m_Name: m_EditorClassIdentifier: _baseGameDurationSeconds: 600 - _currentEfficiency: 0 _remainingGameDurationSeconds: 0 - _developers: [] + _currentEfficiency: 0 + _developers: + - {fileID: 283529459} --- !u!4 &283529458 Transform: m_ObjectHideFlags: 0 @@ -265,6 +267,18 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &283529459 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 283529456} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6dcc72027d5c35441a351fdb5140b0f8, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1737307722 GameObject: m_ObjectHideFlags: 0 diff --git a/3d Prototyp/Assets/Scripts/Developer.cs b/3d Prototyp/Assets/Scripts/Developer.cs index b3feff53..5844c954 100644 --- a/3d Prototyp/Assets/Scripts/Developer.cs +++ b/3d Prototyp/Assets/Scripts/Developer.cs @@ -8,4 +8,9 @@ public class Developer : MonoBehaviour /// Gibt die Effizienz des Entwicklers in Prozent zurück. /// public float Efficiency => 1.0f; + + public void UpdateEfficiency() + { + // TODO: Implement + } } diff --git a/3d Prototyp/Assets/Scripts/GameManager.cs b/3d Prototyp/Assets/Scripts/GameManager.cs index 9d2a07c1..5eec86e3 100644 --- a/3d Prototyp/Assets/Scripts/GameManager.cs +++ b/3d Prototyp/Assets/Scripts/GameManager.cs @@ -9,24 +9,21 @@ public class GameManager : MonoBehaviour public static GameManager Instance { get; private set; } [SerializeField] - private double _gameProgress = 0.0; + private double _baseGameDurationSeconds = 10.0 * 60.0; [SerializeField] - private double _baseGameDurationSeconds = 10.0 * 60.0; + private double _remainingGameDurationSeconds = 0.0; [SerializeField, ShowOnly] private double _currentEfficiency = 0.0; - [SerializeField, ShowOnly] - private double _remainingGameDurationSeconds = 0.0; - [SerializeField] private List _developers = new(); /// - /// Wie weit das Spiel bereits fortgeschritten ist. + /// Wie weit das Spiel bereits fortgeschritten ist, in Prozent. /// - public double GameProgress => _gameProgress; + public double GameProgress => 1.0 - (_remainingGameDurationSeconds / _baseGameDurationSeconds); /// /// Wie Effizient das Team derzeit arbeitet. @@ -36,17 +33,7 @@ public class GameManager : MonoBehaviour /// /// Wie viele Sekunden das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern. /// - public double RemainingGameDurationSeconds => _remainingGameDurationSeconds; - - /// - /// Wie lange das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern. - /// - public TimeSpan RemainingGameDuration => TimeSpan.FromSeconds(_remainingGameDurationSeconds); - - /// - /// Wie lange voraussichtlich das gesamte Spiel dauern wird. - /// - public double ExpectedTotalGameSeconds => 0.0; + public double ExpectedRemainingGameDuration => _remainingGameDurationSeconds / _currentEfficiency; private void Awake() { @@ -59,9 +46,16 @@ public class GameManager : MonoBehaviour Debug.LogError("GameManager already exists. Deleting duplicate."); Destroy(gameObject); } + + InvokeRepeating(nameof(UpdateProgress), 0.0f, 1.0f); } - void Update() + private void Start() + { + _remainingGameDurationSeconds = _baseGameDurationSeconds; + } + + void UpdateProgress() { UpdateEfficiency(); UpdateGameDuration(); @@ -69,13 +63,20 @@ public class GameManager : MonoBehaviour void UpdateEfficiency() { - _currentEfficiency = _developers.Sum(d => d.Efficiency); + double developerEfficiency = 0.0f; + + foreach (Developer developer in _developers) + { + developer.UpdateEfficiency(); + developerEfficiency += developer.Efficiency; + } + + _currentEfficiency = developerEfficiency; } void UpdateGameDuration() { - double baseSecondsLeft = _baseGameDurationSeconds * (1.0 - GameProgress); - - _remainingGameDurationSeconds = baseSecondsLeft / _currentEfficiency; + // Entwickler Effizienz ist im Grunde wie viele Entwicklersekunden wir pro Sekunde verrichten können. + _remainingGameDurationSeconds -= _currentEfficiency; } }