public override void Initialize() { base.Initialize(); #if WINDOWS || XBOX var shared = new SharedSaveDevice(); shared.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; shared.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; _sharedDevice = shared; #else _sharedDevice = new IsolatedStorageSaveDevice(); #endif _playerDevices = new Dictionary <PlayerIndex, IAsyncSaveDevice>(); for (int i = 0; i < 4; i++) { var playerIndex = (PlayerIndex)Enum.ToObject(typeof(PlayerIndex), i); #if WINDOWS || XBOX var playerDevice = new PlayerSaveDevice(playerIndex); playerDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; playerDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; #else var playerDevice = new IsolatedStorageSaveDevice(); #endif _playerDevices.Add(playerIndex, playerDevice); } }
public override void Initialize() { base.Initialize(); #if WINDOWS || XBOX var shared = new SharedSaveDevice(); shared.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; shared.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; _sharedDevice = shared; #else _sharedDevice = new IsolatedStorageSaveDevice(); #endif _playerDevices = new Dictionary<PlayerIndex, IAsyncSaveDevice>(); for (int i = 0; i < 4; i++) { var playerIndex = (PlayerIndex) Enum.ToObject(typeof (PlayerIndex), i); #if WINDOWS || XBOX var playerDevice = new PlayerSaveDevice(playerIndex); playerDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; playerDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; #else var playerDevice = new IsolatedStorageSaveDevice(); #endif _playerDevices.Add(playerIndex, playerDevice); } }
/// <summary> /// Constructor. /// </summary> public GameplayScreen(GameToPlay action) { TransitionOnTime = TimeSpan.FromSeconds(1.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); EasyStorageSettings.SetSupportedLanguages(Language.English); _saveDevice = new IsolatedStorageSaveDevice(); SaveGameGlobal.SaveDevice = _saveDevice; _saveDevice.SaveCompleted += SaveDeviceSaveCompleted; //This will be used for drag and drop operations EnabledGestures = GestureType.FreeDrag | GestureType.DragComplete | GestureType.Tap; CurrentGameToPlay = action; if (action == GameToPlay.NewGame) { Player.currentLevel = 1; } else if (action == GameToPlay.SurvivalGame) { Player.currentLevel = 0; } else { if (Player.currentLevel > 1) _doLoad = true; else _doLoad = false; } }
private void PromptMe() { // we can set our supported languages explicitly or we can allow the // game to support all the languages. the first language given will // be the default if the current language is not one of the supported // languages. this only affects the text found in message boxes shown // by EasyStorage and does not have any affect on the rest of the game. EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish); // on Windows Phone we use a save device that uses IsolatedStorage // on Windows and Xbox 360, we use a save device that gets a //shared StorageDevice to handle our file IO. #if WINDOWS_PHONE saveDevice = new IsolatedStorageSaveDevice(); Global.SaveDevice = saveDevice; // we use the tap gesture for input on the phone TouchPanel.EnabledGestures = GestureType.Tap; #else // create and add our SaveDevice SharedSaveDevice sharedSaveDevice = new SharedSaveDevice(); ScreenManager.Game.Components.Add(sharedSaveDevice); // make sure we hold on to the device saveDevice = sharedSaveDevice; // hook two event handlers to force the user to choose a new device if they cancel the // device selector or if they disconnect the storage device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; // prompt for a device on the first Update we can sharedSaveDevice.PromptForDevice(); sharedSaveDevice.DeviceSelected += (s, e) => { //Save our save device to the global counterpart, so we can access it //anywhere we want to save/load GameSettings.SaveDevice = (SaveDevice)s; //Once they select a storage device, we can load the main menu. //You'll notice I hard coded PlayerIndex.One here. You'll need to //change that if you plan on releasing your game. I linked to an //example on how to do that but here's the link if you need it. //http://blog.nickgravelyn.com/2009/03/basic-handling-of-multiple-controllers/ ScreenManager.AddScreen(new MainMenuScreen(), PlayerIndex.One); }; #endif #if XBOX // add the GamerServicesComponent ScreenManager.Game.Components.Add( new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(ScreenManager.Game)); #endif }
public IAsyncSaveDevice PreparePlayerDevice(PlayerIndex playerIndex) { IAsyncSaveDevice playerDevice = _playerDevices[playerIndex]; #if WINDOWS || XBOX ((PlayerSaveDevice)playerDevice).PromptForDevice(); #endif return(playerDevice); }
private void PromptMe() { // we can set our supported languages explicitly or we can allow the // game to support all the languages. the first language given will // be the default if the current language is not one of the supported // languages. this only affects the text found in message boxes shown // by EasyStorage and does not have any affect on the rest of the game. EasyStorageSettings.SetSupportedLanguages(Language.English); // on Windows Phone we use a save device that uses IsolatedStorage // on Windows and Xbox 360, we use a save device that gets a //shared StorageDevice to handle our file IO. // create and add our SaveDevice SharedSaveDevice sharedSaveDevice = new SharedSaveDevice(); ScreenManager.Game.Components.Add(sharedSaveDevice); // make sure we hold on to the device saveDevice = sharedSaveDevice; // hook two event handlers to force the user to choose a new device if they cancel the // device selector or if they disconnect the storage device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; // prompt for a device on the first Update we can sharedSaveDevice.PromptForDevice(); sharedSaveDevice.DeviceSelected += (s, e) => { //Save our save device to the global counterpart, so we can access it //anywhere we want to save/load Global.SaveDevice = (SaveDevice)s; //Once they select a storage device, we can load the main menu. //You'll notice I hard coded PlayerIndex.One here. You'll need to //change that if you plan on releasing your game. I linked to an //example on how to do that but here's the link if you need it. //<a href="http://blog.nickgravelyn.com/2009/03/basic-handling-of-multiple-controllers/">http://blog.nickgravelyn.com/2009/03/basic-handling-of-multiple-controllers/</a> ScreenManager.AddScreen(new MainMenuScreen(), null); }; #if XBOX // add the GamerServicesComponent ScreenManager.Game.Components.Add( new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(ScreenManager.Game)); #endif }
protected override void Initialize() { // we can set our supported languages explicitly or we can allow the // game to support all the languages. the first language given will // be the default if the current language is not one of the supported // languages. this only affects the text found in message boxes shown // by EasyStorage and does not have any affect on the rest of the game. EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish); // on Windows Phone we use a save device that uses IsolatedStorage // on Windows and Xbox 360, we use a save device that gets a shared StorageDevice to handle our file IO. #if WINDOWS_PHONE saveDevice = new IsolatedStorageSaveDevice(); #else // create and add our SaveDevice SharedSaveDevice sharedSaveDevice = new SharedSaveDevice(); Components.Add(sharedSaveDevice); // make sure we hold on to the device saveDevice = sharedSaveDevice; // hook two event handlers to force the user to choose a new device if they cancel the // device selector or if they disconnect the storage device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; // prompt for a device on the first Update we can sharedSaveDevice.PromptForDevice(); #endif // we use the tap gesture for input on the phone TouchPanel.EnabledGestures = GestureType.Tap; #if XBOX // add the GamerServicesComponent Components.Add(new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(this)); #endif // hook an event so we can see that it does fire saveDevice.SaveCompleted += new SaveCompletedEventHandler(saveDevice_SaveCompleted); base.Initialize(); }
protected override void Initialize() { // we can set our supported languages explicitly or we can allow the // game to support all the languages. the first language given will // be the default if the current language is not one of the supported // languages. this only affects the text found in message boxes shown // by EasyStorage and does not have any affect on the rest of the game. EasyStorageSettings.SetSupportedLanguages(Language.French, Language.Spanish); // on Windows Phone we use a save device that uses IsolatedStorage // on Windows and Xbox 360, we use a save device that gets a shared StorageDevice to handle our file IO. #if WINDOWS_PHONE saveDevice = new IsolatedStorageSaveDevice(); #else // create and add our SaveDevice SharedSaveDevice sharedSaveDevice = new SharedSaveDevice(); Components.Add(sharedSaveDevice); // make sure we hold on to the device saveDevice = sharedSaveDevice; // hook two event handlers to force the user to choose a new device if they cancel the // device selector or if they disconnect the storage device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; // prompt for a device on the first Update we can sharedSaveDevice.PromptForDevice(); #endif // we use the tap gesture for input on the phone TouchPanel.EnabledGestures = GestureType.Tap; #if XBOX // add the GamerServicesComponent Components.Add(new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(this)); #endif // hook an event so we can see that it does fire saveDevice.SaveCompleted += new SaveCompletedEventHandler(saveDevice_SaveCompleted); base.Initialize(); }
public void Initialize(Game game) { // create the save device SharedSaveDevice sharedSaveDevice = new SharedSaveDevice(); game.Components.Add(sharedSaveDevice); saveDevice = sharedSaveDevice; // create event handlers that force the user to choose a new device // if they cancel the device selector, or it they disconnect the storage // device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Nothing; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Prompt; // prompt for a device on the first update we can sharedSaveDevice.PromptForDevice(); #if XBOX game.Components.Add(new GamerServicesComponent(game)); #endif saveDevice.SaveCompleted += new SaveCompletedEventHandler(saveDevice_SaveCompleted); saveDevice.LoadCompleted += new LoadCompletedEventHandler(saveDevice_LoadCompleted); }
public override void LoadContent(ContentManager _content) { base.LoadContent(_content); TransitionOnTime = TimeSpan.FromSeconds(0f); TransitionOffTime = TimeSpan.FromSeconds(0f); LevelDataManager.UItextures.TryGetValue("Title", out menuTitleGraphic); isMenuTitleGraphic = true; menuTitleGraphicScale = 1.0f; textLength = ScreenManager.font.MeasureString(text) * textscale; video = LevelDataManager.tempContent.Load<Video>(@"Video\pw_intro2"); player = new VideoPlayer(); player.Play(video); // we can set our supported languages explicitly or we can allow the // game to support all the languages. the first language given will // be the default if the current language is not one of the supported // languages. this only affects the text found in message boxes shown // by EasyStorage and does not have any affect on the rest of the game. EasyStorageSettings.SetSupportedLanguages(Language.English, Language.French, Language.Spanish, Language.German, Language.Italian, Language.Japanese); // on Windows and Xbox 360, we use a save device that gets a //shared StorageDevice to handle our file IO. // create and add our SaveDevice sharedSaveDevice = new SharedSaveDevice(); ScreenManager.Game.Components.Add(sharedSaveDevice); // make sure we hold on to the device saveDevice = sharedSaveDevice; LevelDataManager.SaveDevice = saveDevice; // hook two event handlers to force the user to choose a new device if they cancel the // device selector or if they disconnect the storage device after selecting it sharedSaveDevice.DeviceSelectorCanceled += (s, e) => e.Response = SaveDeviceEventResponse.Force; sharedSaveDevice.DeviceDisconnected += (s, e) => e.Response = SaveDeviceEventResponse.Force; #if XBOX // add the GamerServicesComponent ScreenManager.Game.Components.Add( new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent(ScreenManager.Game)); #endif sharedSaveDevice.DeviceSelected += (s, e) => { LoadOptions(); LevelDataManager.ReadSaveGameData(); isPrompt = true; }; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //The InputManager instance automatically updates input Components.Add(InputManager.GetInstance(this)); //The facet manager will do the heavy lifting for event loops Components.Add(new FacetManager(this)); #if XBOX //Awesome 360 services. Allows for networking stuff. Components.Add(new GamerServicesComponent(this)); #endif //Let the SoundManager get at the game's ContentManager Components.Add(SoundManager.GetInstance(this)); #if WINDOWS && DEBUG //Set up for logging String path = System.IO.Path.GetTempPath() + "Chromathud\\chromathud.log"; Trace.Listeners.Add(new TextWriterTraceListener(path)); Trace.WriteLine("And, we're tracing."); #endif //Set up persistent storage EasyStorage.EasyStorageSettings.SetSupportedLanguages(EasyStorage.Language.English); SharedSaveDevice = new IsolatedStorageSaveDevice(); //Load game options, this is ASYNC Preferences.LoadAsync(SharedSaveDevice); base.Initialize(); }
private bool saveLeaderboard(IAsyncSaveDevice device) { if (device.IsReady) { device.SaveCompleted += new SaveCompletedEventHandler((sender, args) => { }); device.SaveAsync(ChromathudGame.Name, hsFileName(), stream => { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(List<Entry>)); ser.Serialize(stream, top10); }); return true; } return false; }
private List<Entry> checkLeaderboard(IAsyncSaveDevice device, out bool newScoreDidPlace) { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(List<Entry>)); try { device.Load(ChromathudGame.Name, hsFileName(), stream => { top10 = new List<Entry>((List<Entry>)ser.Deserialize(stream)); }); } catch (Exception e) { top10 = new List<Entry>(); } newScoreDidPlace = processLeaderboard(); return top10; }
public bool SaveLeaderboard(IAsyncSaveDevice device) { return saveLeaderboard(device); }
public List<Entry> CheckLeaderboard(IAsyncSaveDevice device) { return checkLeaderboard(device, out changed); }
public List<Entry> CheckAndSaveLeaderboard(IAsyncSaveDevice device) { top10 = checkLeaderboard(device, out changed); return top10; }