Here is the Save function:
public void Save()
{
var Personal=new JSONObject
{
{"Name" , PlayerName},
{"Gender" , Gender },
{"Body Type" , BodyType},
{"Alignment" , Alignment},
{"Guild" , Guild },
{"Rank" , Rank },
{"Form" , Form},
{"Health" , Health},
{"Hunger" , Hunger},
{"Thirst", Thirst},
{"Intoxication" , Intoxication},
{"Fatigue" ,Fatigue},
{"Encumbrance" , Encumbrance},
{"Experience" , Experience}
};
var Stats = new JSONObject
{
{"Constitution" , Constitution},
{"Strength" , Strength},
{"Stamina" , Stamina},
{"Dexterity" , Dexterity},
{"Intelligence" , Intelligence},
{"Wisdom" , Wisdom},
{"Focus" , Focus},
{"BattleSpeed" , Battlespeed}
};
var Vitals = new JSONObject
{
{"Life" , Life},
{"Energy" , Energy},
{"Endurance", Endurance}
};
var Skills = new JSONObject
{
{"Light Melee Weapons" , LightMeleeWeapons},
{"Medium Melee Weapons" , MediumMeleeWeapons},
{"Heavy Melee Weapons" , HeavyMeleeWeapons},
{"Light Ranged Weapons" , LightRangedWeapons},
{"Medium Ranged Weapons" , MediumRangedWeapons},
{"Heavy Ranged Weapons" , HeavyRangedWeapons},
{"Light Armor" ,LightArmor},
{"Medium Armor" ,MediumArmor},
{"Heavy Armor" , HeavyArmor},
{"Holy Armor" , HolyArmor},
{"Holy Weapon",HolyWeapon},
{"Wicked Armor" ,WickedArmor},
{"Wicked Weapon",WickedWeapon},
{"Block", Block},
{"Parry" , Parry},
{"Evade" , Evade},
{"Critical Hit" ,CriticalHit}
};
var Money = new JSONObject
{
{"Copper" , Copper},
{"Silver" , Silver},
{"Gold" , Gold}
};
var Location = new JSONObject
{
{"Map", Application.loadedLevel},
{"X" , CoordX},
{"Y" , CoordY},
{"Z" , CoordZ}
// {"Rotation" , Rotation}
};
Debug.Log("Saved X" + CoordX);
Debug.Log("Saved Y" + CoordY);
Debug.Log("Saved Z" + CoordZ);
var Player = new JSONObject
{
{"Personal" , Personal},
{"Stats" , Stats},
{"Vitals" , Vitals},
{"Skills" , Skills},
{"Money" , Money},
{"Location", Location}
};
Debug.Log(Player);
File.WriteAllText(Application.dataPath + "/Player.json", Player.ToString());
}
I wanted to set it up so that depending on where you were facing it would move you off the trigger on either x, y, or z. That’s what the switch/case was all about. Also wanted to swing the player around so they are facing 180 degrees from the trigger(door) as if they came out. If that makes more sense.