Files
TheGame/scripts/GameSeed.cs
Björn Blomberg 74062a37d6 Add localization support and refactor menus
- Implemented LocalizationManager for handling multiple languages.
- Updated LoadGameMenu, MainMenu, PauseMenu, and SettingsMenu to support localization.
- Added InstanceSelectionMenu for selecting game instances.
- Refactored SaveManager to handle new SaveInstance structure.
- Created SaveDialog for saving games with user-defined names.
- Enhanced SaveData to manage multiple save instances.
- Added error handling and logging for save/load operations.
- Updated UI elements to reflect localized text.
2025-10-17 14:22:21 +02:00

55 lines
1.6 KiB
C#

using System;
namespace TheGame
{
public class GameSeed
{
public string SeedValue { get; set; }
public DateTime CreatedDate { get; set; }
public string DisplayName { get; set; }
public GameSeed()
{
SeedValue = GenerateNewSeed();
CreatedDate = DateTime.Now;
DisplayName = $"Game {CreatedDate:yyyy-MM-dd HH:mm}";
}
public GameSeed(string customSeed, string displayName = "")
{
SeedValue = customSeed;
CreatedDate = DateTime.Now;
DisplayName = string.IsNullOrEmpty(displayName) ? $"Game {CreatedDate:yyyy-MM-dd HH:mm}" : displayName;
}
private static string GenerateNewSeed()
{
// Generera en 8-tecken seed baserad på timestamp och random
var random = new Random();
var timestamp = DateTime.Now.Ticks;
var combined = timestamp + random.Next(1000, 9999);
// Konvertera till hexadecimal och ta första 8 tecknen
return Math.Abs(combined).ToString("X")[..8];
}
public override string ToString()
{
return $"{DisplayName} (Seed: {SeedValue})";
}
public override bool Equals(object obj)
{
if (obj is GameSeed other)
{
return SeedValue.Equals(other.SeedValue);
}
return false;
}
public override int GetHashCode()
{
return SeedValue.GetHashCode();
}
}
}