Exemplo n.º 1
0
 void Awake()
 {
     if (Game.PlayerCharacter == null)
     {
         Game.PlayerCharacter = new Character(CharacterDef.Get("Widow Tarha"), ClassDef.Get("Necromancer"));
         //Game.PlayerCharacter.AddItem(ItemDef.Get("Steel Broadsword"));
         //Game.PlayerCharacter.AddItem(ItemDef.Get("Light Hammer"));
     }
 }
Exemplo n.º 2
0
    public Character(string saveStr)
    {
        var str = saveStr.Split('\n');

        int i = 0;

        if (int.TryParse(str[i], out int numPlayers))
        {
            NumPlayers = numPlayers;
        }
        else
        {
            Debug.LogWarning("Failed to initialize character!");
            return;
        }

        ++i;
        if (int.TryParse(str[i], out int act))
        {
            Act = act;
        }
        else
        {
            Debug.LogWarning("Failed to initialize character!");
            return;
        }

        Init();

        ++i;
        Definition = CharacterDef.Get(str[i]);

        ++i;
        Class = ClassDef.Get(str[i]);

        ++i;
        Damage = int.Parse(str[i]);

        ++i;
        Fatigue = int.Parse(str[i]);

        // Equipped
        ++i;
        var splitNames = str[i].Split(DELIMITER);

        foreach (var itemName in splitNames)
        {
            var item = ItemDef.Get(itemName);
            if (item != null)
            {
                AddItem(item);
                EquipItem(item);                 // unnecessary, but just in case
            }
        }

        // Unequipped
        ++i;
        splitNames = str[i].Split(DELIMITER);
        foreach (var itemName in splitNames)
        {
            var item = ItemDef.Get(itemName);
            if (item != null)
            {
                AddItem(item);
                UnequipItem(item);                 // unnecessary, but just in case
            }
        }

        // Skills
        ++i;
        splitNames = str[i].Split(DELIMITER);
        foreach (var skillName in splitNames)
        {
            var skill = SkillDef.Get(skillName);
            if (skill != null)
            {
                LearnSkill(skill);
            }
        }

        // Conditions
        ++i;
        splitNames = str[i].Split(DELIMITER);
        foreach (var condName in splitNames)
        {
            if (System.Enum.TryParse(condName, out Condition condition))
            {
                Conditions.Add(condition);
            }
        }
    }