Initial commit: Star of Words Unity project
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>
This commit is contained in:
commit
ecb1c9edea
1455 changed files with 933295 additions and 0 deletions
45
Assets/Scripts/WordPair.cs
Normal file
45
Assets/Scripts/WordPair.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue