public PickUpSpellSaveData(string tag, string name, bool isDestroyed, SpellSaveData spell) { this.tag = tag; this.gameName = name; this.isDestroyed = isDestroyed; this.spell = spell; }
private Spell SaveDataToSpell(SpellSaveData spellInfo) { if (spellInfo == null) { return(null); } var spell = UnitySpell.StringToSpell(UnitySpell.TypeToString[spellInfo.type]); spell.Name = spellInfo.name; spell.Description = spellInfo.description; spell.Power = spellInfo.power; Texture2D tex = new Texture2D(spellInfo.spriteX, spellInfo.spriteY); ImageConversion.LoadImage(tex, spellInfo.spriteBytes); Sprite mySprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), Vector2.one); spell.SpellSprite = mySprite; // spell.SpellSprite = Resources.Load<Sprite>(spellInfo.spritePath); // artifactInfo.gameName = artifact.unityShell.gameObject.name; spell.IsFightOnly = spellInfo.isFightOnly; spell.Used = spellInfo.used; return(spell); }
private SpellSaveData SpellToSaveData(Spell spell) { var spellInfo = new SpellSaveData(); spellInfo.type = spell.GetType().ToString(); Texture2D texture = spell.SpellSprite.texture; spellInfo.spriteBytes = ImageConversion.EncodeToPNG(texture); spellInfo.spriteX = spell.SpellSprite.texture.width; spellInfo.spriteY = spell.SpellSprite.texture.height; if (spell.unityShell != null) { spellInfo.gameName = spell.unityShell.gameObject.name; } spellInfo.name = spell.Name; spellInfo.description = spell.Description; spellInfo.hasPower = spell.HasPower; spellInfo.power = (int)spell.Power; spellInfo.isFightOnly = spell.IsFightOnly; spellInfo.used = spell.Used; spellInfo.cost = (int)spell.Cost; return(spellInfo); }