public override CharacterData GetCopy() { PlayerCharacterData copy = new PlayerCharacterData(); copy.Init(); copy.SetId(id); copy._skinColor = _skinColor; //it would be more proper to use SetSkinColor() but that requires changing from Color back to hex. copy.isDinnerBoy = isDinnerBoy; //this value belongs to the base class but it's more fitting to only copy it here CopyPrototypeValuesToInstance(copy); for (int i = 0; i < equipmentSlots.Count; i++) { copy.equipmentSlots.Add(new EquipmentSlot(equipmentSlots[i].itemType, equipmentSlots[i].slotNumber)); } return(copy); }
public static void CreatePlayerCharacters() { playerCollection = new Dictionary <string, PlayerCharacterData>(); //use this line to load data straight from a json file //PlayerCharacterMap map = Utils.LoadJsonFromPath<PlayerCharacterMap>(inPath); /* * {"id":"soda_junkie", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":1, "outfit":1, "accessory":0, "eyes": 1, "base_stats" : ["hp=10", "atk=1", "mp=5", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "yes", "can_only_hire_one_per_party":"no", "hire_cost":0, "purchase_prereqs" : ["TAVERN"], "skills":""}, * {"id":"tavern_owner", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":2, "outfit":2, "accessory":0, "eyes": 1, "base_stats" : ["hp=10", "atk=1", "mp=0", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "no", "can_only_hire_one_per_party":"no", "hire_cost":0, "purchase_prereqs" : ["SODA_OWNER"], "skills":""}, * {"id":"blacksmith", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":10, "outfit":16, "accessory":0, "eyes": 1, "base_stats" : ["hp=10", "atk=1", "mp=0", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "no", "can_only_hire_one_per_party":"no", "hire_cost":0, "purchase_prereqs" : ["SODA_BLACKSMITH"], "skills":""}, * {"id":"wizard", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":0, "outfit":20, "accessory":40, "eyes": 100, "base_stats" : ["hp=25", "atk=5", "mp=35", "spd=100"], "equippable_slots":"WSAII", "can_hire_in_tavern": "no", "can_only_hire_one_per_party":"yes", "hire_cost":750, "purchase_prereqs" : ["SODA_WIZARD"], "skills":"EVISCERATE, PRECOGNITION, MAGIC_MASTER"}, * {"id":"carpenter", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":1, "outfit":3, "accessory":1, "eyes": 2, "base_stats" : ["hp=13", "atk=1", "mp=10", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "yes", "can_only_hire_one_per_party":"no", "hire_cost":10, "purchase_prereqs" : ["SODA_CARPENTER"], "skills":"SWIFT_METAL"}, * {"id":"miner", "gender":"MALE", "body":1, "head":1, "mouth":1, "hands":1, "hair":1, "outfit":5, "accessory":4, "eyes": 2, "base_stats" : ["hp=11", "atk=2", "mp=20", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "yes", "can_only_hire_one_per_party":"no", "hire_cost":25, "purchase_prereqs" : ["SODA_MINER"], "skills":"PICKAXE, PROSPECTOR, EXCAVATOR"}, * {"id":"nurse", "gender":"FEMALE", "body":1, "head":1, "mouth":2, "hands":1, "hair":4, "outfit":4, "accessory":2, "eyes": 1, "base_stats" : ["hp=13", "atk=1", "mp=30", "spd=100"], "equippable_slots":"WSAI", "can_hire_in_tavern": "yes", "can_only_hire_one_per_party":"no", "hire_cost":40, "purchase_prereqs" : ["SODA_NURSE"], "skills":"FIRST_AID, BIOHAZARD"}, */ //instead, create the data manually //the following letters are used to indicate the type of equippable slot: /* * W = weapon * S = shield * A = armor * I = accessory item * */ var sodaJunkieData = new PlayerCharacterRow { id = CharId.SODA_JUNKIE, gender = "MALE", base_stats = new string[] { "hp=10", "atk=1", "mp=5", "spd=100" }, equippable_slots = "WSAI", skills = "" }; var carpenterData = new PlayerCharacterRow { id = CharId.CARPENTER, gender = "MALE", base_stats = new string[] { "hp=13", "atk=1", "mp=10", "spd=100" }, equippable_slots = "WSAI", skills = SkillId.SWIFT_METAL }; var nurseData = new PlayerCharacterRow { id = CharId.NURSE, gender = "FEMALE", base_stats = new string[] { "hp=13", "atk=1", "mp=30", "spd=100" }, equippable_slots = "WSAI", skills = SkillId.FIRST_AID + "," + SkillId.BIOHAZARD }; PlayerCharacterMap map = new PlayerCharacterMap(); map.player_characters = new PlayerCharacterRow[] { sodaJunkieData, carpenterData, nurseData }; PlayerCharacterRow row; PlayerCharacterData tempCharacter; Gender parsedGender; bool parsedCanHire; bool parsedCanOnlyHireOnePerParty; for (int i = 0; i < map.player_characters.Length; i++) { row = map.player_characters[i]; tempCharacter = new PlayerCharacterData(); tempCharacter.Init(); tempCharacter.SetId(row.id); tempCharacter.SetSpecies(Species.HUMAN); tempCharacter.SetBaseFaction(Faction.PLAYER); Stats.ParseArrayIntoStatObject(row.base_stats, tempCharacter.baseStats); parsedGender = (Gender)Enum.Parse(typeof(Gender), row.gender); parsedCanHire = (row.can_hire_in_tavern == "yes"); parsedCanOnlyHireOnePerParty = (row.can_only_hire_one_per_party == "yes"); tempCharacter.SetBaseAppearance(parsedGender, row.body, row.head, row.mouth, row.hands, row.hair, row.outfit, row.accessory, row.eyes); tempCharacter.SetHireInfo(parsedCanHire, row.hire_cost, parsedCanOnlyHireOnePerParty); //parse out equip slots ParseStringIntoEquipSlotsForCharacter(row.equippable_slots, tempCharacter); //purchase prereqs tempCharacter.purchasePrerequisites = row.purchase_prereqs; //skills if (row.skills.Length > 0) { tempCharacter.SetBaseSkills(row.skills.Split(',')); } //set defend flags for certain classes if (tempCharacter.id == CharId.SODA_JUNKIE || tempCharacter.id == CharId.DUAL_WIELD) { tempCharacter.SetFlags(CharacterFlags.CANT_DEFEND); } playerCollection.Add(tempCharacter.id, tempCharacter); characterCollection.Add(tempCharacter.id, tempCharacter); } }