コード例 #1
0
    public void LoadPlayerSaveData()
    {
        var regex = new Regex(@"(?<=[A-Z])(?=[A-Z][a-z])|(?<=[^A-Z])(?=[A-Z])");

        HP = ES3.Load("HP", 100.0f);
        SetHP(HP);

        string defaultSkill = "Healing Wave";

        string e1   = (string)ES3.Load("energySkill1.description", defaultValue: defaultSkill);
        int    e1Lv = ES3.Load("energySkill1.skillLevel", 0);

        string e2   = (string)ES3.Load("energySkill2.description", defaultValue: "Lightning");
        int    e2Lv = ES3.Load("energySkill2.skillLevel", 0);

        string s   = (string)ES3.Load("staminaSkill.description", defaultValue: "Locked Talent");
        int    sLv = ES3.Load("staminaSkill.skillLevel", 0);

        skills.PlayerId = ES3.Load("PlayerId", 2);

        foreach (var prop in skills.GetType().GetFields())
        {
            //Debug.LogFormat("{0}", prop.Name);
            var name = FirstLetterToUpper(regex.Replace(prop.Name, " "));
            if (name == e1)
            {
                var p = (PlayerSkills.BaseSkill)prop.GetValue(skills);
                energySkill1 = p;
                //Debug.Log(p.description);
                energySkill1.skillLevel = e1Lv;
                //Debug.Log(skills.warcry.skillLevel);
                //Debug.Log(p.GetType().GetProperty("description").GetValue(p));
            }
            else if (name == e2)
            {
                var p = (PlayerSkills.BaseSkill)prop.GetValue(skills);
                energySkill2            = p;
                energySkill2.skillLevel = e2Lv;
            }
            else if (name == s)
            {
                var p = (PlayerSkills.BaseSkill)prop.GetValue(skills);
                staminaSkill            = p;
                staminaSkill.skillLevel = sLv;
            }
        }
    }