public void SetData(string saveString, params object[] otherData) { DummySave ds = JsonUtility.FromJson <DummySave>(saveString); ID = ds.ID; Random = ds.Random; IsMarkedTrash = ds.Trash; Level = ds.Level; SetValuesBasedOnRandom(); if (CreatedFromOriginal) { return; } Armor original; if (otherData[0] is PersistentSetItem) { PersistentSetItem allItems = (PersistentSetItem)otherData[0]; original = allItems.First(it => it.ID == ID) as Armor; } else { original = otherData[0] as Armor; } // Copy Original Values //OnAfterObtained(original); base.CopyValues(original); ArmorAtLevel0 = original.ArmorAtLevel0; ElementalWeakness = original.ElementalWeakness; }
public void SetData(string saveString, params object[] otherData) { DummySave ds = JsonUtility.FromJson <DummySave>(saveString); ID = ds.ID; Random = ds.Random; TapsWithWeapon.Value = ds.Taps; MarkedAsTrash = ds.Trash; Level = ds.Level; if (ds.EnchantID != -1 && CreatedFromOriginal) { Enchanter og = DataManager.Instance.AllItems.First(it => it.ID == ds.EnchantID) as Enchanter; Enchantment = Instantiate(og); Enchantment.CreatedFromOriginal = true; Enchantment.SetData(ds.EnchantSave, og); } SetValuesBasedOnRandom(); if (CreatedFromOriginal) { return; } Weapon original; if (otherData[0] is PersistentSetItem) { PersistentSetItem allItems = (PersistentSetItem)otherData[0]; original = allItems.First(it => it.ID == ID) as Weapon; } else { original = otherData[0] as Weapon; } // Copy Original Values base.CopyValues(original); DamageAtLevel0 = original.DamageAtLevel0; LevelUp = original.LevelUp; if (ds.EnchantID != -1) { Enchanter og = DataManager.Instance.AllItems.First(it => it.ID == ds.EnchantID) as Enchanter; Enchantment = Instantiate(og); Enchantment.CreatedFromOriginal = true; Enchantment.SetData(ds.EnchantSave, og); } }
public override void SetData(string saveString, params object[] otherData) { SaveObject ds = JsonUtility.FromJson <SaveObject>(saveString); ID = ds.ID; if (AllItems != null && ds.Entries != null) { Items.Clear(); foreach (string data in ds.Entries) { Items.Add(new SellableItem(data, AllItems)); } } FollowerData original; if (otherData[0] is PersistentSetFollowerData) { PersistentSetFollowerData allFollowers = (PersistentSetFollowerData)otherData[0]; original = allFollowers.First(it => it.ID == ID); } else { original = otherData[0] as FollowerData; if (SizeOfSprite == original.SizeOfSprite && SideIdleAnimation == original.SideIdleAnimation) { return; // This object may have been create based on the original. In which case, we don't need to do any copying } } ID = original.ID; SizeOfSprite = original.SizeOfSprite; SideIdleAnimation = original.SideIdleAnimation; RandomAnimation = original.RandomAnimation; MinTimeBetweenRandomAnims = original.MinTimeBetweenRandomAnims; MaxTimeBetweenRandomAnims = original.MaxTimeBetweenRandomAnims; AllItems = ((ShopFollower)original).AllItems; if (ds.Entries == null) { Items = ((ShopFollower)original).Items; } AfterCreated(); }
public void SetData(string saveString, params object[] otherData) { DummySave ds = JsonUtility.FromJson <DummySave>(saveString); ID = ds.ID; Level = ds.Level; RandomRoll = ds.RandomRoll; if (Level == -1) { Level = 1; } if (RandomRoll == -1) { RollMod(); } SetValuesBasedOnRandom(); if (CreatedFromOriginal) { return; } Headgear original; if (otherData[0] is PersistentSetItem) { PersistentSetItem allItems = (PersistentSetItem)otherData[0]; original = allItems.First(it => it.ID == ID) as Headgear; } else { original = otherData[0] as Headgear; } HealthGainedAtLevel0 = original.HealthGainedAtLevel0; // Copy Original Values base.CopyValues(original); }
public SellableItem(string data, PersistentSetItem allItems) { StringReader sr = new StringReader(data); int id = int.Parse(sr.ReadLine()); int amount = int.Parse(sr.ReadLine()); int level = int.Parse(sr.ReadLine()); string additionalInfo = sr.ReadLine(); Item original = allItems.First(it => it.ID == id); if (original is ISaveable) { Item = Instantiate(original); Item.CreatedFromOriginal = true; ((ISaveable)Item).SetData(additionalInfo, original); } else { Item = original; } Amount = amount; Level = level; }