41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BlockOutReplica.Infrastructure
|
|
{
|
|
public static class OriginalLevelSettings
|
|
{
|
|
[Serializable] public sealed class Entry
|
|
{
|
|
public int levelIndex;
|
|
public bool isHard;
|
|
public bool isSuperHard;
|
|
public int levelDuration;
|
|
public string seedId;
|
|
}
|
|
[Serializable] private sealed class Config { public Entry[] levelConfigModels; }
|
|
private static Entry[] all;
|
|
public static IReadOnlyList<Entry> All
|
|
{
|
|
get
|
|
{
|
|
if (all == null)
|
|
{
|
|
var asset = Resources.Load<TextAsset>("OriginalFlow/LevelsConfig");
|
|
if (asset == null) throw new InvalidOperationException("Missing original LevelsConfig");
|
|
all = JsonUtility.FromJson<Config>(asset.text).levelConfigModels;
|
|
if (all == null || all.Length < 20) throw new InvalidOperationException("Incomplete original level settings");
|
|
Array.Sort(all, (a,b) => a.levelIndex.CompareTo(b.levelIndex));
|
|
}
|
|
return all;
|
|
}
|
|
}
|
|
public static Entry Find(string seed)
|
|
{
|
|
foreach (var entry in All) if (entry.seedId == seed) return entry;
|
|
return null;
|
|
}
|
|
}
|
|
}
|