Snapshot of the existing Unity 6 language-learning word game before any refactoring. Adds Unity .gitignore and .gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
978 B
C#
45 lines
978 B
C#
using System;
|
|
using System.Reflection;
|
|
|
|
[Serializable]
|
|
public class WordPair
|
|
{
|
|
public string tr;
|
|
public string en;
|
|
public string es;
|
|
public string de;
|
|
public string fr;
|
|
public string pt;
|
|
|
|
private const string DefaultLang = "en";
|
|
|
|
public WordPair(string tr, string en, string es, string de, string fr, string pt)
|
|
{
|
|
this.tr = tr;
|
|
this.en = en;
|
|
this.es = es;
|
|
this.de = de;
|
|
this.fr = fr;
|
|
this.pt = pt;
|
|
}
|
|
|
|
public string GetByCode(string code)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(code))
|
|
code = DefaultLang;
|
|
|
|
string safe = code.ToLower();
|
|
|
|
FieldInfo f = this.GetType().GetField(safe);
|
|
if (f != null)
|
|
{
|
|
string val = f.GetValue(this) as string;
|
|
if (!string.IsNullOrEmpty(val))
|
|
return val;
|
|
}
|
|
|
|
return GetByCode(DefaultLang);
|
|
}
|
|
|
|
public string Get(string code) => GetByCode(code);
|
|
}
|