public static Character GetCharacter(string characterName) { var character = JsonUtility.FromJson <Character>(PlayerPrefs.GetString(characterName, Constants.PpSerializeDefault)); character.Weapons = new List <Weapon>(); character.Weapons.Add(JsonUtility.FromJson <Weapon>(PlayerPrefs.GetString(characterName + Constants.PpWeapon1, Constants.PpSerializeDefault))); character.Weapons.Add(JsonUtility.FromJson <Weapon>(PlayerPrefs.GetString(characterName + Constants.PpWeapon2, Constants.PpSerializeDefault))); character.Skills = new List <Skill>(); character.Skills.Add(SkillsData.GetSkillFromName(PlayerPrefs.GetString(characterName + Constants.PpSkill1, Constants.PpSerializeDefault))); character.Skills.Add(SkillsData.GetSkillFromName(PlayerPrefs.GetString(characterName + Constants.PpSkill2, Constants.PpSerializeDefault))); character.Inventory = new List <InventoryItem>(); for (int i = 0; i < character.InventoryPlace; ++i) { var serialized = PlayerPrefs.GetString(characterName + Constants.PpInventoryItem + i, Constants.PpSerializeDefault); if (string.IsNullOrEmpty(serialized)) { continue; } var typeId = PlayerPrefs.GetInt(characterName + Constants.PpInventoryItem + i + "Type"); if (typeId == InventoryItemType.Weapon.GetHashCode()) { character.Inventory.Add(JsonUtility.FromJson <Weapon>(serialized)); } else if (typeId == InventoryItemType.Skill.GetHashCode()) { character.Inventory.Add(SkillsData.GetSkillFromName(serialized)); } else { character.Inventory.Add(ItemsData.GetItemFromName(serialized)); } } return(character); }
// ORC // public static Character GetBaseOrc(CharacterGender gender, bool isPlayer = false) { var tmpChar = new Character() { Race = CharacterRace.Orc, StrongAgainst = CharacterRace.Human, StrongIn = MapType.Mountains, Diet = Diet.Herbivorous, HpMax = 500, PaMax = 6, PmMax = 1, LevelingHealthPercent = 25, LevelingDamagePercent = 5, FavWeapons = new List <WeaponType> { WeaponType.GreatSword, WeaponType.Gauntlets }, Weapons = new List <Weapon> { WeaponsData.GetWeaponFromType(WeaponType.GreatSword, isPlayer), WeaponsData.GetWeaponFromType(WeaponType.Gauntlets, isPlayer) }, SkillsTypes = new List <SkillType> { SkillType.Racial, SkillType.NotRatial }, Skills = new List <Skill> { Random.Range(0, 2) == 0 ? SkillsData.GetSkillFromName(SkillsData.OrcSkillsNames[0]) : SkillsData.GetSkillFromName(SkillsData.OrcSkillsNames[1]) }, BodyParts = CreateBodyPartsFromRace(CharacterRace.Human, gender), Inventory = new List <InventoryItem> { ItemsData.GetRandomItem(isPlayer) }, InventoryPlace = 3, WeightLimit = 80, SleepHoursNeeded = 12, SleepRestorationPercent = 100, RunAwayPercent = 15, LootPercent = 15, CritChancePercent = 0 }; HandleGreatSword(tmpChar); return(tmpChar); }
// DWARF // public static Character GetBaseDwarf(CharacterGender gender, bool isPlayer = false) { var tmpChar = new Character() { Race = CharacterRace.Dwarf, StrongAgainst = CharacterRace.Orc, StrongIn = MapType.Mines, Diet = Diet.Omnivorous, HpMax = 350, PaMax = 6, PmMax = 2, LevelingHealthPercent = 10, LevelingDamagePercent = 20, FavWeapons = new List <WeaponType> { WeaponType.Hammer, WeaponType.Axe }, Weapons = new List <Weapon> { WeaponsData.GetWeaponFromType(WeaponType.Hammer, isPlayer), WeaponsData.GetWeaponFromType(WeaponType.Axe, isPlayer) }, SkillsTypes = new List <SkillType> { SkillType.Racial, SkillType.NotRatial }, Skills = new List <Skill> { Random.Range(0, 2) == 0 ? SkillsData.GetSkillFromName(SkillsData.DwarfSkillsNames[0]) : SkillsData.GetSkillFromName(SkillsData.DwarfSkillsNames[1]) }, BodyParts = CreateBodyPartsFromRace(CharacterRace.Human, gender), Inventory = new List <InventoryItem> { ItemsData.GetRandomItem(isPlayer) }, InventoryPlace = 4, WeightLimit = 60, SleepHoursNeeded = 7, SleepRestorationPercent = 75, RunAwayPercent = 10, LootPercent = 50, CritChancePercent = 0 }; HandleGreatSword(tmpChar); return(tmpChar); }