More betterer Time tracking and basic Win/Lose check
This commit is contained in:
68
3d Prototyp/Assets/Scripts/Utility/Difficulty.cs
Normal file
68
3d Prototyp/Assets/Scripts/Utility/Difficulty.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
public enum Difficulty
|
||||
{
|
||||
Easy,
|
||||
Medium,
|
||||
Hard
|
||||
}
|
||||
|
||||
public abstract class DifficultySettings
|
||||
{
|
||||
public Difficulty Difficulty { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Faktor, wie viel mehr Zeit man halt als die Entwickler bei 100% effizienz benötigen.
|
||||
/// </summary>
|
||||
public double DaysUntilReleaseFactor { get; protected set; }
|
||||
}
|
||||
|
||||
public class EasyDifficulty : DifficultySettings
|
||||
{
|
||||
public EasyDifficulty()
|
||||
{
|
||||
Difficulty = Difficulty.Easy;
|
||||
DaysUntilReleaseFactor = 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
public class MediumDifficulty : DifficultySettings
|
||||
{
|
||||
public MediumDifficulty()
|
||||
{
|
||||
Difficulty = Difficulty.Medium;
|
||||
DaysUntilReleaseFactor = 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
public class HardDifficulty : DifficultySettings
|
||||
{
|
||||
public HardDifficulty()
|
||||
{
|
||||
Difficulty = Difficulty.Hard;
|
||||
DaysUntilReleaseFactor = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DifficultyExtensions
|
||||
{
|
||||
public static DifficultySettings GetSettings(this Difficulty difficulty) => difficulty switch
|
||||
{
|
||||
Difficulty.Easy => new EasyDifficulty(),
|
||||
Difficulty.Medium => new MediumDifficulty(),
|
||||
Difficulty.Hard => new HardDifficulty(),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(difficulty), difficulty, null)
|
||||
};
|
||||
|
||||
public static string GetName(this Difficulty difficulty) =>
|
||||
difficulty switch
|
||||
{
|
||||
Difficulty.Easy => "Entspannt",
|
||||
Difficulty.Medium => "Normal",
|
||||
Difficulty.Hard => "Stressig",
|
||||
_ => "Unbekannt"
|
||||
};
|
||||
}
|
||||
}
|
||||
3
3d Prototyp/Assets/Scripts/Utility/Difficulty.cs.meta
Normal file
3
3d Prototyp/Assets/Scripts/Utility/Difficulty.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d5811ffae894b2ea0b1a25dbd30ec9f
|
||||
timeCreated: 1712259095
|
||||
33
3d Prototyp/Assets/Scripts/Utility/EndGameCondition.cs
Normal file
33
3d Prototyp/Assets/Scripts/Utility/EndGameCondition.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
|
||||
namespace Utility
|
||||
{
|
||||
[Flags]
|
||||
public enum EndGameCondition
|
||||
{
|
||||
Win = 0x01,
|
||||
Lose = 0x02,
|
||||
|
||||
Win_GamePublished = Win | 0x04,
|
||||
Lose_NoDevelopersLeft = Lose | 0x08,
|
||||
Lose_DeadlineMissed = Lose | 0x10
|
||||
}
|
||||
|
||||
public static class EndGameConditionExtension
|
||||
{
|
||||
public static bool IsWin(this EndGameCondition endGameCondition) =>
|
||||
endGameCondition.HasFlag(EndGameCondition.Win);
|
||||
|
||||
public static bool IsLose(this EndGameCondition endGameCondition) =>
|
||||
endGameCondition.HasFlag(EndGameCondition.Lose);
|
||||
|
||||
public static string GetEndGameMessage(this EndGameCondition endGameCondition) =>
|
||||
endGameCondition switch
|
||||
{
|
||||
EndGameCondition.Win_GamePublished => "Dein Spiel wurde erfolgreich veröffentlicht!",
|
||||
EndGameCondition.Lose_NoDevelopersLeft => "Oh nein, alle deine Entwickler sind weg!",
|
||||
EndGameCondition.Lose_DeadlineMissed => "Oh nein, du hast die Deadline verpasst!",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(endGameCondition), endGameCondition, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad1840e1e170446a86caf0e316b19b54
|
||||
timeCreated: 1712261399
|
||||
@ -25,5 +25,20 @@
|
||||
/// <param name="days">Die Anzahl an Tagen, die vergehen sollen.</param>
|
||||
public static Weekday GetFutureDay(this Weekday current, int days) =>
|
||||
(Weekday)(((int)current + days) % 7);
|
||||
|
||||
/// <summary>
|
||||
/// Gibt den deutschen Namen des Wochentags zurück.
|
||||
/// </summary>
|
||||
public static string GetName(this Weekday weekday) => weekday switch
|
||||
{
|
||||
Weekday.Monday => "Montag",
|
||||
Weekday.Tuesday => "Dienstag",
|
||||
Weekday.Wednesday => "Mittwoch",
|
||||
Weekday.Thursday => "Donnerstag",
|
||||
Weekday.Friday => "Freitag",
|
||||
Weekday.Saturday => "Samstag",
|
||||
Weekday.Sunday => "Sonntag",
|
||||
_ => "Unbekannt"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user