Hello,
I’m trying to work on an award system, the first award I’m working on is “completing a level” award.
At the end of the level, a menu pops up saying congrats - you’ve completed this level. This then sets a boolean called “CompleteAward” to true. So when I go back to my main menu, under my award menu, I can see my award is unlocked (completed). This all works great, but I can’t seem to save this boolean’s status.
The weird thing is, is that I’m using the same system for ‘Game Stats’ - which basically tells you how many enemies you’ve killed throughout the game - and this works, it saves and loads.
The only difference I am using between the two are PlayerPrefs and PlayerPrefsX (which allow me to save booleans). I just cant understand why it wont save/load the PrefsX.
Okay, well here is a snippet of my pop up end of level menu: (Menu.js) - this is in my LEVEL
function OnGUI(){
if(Controller.RoundComplete == true && paused){
// ---- Review Awards ---- \\
// complete map
if(saveComplete){
CompleteAward();
saveComplete = false;
}
}
// Continue Button \\
if(GUI.Button(Rect(Screen.width/2 - 400/2 ,Screen.height-300, 400, 100), "Continue")){
Time.timeScale = 1;
// Game Stats \\
PlayerPrefs.SetInt("Credits.XP", Credits.XP);
PlayerPrefs.SetInt("TurretStats.turretsPlace", TurretStats.turretsPlace);
PlayerPrefs.SetInt("TurretStats.turretsDestroyed", TurretStats.turretsDestroyed);
PlayerPrefs.SetInt("TurretStats.turretsRepaired", TurretStats.turretsRepaired);
PlayerPrefs.SetInt("TurretStats.turretsUpgrades", TurretStats.turretsUpgrades);
// Award Stats \\
PlayerPrefsX.SetBool("MapStats.mapOne.CompleteAwards", MapStats.mapOne.CompleteAwards);
Application.LoadLevel (0 + 1);
}
}
private var saveComplete : boolean = true;
function CompleteAward(){
var externalSpawn = FindObjectOfType(Spawn);
var externalStat = FindObjectOfType(MapStats);
if(externalSpawn.MapSelected == 1){
MapStats.mapOne.CompleteAwards = true;
//PlayerPrefsX.SetBool("externalStat.mapOne.CompleteAwards", externalStat.mapOne.CompleteAwards);
}
}
Here is my MapStats (basically holds the info for my awards): - this is on my MAIN MENU
class MapOne {
static var CompleteAwards : boolean;
static var DefenderAwards : boolean;
static var BuilderAwards : boolean;
static var WageAwards : boolean;
static var PeakAwards : boolean;
}
static var mapOne : MapOne = MapOne();
function Awake(){
mapOne.CompleteAwards = PlayerPrefsX.GetBool("mapOne.CompleteAwards");
}
Can someone please help me out here.
Thanks