public void FinalizeCharacter() { var characterName = characterNameMenu.GetComponentInChildren <InputField>().text; if (characterName == "") { return; } var character = SavedCharacter.BrandNewCharacter(characterName, selectedFurType); character.strength = strength; character.dexterity = dexterity; character.constitution = constitution; character.intelligence = intelligence; character.wisdom = wisdom; character.luck = luck; //foreach (var attribute in selectedAbilities[3].attributes) { // if (attribute.type == "boostStat") { // switch ((string)attribute.FindParameter("stat").value) { // case "strength": // character.strength += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // case "dexterity": // character.dexterity += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // case "constitution": // character.constitution += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // case "intelligence": // character.intelligence += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // case "wisdom": // character.wisdom += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // case "luck": // character.luck += Mathf.FloorToInt((float)attribute.FindParameter("degree").value); // break; // } // } //} character.soulGemActives.Add(SavedActiveAbility.ConvertFrom((ActiveAbility)selectedAbilities[0])); character.soulGemActives.Add(SavedActiveAbility.ConvertFrom((ActiveAbility)selectedAbilities[1])); character.soulGemActives.Add(SavedActiveAbility.ConvertFrom((ActiveAbility)selectedAbilities[2])); character.soulGemPassive = SavedPassiveAbility.ConvertFrom((PassiveAbility)selectedAbilities[3]); BinaryFormatter bf = new BinaryFormatter(); if (!Directory.Exists(Application.persistentDataPath + "/characters")) { Directory.CreateDirectory(Application.persistentDataPath + "/characters"); } FileStream file = File.Create(Application.persistentDataPath + "/characters/" + characterName + ".character"); bf.Serialize(file, character); file.Close(); FinishCharacterCreation(); generatedAbilities = false; }
public static SavedAbility ConvertFrom(Ability ability) { if (ability is ActiveAbility) { return(SavedActiveAbility.ConvertFrom((ActiveAbility)ability)); } else { return(SavedPassiveAbility.ConvertFrom((PassiveAbility)ability)); } }
public static SavedPassiveAbility ConvertFrom(PassiveAbility ability) { var obj = new SavedPassiveAbility(); if (ability == null) { return(null); } obj.icon = ability.icon; obj.name = ability.name; obj.description = ability.description; obj.points = ability.points; obj.level = ability.level; obj.xp = ability.xp; obj.skillTree = SavedSkillTree.ConvertFrom(ability.skillTree); foreach (var attribute in ability.attributes) { obj.attributes.Add(SavedAbilityAttribute.ConvertFrom(attribute)); } return(obj); }