Gehirn erfolgreich eingeschaltet 👍👍👍
This commit is contained in:
@ -8,4 +8,9 @@ public class Developer : MonoBehaviour
|
||||
/// Gibt die Effizienz des Entwicklers in Prozent zurück.
|
||||
/// </summary>
|
||||
public float Efficiency => 1.0f;
|
||||
|
||||
public void UpdateEfficiency()
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<Developer> _developers = new();
|
||||
|
||||
/// <summary>
|
||||
/// Wie weit das Spiel bereits fortgeschritten ist.
|
||||
/// Wie weit das Spiel bereits fortgeschritten ist, in Prozent.
|
||||
/// </summary>
|
||||
public double GameProgress => _gameProgress;
|
||||
public double GameProgress => 1.0 - (_remainingGameDurationSeconds / _baseGameDurationSeconds);
|
||||
|
||||
/// <summary>
|
||||
/// Wie Effizient das Team derzeit arbeitet.
|
||||
@ -36,17 +33,7 @@ public class GameManager : MonoBehaviour
|
||||
/// <summary>
|
||||
/// Wie viele Sekunden das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern.
|
||||
/// </summary>
|
||||
public double RemainingGameDurationSeconds => _remainingGameDurationSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Wie lange das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern.
|
||||
/// </summary>
|
||||
public TimeSpan RemainingGameDuration => TimeSpan.FromSeconds(_remainingGameDurationSeconds);
|
||||
|
||||
/// <summary>
|
||||
/// Wie lange voraussichtlich das gesamte Spiel dauern wird.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user