Add actual ASCII-Art for distros, add first three distros and being able to choose a starting-distro. Update UI to fix multiple small bugs.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using KernelPanic.Data;
|
||||
|
||||
namespace KernelPanic.Meta
|
||||
{
|
||||
@@ -7,7 +9,23 @@ namespace KernelPanic.Meta
|
||||
/// </summary>
|
||||
public sealed class GachaService
|
||||
{
|
||||
private readonly List<DistroDefinition> bannerPool = new();
|
||||
|
||||
public int PullTokens => 0; // TODO: Replace with the real pull-token wallet when that meta system exists.
|
||||
public IReadOnlyList<DistroDefinition> BannerPool => bannerPool;
|
||||
|
||||
public event Action BannerPoolChanged;
|
||||
|
||||
public void AddToBannerPool(DistroDefinition distro)
|
||||
{
|
||||
if (distro == null || bannerPool.Contains(distro))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bannerPool.Add(distro);
|
||||
BannerPoolChanged?.Invoke();
|
||||
}
|
||||
|
||||
public GachaPullResult PerformPull(EntropyWallet wallet, int cost)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using KernelPanic.Data;
|
||||
using System;
|
||||
|
||||
namespace KernelPanic.Meta
|
||||
{
|
||||
/// <summary>
|
||||
/// Tracks player-owned persistent unlocks for menu presentation and collection views.
|
||||
/// </summary>
|
||||
public sealed class PlayerCollection
|
||||
{
|
||||
private readonly List<DistroDefinition> ownedUnits = new();
|
||||
|
||||
// TODO: Populate owned units from SaveService during bootstrap.
|
||||
// TODO: Add newly unlocked units from GachaService rewards when pulls exist.
|
||||
public IReadOnlyList<DistroDefinition> OwnedUnits => ownedUnits;
|
||||
|
||||
public event Action Changed;
|
||||
|
||||
public void Add(DistroDefinition unit)
|
||||
{
|
||||
if (unit == null || ownedUnits.Contains(unit))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Persistence is wired by the owner so this domain class stays IO-free.
|
||||
ownedUnits.Add(unit);
|
||||
Changed?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a10ff65b6e9478d9fe638f8a39f8144
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KernelPanic.Meta
|
||||
{
|
||||
@@ -7,22 +10,66 @@ namespace KernelPanic.Meta
|
||||
/// </summary>
|
||||
public sealed class SaveService
|
||||
{
|
||||
private const string SaveFileName = "kernel-panic-save.json";
|
||||
|
||||
public string SavePath => Path.Combine(Application.persistentDataPath, SaveFileName);
|
||||
|
||||
public void Save(SaveData data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
data ??= new SaveData();
|
||||
data.EnsureLists();
|
||||
|
||||
string directory = Path.GetDirectoryName(SavePath);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
string json = JsonUtility.ToJson(data, true);
|
||||
File.WriteAllText(SavePath, json);
|
||||
}
|
||||
|
||||
public SaveData Load()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (!File.Exists(SavePath))
|
||||
{
|
||||
return SaveData.CreateDefault();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SaveData data = JsonUtility.FromJson<SaveData>(File.ReadAllText(SavePath));
|
||||
data ??= SaveData.CreateDefault();
|
||||
data.EnsureLists();
|
||||
return data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Save file could not be loaded; starting fresh. {ex.Message}");
|
||||
return SaveData.CreateDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores persistent progression data for serialization.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class SaveData
|
||||
{
|
||||
public int EntropyBalance { get; set; }
|
||||
public bool starterChosen;
|
||||
public List<string> ownedUnitIds = new();
|
||||
public List<string> bannerPoolIds = new();
|
||||
|
||||
public static SaveData CreateDefault()
|
||||
{
|
||||
return new SaveData();
|
||||
}
|
||||
|
||||
public void EnsureLists()
|
||||
{
|
||||
ownedUnitIds ??= new List<string>();
|
||||
bannerPoolIds ??= new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user