/* * Initialise * * reads all of the saved data from the achievements file (or makes the file) * and initialises the passed in masked list * * @param MaskedStringList - the display object for the achievements * @returns void */ public static void Initialise(MaskedStringList list) { string path = Application.dataPath + "/achivements.bin"; //don't load data if it has already been loaded if (AchievementsTracker.m_firstStart) { //if the file exists, load it else make a new one if (File.Exists(path)) { //open a file stream to the stats.dat file FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read); //get the binary reader for the file BinaryReader br = new BinaryReader(file); //read all of the variables form the file outOfTheGates = bool.Parse(br.ReadString()); br.ReadString(); firstBlood = bool.Parse(br.ReadString()); br.ReadString(); ohBaby = bool.Parse(br.ReadString()); br.ReadString(); bigDaddy = bool.Parse(br.ReadString()); br.ReadString(); highMotor = bool.Parse(br.ReadString()); br.ReadString(); bigDaddy = bool.Parse(br.ReadString()); br.ReadString(); digitalMassacre = bool.Parse(br.ReadString()); br.ReadString(); efficientDoctor = bool.Parse(br.ReadString()); br.ReadString(); notThatBad = bool.Parse(br.ReadString()); br.ReadString(); file.Close(); } else { WriteData(); } AchievementsTracker.m_firstStart = false; } //display name of the item value to give the item display type of the item (whole number, decimal, time stamp) list.names.Add("Out of the Gates - Play One Game"); list.values.Add(ConvertBoolToFloat(outOfTheGates)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("First Blood - Kill One Enemy"); list.values.Add(ConvertBoolToFloat(firstBlood)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("Oh Baby - Kill Three Enemies in One Turn"); list.values.Add(ConvertBoolToFloat(ohBaby)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("BigDaddy- Invoke the BIGDADDY Protocool"); list.values.Add(ConvertBoolToFloat(bigDaddy)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("Digital Massacre - defeat an AI of the highest difficulty"); list.values.Add(ConvertBoolToFloat(digitalMassacre)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("Efficient Doctor - Heal more than 400 health per turn on average"); list.values.Add(ConvertBoolToFloat(efficientDoctor)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); list.names.Add("Not That Bad - Play for an hour"); list.values.Add(ConvertBoolToFloat(notThatBad)); list.displayTypes.Add(MaskedStringList.DisplayType.ENABLE); }
/* * Initialise * * reads all of the saved data from the stats file (or makes the file) * and initialises the passed in masked list * * @param MaskedStringList - the display object for the statistics * @returns void */ public static void Initialise(MaskedStringList list) { string path = Application.dataPath + "/stats.bin"; //don't load data if it has already been loaded if (StatisticsTracker.m_firstStart) { //if the file exists, load it else make a new one if (File.Exists(path)) { //open a file stream to the stats.dat file FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read); //get the binary reader for the file BinaryReader br = new BinaryReader(file); //read all of the variables form the file gamesPlayed = int.Parse(br.ReadString()); br.ReadString(); unitsDefeated = int.Parse(br.ReadString()); br.ReadString(); gamesPlayed = int.Parse(br.ReadString()); br.ReadString(); turnsPlayed = int.Parse(br.ReadString()); br.ReadString(); turnsPerGame = float.Parse(br.ReadString()); br.ReadString(); healingPerTurn = float.Parse(br.ReadString()); br.ReadString(); damagePerTurn = float.Parse(br.ReadString()); br.ReadString(); timeSpentPlaying = float.Parse(br.ReadString()); br.ReadString(); totalHealing = float.Parse(br.ReadString()); br.ReadString(); totalDamage = float.Parse(br.ReadString()); br.ReadString(); mostUnitsDamagedWithOneAttack = int.Parse(br.ReadString()); br.ReadString(); mostUnitsDefeatedInASingleTurn = int.Parse(br.ReadString()); br.ReadString(); tilesCrossed = int.Parse(br.ReadString()); file.Close(); } else { WriteData(); } StatisticsTracker.m_firstStart = false; } CalculateAverages(); //display name of the item value to give the item display type of the item (whole number, decimal, time stamp) list.names.Add("Games Played"); list.values.Add(gamesPlayed); list.displayTypes.Add(MaskedStringList.DisplayType.INT); list.names.Add("Units Defeated"); list.values.Add(unitsDefeated); list.displayTypes.Add(MaskedStringList.DisplayType.INT); list.names.Add("Turns Played"); list.values.Add(turnsPlayed); list.displayTypes.Add(MaskedStringList.DisplayType.INT); list.names.Add("Turns Per Game"); list.values.Add(turnsPerGame); list.displayTypes.Add(MaskedStringList.DisplayType.FLOAT); list.names.Add("Healing Per Turn"); list.values.Add(healingPerTurn); list.displayTypes.Add(MaskedStringList.DisplayType.FLOAT); list.names.Add("Damage Per Turn"); list.values.Add(damagePerTurn); list.displayTypes.Add(MaskedStringList.DisplayType.FLOAT); list.names.Add("Time Spent Playing"); list.values.Add(timeSpentPlaying); list.displayTypes.Add(MaskedStringList.DisplayType.TIME); list.names.Add("Total Healing"); list.values.Add(totalHealing); list.displayTypes.Add(MaskedStringList.DisplayType.FLOAT); list.names.Add("Total Damage"); list.values.Add(totalDamage); list.displayTypes.Add(MaskedStringList.DisplayType.FLOAT); list.names.Add("Most Units Damaged in a Single Attack"); list.values.Add(mostUnitsDamagedWithOneAttack); list.displayTypes.Add(MaskedStringList.DisplayType.INT); list.names.Add("Most Units Defeated in a Single Turn"); list.values.Add(mostUnitsDefeatedInASingleTurn); list.displayTypes.Add(MaskedStringList.DisplayType.INT); list.names.Add("Tiles Crossed"); list.values.Add(tilesCrossed); list.displayTypes.Add(MaskedStringList.DisplayType.INT); }