Beispiel #1
0
    public static SavedCharacter ConvertFrom(GameObject go)
    {
        var pc        = go.GetComponent <PlayerCharacter>();
        var character = go.GetComponent <Character>();
        var au        = go.GetComponent <AbilityUser>();
        var obj       = new SavedCharacter {
            xp                = pc.GetComponent <ExperienceGainer>().xp,
            level             = pc.GetComponent <ExperienceGainer>().level,
            xpToLevel         = pc.GetComponent <ExperienceGainer>().xpToLevel,
            gold              = pc.gold,
            weapon            = SavedWeapon.ConvertFrom(pc.weapon),
            armor             = SavedArmor.ConvertFrom(pc.armor),
            necklace          = SavedNecklace.ConvertFrom(pc.necklace),
            belt              = SavedBelt.ConvertFrom(pc.belt),
            cloak             = SavedCloak.ConvertFrom(pc.cloak),
            earring           = SavedEarring.ConvertFrom(pc.earring),
            hat               = SavedHat.ConvertFrom(pc.hat),
            shoes             = SavedShoes.ConvertFrom(pc.shoes),
            soulGemPassive    = SavedAbility.ConvertFrom(au.soulGemPassive),
            currentAbility    = character.GetComponent <InputController>().currentAbility,
            currentAltAbility = character.GetComponent <InputController>().currentAltAbility,
            sparePoints       = pc.GetComponent <ExperienceGainer>().sparePoints,
            strength          = (int)CharacterAttribute.attributes["strength"].instances[character].BaseValue,
            dexterity         = (int)CharacterAttribute.attributes["dexterity"].instances[character].BaseValue,
            constitution      = (int)CharacterAttribute.attributes["constitution"].instances[character].BaseValue,
            intelligence      = (int)CharacterAttribute.attributes["intelligence"].instances[character].BaseValue,
            wisdom            = (int)CharacterAttribute.attributes["wisdom"].instances[character].BaseValue,
            luck              = (int)CharacterAttribute.attributes["luck"].instances[character].BaseValue,
            resurrectionTimer = au.resurrectionTimer,
            name              = pc.GetComponent <PlayerSyncer>().characterName,
            furType           = pc.GetComponent <PlayerSyncer>().furType
        };

        obj.bracelets[0] = SavedBracelet.ConvertFrom(pc.bracelets[0]);
        obj.bracelets[1] = SavedBracelet.ConvertFrom(pc.bracelets[1]);
        obj.bracelets[2] = SavedBracelet.ConvertFrom(pc.bracelets[2]);
        obj.bracelets[3] = SavedBracelet.ConvertFrom(pc.bracelets[3]);
        foreach (var consumable in pc.consumables)
        {
            obj.consumables.Add(SavedConsumable.ConvertFrom(consumable));
        }
        foreach (var ability in au.soulGemActives)
        {
            obj.soulGemActives.Add(SavedAbility.ConvertFrom(ability));
        }
        foreach (var ability in au.soulGemActivesOverflow)
        {
            obj.soulGemActivesOverflow.Add(SavedAbility.ConvertFrom(ability));
        }
        foreach (var ability in au.soulGemPassivesOverflow)
        {
            obj.soulGemPassivesOverflow.Add(SavedAbility.ConvertFrom(ability));
        }
        return(obj);
    }
Beispiel #2
0
 public static SavedItem ConvertFrom(Item item)
 {
     if (item is Weapon)
     {
         return(SavedWeapon.ConvertFrom((Weapon)item));
     }
     if (item is Armor)
     {
         return(SavedArmor.ConvertFrom((Armor)item));
     }
     if (item is Belt)
     {
         return(SavedBelt.ConvertFrom((Belt)item));
     }
     if (item is Bracelet)
     {
         return(SavedBracelet.ConvertFrom((Bracelet)item));
     }
     if (item is Cloak)
     {
         return(SavedCloak.ConvertFrom((Cloak)item));
     }
     if (item is Earring)
     {
         return(SavedEarring.ConvertFrom((Earring)item));
     }
     if (item is Hat)
     {
         return(SavedHat.ConvertFrom((Hat)item));
     }
     if (item is Necklace)
     {
         return(SavedNecklace.ConvertFrom((Necklace)item));
     }
     if (item is Shoes)
     {
         return(SavedShoes.ConvertFrom((Shoes)item));
     }
     return(null);
 }