/// <summary> /// Reads the 'TimeGateLevels.xml' files from the given profile and returns the content /// </summary> public CommandCenterEventArgs LoadTimeGateUpgradeLevels(string profilePath) { xmlLoader = XElement.Load(profilePath + "\\" + TimeGateLevelsFile); //<TimeGate1>0</TimeGate1> //means that there is no unlocked level in the first TimeGateUpgrade Category //<TimeGate1>1</TimeGate1> //means that the first unlocked level in the first TimeGateUpgrade Category is level1 //but no level is bought in this category, as level 1 is the first level //<TimeGate1>2</TimeGate1> //means that the first unlocked level in the first TimeGateUpgrade Category is level2 //and that level1 (the previous level) is bought //... //<TimeGate1>5</TimeGate1> //means that all levels have been bought in the first TimeGateUpgrade Category int level1 = Convert.ToInt32(xmlLoader.Element("TimeGate1").Value); int level2 = Convert.ToInt32(xmlLoader.Element("TimeGate2").Value); int level3 = Convert.ToInt32(xmlLoader.Element("TimeGate3").Value); int level4 = Convert.ToInt32(xmlLoader.Element("TimeGate4").Value); CommandCenterEventArgs timeGateArgs = new CommandCenterEventArgs(level1, level2, level3, level4); return(timeGateArgs); }
public void SaveTimeGateUpgradeLevels(string profilePath, CommandCenterEventArgs levels) { xmlSaver = new XmlDocument(); XmlNode node; XmlNode root = xmlSaver.CreateElement("root"); xmlSaver.AppendChild(root); node = xmlSaver.CreateElement("TimeGate1"); node.AppendChild(xmlSaver.CreateTextNode(levels.TimeGateUpgradeLevels[0].ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("TimeGate2"); node.AppendChild(xmlSaver.CreateTextNode(levels.TimeGateUpgradeLevels[1].ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("TimeGate3"); node.AppendChild(xmlSaver.CreateTextNode(levels.TimeGateUpgradeLevels[2].ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("TimeGate4"); node.AppendChild(xmlSaver.CreateTextNode(levels.TimeGateUpgradeLevels[3].ToString())); root.AppendChild(node); xmlSaver.Save(profilePath + "\\" + TimeGateLevelsFile); }
void commandCenter_OnEnterZone(object sender, CommandCenterEventArgs e) { commandCenter.Hide(); //-------- camera.ChangeResolution(e.ResolutionValue.X, e.ResolutionValue.Y); if (e.FullScreen == "On") { camera.Fullscreen = true; } else { camera.Fullscreen = false; } //-------- //preloader--- preloader.Width = this.Game.GraphicsDevice.PresentationParameters.BackBufferWidth; preloader.Height = this.Game.GraphicsDevice.PresentationParameters.BackBufferHeight; preloader.X = 0; preloader.Y = 0; //----------- camera_OnMove(null, null); //refreshes the gameInterface panels' positions according to the //new camera position IOManager.EnterZone(this, e); }
public void EnterZone(object sender, CommandCenterEventArgs args) { //the GameInterface_Graphics Graphics is loaded only once if (DisplayManager.GameInterfaceLoaded == false) LoadGameInterfaceGraphics(args.ZoneName); else DisplayManager.DisplayGame(); }
public void LoadProfile() { if (isNewProfile) //the profile will be created with the 'default' settings { isNewProfile = false; DirectoryInfo defaultDir = new DirectoryInfo(profilesFolder + "\\" + defaultProfileFolder); foreach (FileInfo defaultFile in defaultDir.GetFiles()) { if (Directory.Exists(profilesFolder + "\\" + currentProfileFolder) == false) { Directory.CreateDirectory(profilesFolder + "\\" + currentProfileFolder); } File.Copy(profilesFolder + "\\" + defaultProfileFolder + "\\" + defaultFile.Name, profilesFolder + "\\" + currentProfileFolder + "\\" + defaultFile.Name); } } //at this point the profile already exists (weather it has just been created or it already existed) //and it will be loaded CommandCenterEventArgs optionsPanelSettings = xmlData.LoadSettings(profilesFolder + "\\" + currentProfileFolder); CommandCenter.SetGameOptions(optionsPanelSettings); try { CommandCenter.OnSaveOptions -= new EventHandler <CommandCenterEventArgs>(CommandCenter_OnSaveOptions); } catch (Exception) { } CommandCenter.OnSaveOptions += new EventHandler <CommandCenterEventArgs>(CommandCenter_OnSaveOptions); ResetAutosaveTimer(CommandCenter.GetCurrentSettings.AutosaveTimeValue); //sound float volume = (float)optionsPanelSettings.VolumeValue; if (volume > 0) { volume /= 10; //maximum will be 0.9f } SoundManager.GeneralSoundVolume = volume; if (optionsPanelSettings.SoundState == "On") { SoundManager.SoundsOn = true; } else { SoundManager.SoundsOn = false; } CommandCenterEventArgs timeGatePanelLevels = xmlData.LoadTimeGateUpgradeLevels(profilesFolder + "\\" + currentProfileFolder); CommandCenter.SetTimeGateLevels(timeGatePanelLevels); List <CommandCenterEventArgs> zonesParameters = xmlData.LoadZonesParameters(profilesFolder + "\\" + currentProfileFolder); CommandCenter.SetZoneParameters(zonesParameters); CommandCenter.SetCurrentUser(currentProfileFolder); }
public void SaveGameAndZone(object sender, CommandCenterEventArgs args, List<Slot> _slots, MilleniumGoalsSet mg, List<Research> research) { DisplayManager.CameraFreeze(); DisplayManager.ShowPreloaderTimerMode(IOOperation.SavingGame); ProfileManager.SaveGame(args); ProfileManager.SaveHistory(_slots); ProfileManager.SaveZoneParameters(mg); ProfileManager.SaveZoneResearch(research); }
public void SaveGameAndZone(object sender, CommandCenterEventArgs args, List <Slot> _slots, MilleniumGoalsSet mg, List <Research> research) { DisplayManager.CameraFreeze(); DisplayManager.ShowPreloaderTimerMode(IOOperation.SavingGame); ProfileManager.SaveGame(args); ProfileManager.SaveHistory(_slots); ProfileManager.SaveZoneParameters(mg); ProfileManager.SaveZoneResearch(research); }
public void EnterZone(object sender, CommandCenterEventArgs args) { //the GameInterface_Graphics Graphics is loaded only once if (DisplayManager.GameInterfaceLoaded == false) { LoadGameInterfaceGraphics(args.ZoneName); } else { DisplayManager.DisplayGame(); } }
/// <summary> /// Reads the 'Settings.xml' file from the given profile and returns the content /// </summary> public CommandCenterEventArgs LoadSettings(string profilePath) { xmlLoader = XElement.Load(profilePath + "\\" + SettingsFile); int TimeValueIndex = Convert.ToInt32(xmlLoader.Element("TimeValueIndex").Value); string DifficultyLevel = xmlLoader.Element("DifficultyLevel").Value; int ResolutionValueIndex = Convert.ToInt32(xmlLoader.Element("ResolutionValueIndex").Value); string FullScreenState = xmlLoader.Element("FullScreenState").Value; int VolumeValue = Convert.ToInt32(xmlLoader.Element("VolumeValue").Value); string SoundState = xmlLoader.Element("SoundState").Value; int CameraSpeed = Convert.ToInt32(xmlLoader.Element("CameraSpeed").Value); CommandCenterEventArgs args = new CommandCenterEventArgs(ResolutionValueIndex, FullScreenState, TimeValueIndex, DifficultyLevel, VolumeValue,SoundState,CameraSpeed); return args; }
/// <summary> /// Reads the 'Settings.xml' file from the given profile and returns the content /// </summary> public CommandCenterEventArgs LoadSettings(string profilePath) { xmlLoader = XElement.Load(profilePath + "\\" + SettingsFile); int TimeValueIndex = Convert.ToInt32(xmlLoader.Element("TimeValueIndex").Value); string DifficultyLevel = xmlLoader.Element("DifficultyLevel").Value; int ResolutionValueIndex = Convert.ToInt32(xmlLoader.Element("ResolutionValueIndex").Value); string FullScreenState = xmlLoader.Element("FullScreenState").Value; int VolumeValue = Convert.ToInt32(xmlLoader.Element("VolumeValue").Value); string SoundState = xmlLoader.Element("SoundState").Value; int CameraSpeed = Convert.ToInt32(xmlLoader.Element("CameraSpeed").Value); CommandCenterEventArgs args = new CommandCenterEventArgs(ResolutionValueIndex, FullScreenState, TimeValueIndex, DifficultyLevel, VolumeValue, SoundState, CameraSpeed); return(args); }
/// <summary> /// Saves the settings to the 'Settings.xml' file from the given profile /// </summary> public void SaveSettings(string profilePath, CommandCenterEventArgs settings) { xmlSaver = new XmlDocument(); XmlNode node; XmlNode root = xmlSaver.CreateElement("root"); xmlSaver.AppendChild(root); node = xmlSaver.CreateElement("TimeValueIndex"); node.AppendChild(xmlSaver.CreateTextNode(settings.TimeValueIndex.ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("DifficultyLevel"); node.AppendChild(xmlSaver.CreateTextNode(settings.DifficultyLevel)); root.AppendChild(node); node = xmlSaver.CreateElement("ResolutionValueIndex"); node.AppendChild(xmlSaver.CreateTextNode(settings.ResolutionIndex.ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("FullScreenState"); node.AppendChild(xmlSaver.CreateTextNode(settings.FullScreen)); root.AppendChild(node); node = xmlSaver.CreateElement("VolumeValue"); node.AppendChild(xmlSaver.CreateTextNode(settings.VolumeValue.ToString())); root.AppendChild(node); node = xmlSaver.CreateElement("SoundState"); node.AppendChild(xmlSaver.CreateTextNode(settings.SoundState)); root.AppendChild(node); node = xmlSaver.CreateElement("CameraSpeed"); node.AppendChild(xmlSaver.CreateTextNode(settings.CameraSpeed.ToString())); root.AppendChild(node); xmlSaver.Save(profilePath + "\\" + SettingsFile); }
/// <summary> /// Saves the options to the Settings xml /// </summary> void CommandCenter_OnSaveOptions(object sender, CommandCenterEventArgs e) { //CommandCenter.OnSaveOptions -= new EventHandler<CommandCenterEventArgs>(CommandCenter_OnSaveOptions); ResetAutosaveTimer(e.AutosaveTimeValue); //sound float volume = (float)e.VolumeValue; if (volume > 0) { volume /= 10; //maximum will be 0.9f } SoundManager.GeneralSoundVolume = volume; if (e.SoundState == "On") { SoundManager.SoundsOn = true; } else { SoundManager.SoundsOn = false; } xmlData.SaveSettings(profilesFolder + "\\" + currentProfileFolder, e); }
public void SaveGame(object sender, CommandCenterEventArgs args) { DisplayManager.CameraFreeze(); DisplayManager.ShowPreloaderTimerMode(IOOperation.SavingGame); ProfileManager.SaveGame(args); }
/// <summary> /// Reads the 'TimeGateLevels.xml' files from the given profile and returns the content /// </summary> public CommandCenterEventArgs LoadTimeGateUpgradeLevels(string profilePath) { xmlLoader = XElement.Load(profilePath + "\\" + TimeGateLevelsFile); //<TimeGate1>0</TimeGate1> //means that there is no unlocked level in the first TimeGateUpgrade Category //<TimeGate1>1</TimeGate1> //means that the first unlocked level in the first TimeGateUpgrade Category is level1 //but no level is bought in this category, as level 1 is the first level //<TimeGate1>2</TimeGate1> //means that the first unlocked level in the first TimeGateUpgrade Category is level2 //and that level1 (the previous level) is bought //... //<TimeGate1>5</TimeGate1> //means that all levels have been bought in the first TimeGateUpgrade Category int level1 = Convert.ToInt32(xmlLoader.Element("TimeGate1").Value); int level2 = Convert.ToInt32(xmlLoader.Element("TimeGate2").Value); int level3 = Convert.ToInt32(xmlLoader.Element("TimeGate3").Value); int level4 = Convert.ToInt32(xmlLoader.Element("TimeGate4").Value); CommandCenterEventArgs timeGateArgs = new CommandCenterEventArgs(level1, level2, level3, level4); return timeGateArgs; }
void commandCenter_OnEnterZone(object sender, CommandCenterEventArgs e) { commandCenter.Hide(); //-------- camera.ChangeResolution(e.ResolutionValue.X, e.ResolutionValue.Y); if (e.FullScreen == "On") camera.Fullscreen = true; else camera.Fullscreen = false; //-------- //preloader--- preloader.Width = this.Game.GraphicsDevice.PresentationParameters.BackBufferWidth; preloader.Height = this.Game.GraphicsDevice.PresentationParameters.BackBufferHeight; preloader.X = 0; preloader.Y = 0; //----------- camera_OnMove(null, null); //refreshes the gameInterface panels' positions according to the //new camera position IOManager.EnterZone(this, e); }
/// <summary> /// Saves the current profile's time gate upgrades /// </summary> public void SaveGame(CommandCenterEventArgs timeGateUpgrades) { xmlData.SaveTimeGateUpgradeLevels(profilesFolder + "\\" + currentProfileFolder, timeGateUpgrades); }
void commandCenter_OnSaveGame(object sender, CommandCenterEventArgs e) { IOManager.SaveGame(sender, e); }
/// <summary> /// Reads the 'Zones.xml' files from the given profile and returns the content /// </summary> public List <CommandCenterEventArgs> LoadZonesParameters(string profilePath) { zoneEventArgs = new List <CommandCenterEventArgs>(); xmlLoader = XElement.Load(profilePath + "\\" + ZonesFile); IEnumerable <XElement> zones = from element in xmlLoader.Elements() select element; foreach (XElement zone in zones) { double Energy_Quantum = Convert.ToDouble(zone.Element("Energy_Quantum").Value); Energy_Quantum = Energy_Quantum * 100; if (Energy_Quantum > 100) { Energy_Quantum = 100; } if (Energy_Quantum < 0) { Energy_Quantum = 0; } double Education_Quantum = Convert.ToDouble(zone.Element("Education_Quantum").Value); Education_Quantum = Education_Quantum * 100; if (Education_Quantum > 100) { Education_Quantum = 100; } if (Education_Quantum < 0) { Education_Quantum = 0; } double Economy_Quantum = Convert.ToDouble(zone.Element("Economy_Quantum").Value); Economy_Quantum = Economy_Quantum * 100; if (Economy_Quantum > 100) { Economy_Quantum = 100; } if (Economy_Quantum < 0) { Economy_Quantum = 0; } double Environment_Quantum = Convert.ToDouble(zone.Element("Environment_Quantum").Value); Environment_Quantum = Environment_Quantum * 100; if (Environment_Quantum > 100) { Environment_Quantum = 100; } if (Environment_Quantum < 0) { Environment_Quantum = 0; } double Health_Quantum = Convert.ToDouble(zone.Element("Health_Quantum").Value); Health_Quantum = Health_Quantum * 100; if (Health_Quantum > 100) { Health_Quantum = 100; } if (Health_Quantum < 0) { Health_Quantum = 0; } double Food_Quantum = Convert.ToDouble(zone.Element("Food_Quantum").Value); Food_Quantum = Food_Quantum * 100; if (Food_Quantum > 100) { Food_Quantum = 100; } if (Food_Quantum < 0) { Food_Quantum = 0; } CommandCenterEventArgs zoneArgs = new CommandCenterEventArgs(Energy_Quantum, Education_Quantum, Economy_Quantum, Environment_Quantum, Health_Quantum, Food_Quantum); zoneEventArgs.Add(zoneArgs); } return(zoneEventArgs); }
/// <summary> /// Reads the 'Zones.xml' files from the given profile and returns the content /// </summary> public List<CommandCenterEventArgs> LoadZonesParameters(string profilePath) { zoneEventArgs = new List<CommandCenterEventArgs>(); xmlLoader = XElement.Load(profilePath + "\\" + ZonesFile); IEnumerable<XElement> zones = from element in xmlLoader.Elements() select element; foreach (XElement zone in zones) { double Energy_Quantum = Convert.ToDouble(zone.Element("Energy_Quantum").Value); Energy_Quantum = Energy_Quantum * 100; if (Energy_Quantum > 100) Energy_Quantum = 100; if (Energy_Quantum < 0) Energy_Quantum = 0; double Education_Quantum = Convert.ToDouble(zone.Element("Education_Quantum").Value); Education_Quantum = Education_Quantum * 100; if (Education_Quantum > 100) Education_Quantum = 100; if (Education_Quantum < 0) Education_Quantum = 0; double Economy_Quantum = Convert.ToDouble(zone.Element("Economy_Quantum").Value); Economy_Quantum = Economy_Quantum * 100; if (Economy_Quantum > 100) Economy_Quantum = 100; if (Economy_Quantum < 0) Economy_Quantum = 0; double Environment_Quantum = Convert.ToDouble(zone.Element("Environment_Quantum").Value); Environment_Quantum = Environment_Quantum * 100; if (Environment_Quantum > 100) Environment_Quantum = 100; if (Environment_Quantum < 0) Environment_Quantum = 0; double Health_Quantum = Convert.ToDouble(zone.Element("Health_Quantum").Value); Health_Quantum = Health_Quantum * 100; if (Health_Quantum > 100) Health_Quantum = 100; if (Health_Quantum < 0) Health_Quantum = 0; double Food_Quantum = Convert.ToDouble(zone.Element("Food_Quantum").Value); Food_Quantum = Food_Quantum * 100; if (Food_Quantum > 100) Food_Quantum = 100; if (Food_Quantum < 0) Food_Quantum = 0; CommandCenterEventArgs zoneArgs = new CommandCenterEventArgs(Energy_Quantum,Education_Quantum,Economy_Quantum,Environment_Quantum,Health_Quantum,Food_Quantum); zoneEventArgs.Add(zoneArgs); } return zoneEventArgs; }