Gehirn erfolgreich eingeschaltet 👍👍👍
This commit is contained in:
parent
089b55658c
commit
7ba804c32d
|
@ -227,6 +227,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 283529458}
|
- component: {fileID: 283529458}
|
||||||
- component: {fileID: 283529457}
|
- component: {fileID: 283529457}
|
||||||
|
- component: {fileID: 283529459}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Game Manager
|
m_Name: Game Manager
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -243,13 +244,14 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 283529456}
|
m_GameObject: {fileID: 283529456}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 54747ffb706c8df4bbb0c0ca3e60a560, type: 3}
|
m_Script: {fileID: 11500000, guid: 4c31bfd8f0f10f540b73de81aac6d46c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_baseGameDurationSeconds: 600
|
_baseGameDurationSeconds: 600
|
||||||
_currentEfficiency: 0
|
|
||||||
_remainingGameDurationSeconds: 0
|
_remainingGameDurationSeconds: 0
|
||||||
_developers: []
|
_currentEfficiency: 0
|
||||||
|
_developers:
|
||||||
|
- {fileID: 283529459}
|
||||||
--- !u!4 &283529458
|
--- !u!4 &283529458
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -265,6 +267,18 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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
|
--- !u!1 &1737307722
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -8,4 +8,9 @@ public class Developer : MonoBehaviour
|
||||||
/// Gibt die Effizienz des Entwicklers in Prozent zurück.
|
/// Gibt die Effizienz des Entwicklers in Prozent zurück.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Efficiency => 1.0f;
|
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; }
|
public static GameManager Instance { get; private set; }
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private double _gameProgress = 0.0;
|
private double _baseGameDurationSeconds = 10.0 * 60.0;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private double _baseGameDurationSeconds = 10.0 * 60.0;
|
private double _remainingGameDurationSeconds = 0.0;
|
||||||
|
|
||||||
[SerializeField, ShowOnly]
|
[SerializeField, ShowOnly]
|
||||||
private double _currentEfficiency = 0.0;
|
private double _currentEfficiency = 0.0;
|
||||||
|
|
||||||
[SerializeField, ShowOnly]
|
|
||||||
private double _remainingGameDurationSeconds = 0.0;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<Developer> _developers = new();
|
private List<Developer> _developers = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wie weit das Spiel bereits fortgeschritten ist.
|
/// Wie weit das Spiel bereits fortgeschritten ist, in Prozent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double GameProgress => _gameProgress;
|
public double GameProgress => 1.0 - (_remainingGameDurationSeconds / _baseGameDurationSeconds);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wie Effizient das Team derzeit arbeitet.
|
/// Wie Effizient das Team derzeit arbeitet.
|
||||||
|
@ -36,17 +33,7 @@ public class GameManager : MonoBehaviour
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wie viele Sekunden das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern.
|
/// Wie viele Sekunden das Spiel voraussichtlich noch dauern wird, würden die Effizienz sich nicht verändern.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double RemainingGameDurationSeconds => _remainingGameDurationSeconds;
|
public double ExpectedRemainingGameDuration => _remainingGameDurationSeconds / _currentEfficiency;
|
||||||
|
|
||||||
/// <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;
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
@ -59,9 +46,16 @@ public class GameManager : MonoBehaviour
|
||||||
Debug.LogError("GameManager already exists. Deleting duplicate.");
|
Debug.LogError("GameManager already exists. Deleting duplicate.");
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvokeRepeating(nameof(UpdateProgress), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
private void Start()
|
||||||
|
{
|
||||||
|
_remainingGameDurationSeconds = _baseGameDurationSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateProgress()
|
||||||
{
|
{
|
||||||
UpdateEfficiency();
|
UpdateEfficiency();
|
||||||
UpdateGameDuration();
|
UpdateGameDuration();
|
||||||
|
@ -69,13 +63,20 @@ public class GameManager : MonoBehaviour
|
||||||
|
|
||||||
void UpdateEfficiency()
|
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()
|
void UpdateGameDuration()
|
||||||
{
|
{
|
||||||
double baseSecondsLeft = _baseGameDurationSeconds * (1.0 - GameProgress);
|
// Entwickler Effizienz ist im Grunde wie viele Entwicklersekunden wir pro Sekunde verrichten können.
|
||||||
|
_remainingGameDurationSeconds -= _currentEfficiency;
|
||||||
_remainingGameDurationSeconds = baseSecondsLeft / _currentEfficiency;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue