コード例 #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);
    }
コード例 #2
0
 public static SavedConsumable ConvertFrom(Consumable consumable)
 {
     if (consumable == null)
     {
         var obj = new SavedConsumable {
             type     = ConsumableType.none,
             degree   = 0,
             quantity = 0
         };
         return(obj);
     }
     else
     {
         var obj = new SavedConsumable {
             type     = consumable.type,
             degree   = consumable.degree,
             quantity = consumable.quantity
         };
         return(obj);
     }
 }