Files
bansonic_beta_main/Assets/scripts/_runtimecache/ExpBottleCatalog.cs
T

106 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
public static class ExpBottleCatalog
{
private static readonly ExpBottleDescriptor[] Descriptors =
{
new ExpBottleDescriptor(ExpBottleKind.Common, "exp_common", "凡品经验瓶", "commonExpBottle78001"),
new ExpBottleDescriptor(ExpBottleKind.Medium, "exp_medium", "中品经验瓶", "mediumExpBottle78002"),
new ExpBottleDescriptor(ExpBottleKind.Superior, "exp_superior", "上品经验瓶", "superiorExpBottle78003"),
new ExpBottleDescriptor(ExpBottleKind.Supreme, "exp_supreme", "极品经验瓶", "supremeExpBottle78004"),
new ExpBottleDescriptor(ExpBottleKind.Extraordinary, "exp_extraordinary", "绝品经验瓶", "extraordinaryExpBottle78005"),
new ExpBottleDescriptor(ExpBottleKind.Celestial, "exp_celestial", "仙品经验瓶", "celestialExpBottle78006"),
new ExpBottleDescriptor(ExpBottleKind.RainAll, "exp_rain_all", "雨露均沾", null),
new ExpBottleDescriptor(ExpBottleKind.AdvancedRainAll, "exp_rain_all_advanced", "高级雨露均沾", null),
new ExpBottleDescriptor(ExpBottleKind.SuperRainAll, "exp_rain_all_super", "超级雨露均沾", null)
};
private static readonly Dictionary<ExpBottleKind, ExpBottleDescriptor> ByKind = BuildByKind();
private static readonly Dictionary<string, ExpBottleDescriptor> ByKey = BuildByKey();
public static IReadOnlyList<ExpBottleDescriptor> All
{
get { return Descriptors; }
}
public static string GetKey(ExpBottleKind kind)
{
return ByKind[kind].Key;
}
public static string GetDisplayName(ExpBottleKind kind)
{
return ByKind[kind].DisplayName;
}
public static bool TryGetKind(string key, out ExpBottleKind kind)
{
kind = default(ExpBottleKind);
if (string.IsNullOrEmpty(key))
{
return false;
}
ExpBottleDescriptor descriptor;
if (!ByKey.TryGetValue(key, out descriptor))
{
return false;
}
kind = descriptor.Kind;
return true;
}
public static bool TryGetLegacyFieldName(ExpBottleKind kind, out string fieldName)
{
fieldName = null;
ExpBottleDescriptor descriptor;
if (!ByKind.TryGetValue(kind, out descriptor) || string.IsNullOrEmpty(descriptor.LegacyPlayerFieldName))
{
return false;
}
fieldName = descriptor.LegacyPlayerFieldName;
return true;
}
private static Dictionary<ExpBottleKind, ExpBottleDescriptor> BuildByKind()
{
var map = new Dictionary<ExpBottleKind, ExpBottleDescriptor>();
for (int i = 0; i < Descriptors.Length; i++)
{
map[Descriptors[i].Kind] = Descriptors[i];
}
return map;
}
private static Dictionary<string, ExpBottleDescriptor> BuildByKey()
{
var map = new Dictionary<string, ExpBottleDescriptor>(StringComparer.Ordinal);
for (int i = 0; i < Descriptors.Length; i++)
{
map[Descriptors[i].Key] = Descriptors[i];
}
return map;
}
}
public sealed class ExpBottleDescriptor
{
public ExpBottleDescriptor(ExpBottleKind kind, string key, string displayName, string legacyPlayerFieldName)
{
Kind = kind;
Key = key;
DisplayName = displayName;
LegacyPlayerFieldName = legacyPlayerFieldName;
}
public ExpBottleKind Kind { get; private set; }
public string Key { get; private set; }
public string DisplayName { get; private set; }
public string LegacyPlayerFieldName { get; private set; }
}