Пример #1
0
        public void SetManMadeByJson(string js)
        {
            WeaponSave ws = Newtonsoft.Json.JsonConvert.DeserializeObject <WeaponSave>(js);

            Name       = ws.Wname;
            WeaponType = ws.Wtype;
            WeaponCards.Clear();
            foreach (var item in ws.Cards)
            {
                CardSave cardSave = Newtonsoft.Json.JsonConvert.DeserializeObject <CardSave>(item);
                WeaponCards.Add(cardSave.CreatAndSetCard());
            }
        }
Пример #2
0
        public InventorySave ToInventorySave()
        {
            InventorySave temp = new InventorySave();

            temp.InventoryName = GetType().Name;
            temp.InventoryCont = 1;
            WeaponSave ws = new WeaponSave();

            ws.Wname = Name;
            ws.Wtype = WeaponType;
            foreach (var item in WeaponCards)
            {
                ws.Cards.Add(item.ToCardSaveString());
            }

            temp.JsonString = Newtonsoft.Json.JsonConvert.SerializeObject(ws);
            return(temp);
        }
Пример #3
0
 public void LoadFromSave(WeaponSave save)
 {
     loaded      = true;
     this.rarity = save.rarity;
     for (int i = 0; i < colours.Length; i++)
     {
         colours[i] = new Color(save.colours[i].r, save.colours[i].g, save.colours[i].b);
     }
     WeaponAttribute[] temp = new WeaponAttribute[save.attributes.Length];
     for (int i = 0; i < temp.Length; i++)
     {
         temp[i] = new WeaponAttribute();
         temp[i].Create(save.attributes[i].type, save.attributes[i].value, this);
         temp[i].InitializeAttribute();
     }
     specialWeaponAttribute = GameManager.instance.WeaponAttributeDatabase.LoadSpecialWeaponAttribute(save.specialAttributeType);
     specialWeaponAttribute.InitializeAttribute(this);
     weaponAttributes = temp;
     OnLoad();
 }
Пример #4
0
    static GlobalSave CreateSaveObject()
    {
        GlobalSave globalSave = new GlobalSave();

        List <WeaponSave> weaponSaves = new List <WeaponSave>();

        foreach (Weapon weapon in CharacterCombat.instance.EquipedWeaponSlots)
        {
            if (weapon)
            {
                WeaponSave save = new WeaponSave();
                save.Init(weapon);
                weaponSaves.Add(save);
            }
        }
        globalSave.weaponSaves      = weaponSaves.ToArray();
        globalSave.slottedAbilities = new int[CharacterAbilityManager.instance.SlottedAbilities.Length];
        for (int i = 0; i < globalSave.slottedAbilities.Length; i++)
        {
            globalSave.slottedAbilities[i] = CharacterAbilityManager.instance.SlottedAbilities[i].abilityInfo.ID;
        }
        return(globalSave);
    }