public class TestScript {
public enum User
{
Name,
Hp,
Mp,
Skill,
};
private Dictionary<User, string> dic = new Dictionary<User, string> {
{User.Name, "taro" },
{User.Hp, "100" },
{User.Mp, "200" },
{User.Skill, "kick" },
};
public enum Setting
{
IsVisible = 0,
IsAuto,
IsSkip,
IsSave,
Max
};
private BitArray flags = new BitArray((int)Setting.Max, false);
public string this[User type]
{
set { dic[type] = value; }
get { return dic[type]; }
}
public bool this[Setting type]
{
set { flags[(int)type] = value; }
get { return flags[(int)type]; }
}
}
void Start () {
var v = new TestScript();
v[TestScript.User.Name] = "hoge";
v[TestScript.User.Hp] = "1000";
Debug.Log(v[TestScript.User.Name]);
Debug.Log(v[TestScript.User.Hp]);
Debug.Log(v[TestScript.User.Mp]);
Debug.Log(v[TestScript.User.Skill]);
v[TestScript.Setting.IsVisible] = true;
v[TestScript.Setting.IsAuto] = true;
v[TestScript.Setting.IsSave] = true;
Debug.Log(v[TestScript.Setting.IsVisible]);
Debug.Log(v[TestScript.Setting.IsAuto]);
Debug.Log(v[TestScript.Setting.IsSkip]);
Debug.Log(v[TestScript.Setting.IsSave]);
}