/* Start asking the user for a storage device. This is asynchronous, and will * complete (with success or failure) sometime later. */ protected virtual void StartGettingStorageDevice() { if (!gettingDevice || retryGettingStorageDevice) { retryGettingStorageDevice = false; gettingDevice = true; if (StorageDeviceNeeded != null) { StorageDeviceNeeded(this, EventArgs.Empty); } else { if (Guide.IsVisible) { retryGettingStorageDevice = true; } else { try { Guide.BeginShowStorageDeviceSelector(SelectedStorage, null); } catch (System.Exception x) { Console.WriteLine("Swallowing BeginShow... exception: " + x.ToString()); retryGettingStorageDevice = true; } } } } }
protected override void Update(GameTime gameTime) { GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); if (gamePadState.Buttons.Back == ButtonState.Pressed) { this.Exit(); } KeyboardState keyState = Keyboard.GetState(); if (!Guide.IsVisible && !operationPending) { if (keyState.IsKeyDown(Keys.S) || (gamePadState.Buttons.B == ButtonState.Pressed)) { operationPending = true; Guide.BeginShowStorageDeviceSelector(FindStorageDevice, "saveRequest"); } if (keyState.IsKeyDown(Keys.L) || (gamePadState.Buttons.A == ButtonState.Pressed)) { operationPending = true; Guide.BeginShowStorageDeviceSelector(FindStorageDevice, "loadRequest"); } } gameData.Time += (float)gameTime.ElapsedGameTime.TotalSeconds; base.Update(gameTime); }
public static bool ReInit() { // If we have a device, it's unplugged, so throw it away and start over. Shutdown(); // Get the setup process started #if XBOX if (BokuGame.bokuGame != null) { if (!requestOpen && !Guide.IsVisible) { try { Guide.BeginShowStorageDeviceSelector(SelectDoneCallback, null); requestOpen = true; } catch { /// Probably the guide got opened but IsVisible wasn't /// set yet. We'll just try again later. } } } #else // PC is always playerOne if (!requestOpen) { Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, SelectDoneCallback, null); requestOpen = true; } #endif // Selection pending return(false); }
/// <summary> /// Shows the storage device selector. /// </summary> void SelectDevice() { Status = StorageProviderStatus.ShowSelector; if (Requirements.Player.HasValue == false) { if (Requirements.SizeInBytes == 0) { Guide.BeginShowStorageDeviceSelector( StorageDeviceDismissed, null); } else { Guide.BeginShowStorageDeviceSelector( Requirements.SizeInBytes, Requirements.DirectoryCount, StorageDeviceDismissed, null); } } else { if (Requirements.SizeInBytes == 0) { Guide.BeginShowStorageDeviceSelector( Requirements.Player.Value, StorageDeviceDismissed, null); } else { Guide.BeginShowStorageDeviceSelector( Requirements.Player.Value, Requirements.SizeInBytes, Requirements.DirectoryCount, StorageDeviceDismissed, null); } } }
private static void SelectStorage() { // Set the request flag if (!Guide.IsVisible) { device = null; result = Guide.BeginShowStorageDeviceSelector(GetDevice, null); } }
private void SaveHighScores() { if ((result == null) || (result.IsCompleted)) { result = Guide.BeginShowStorageDeviceSelector(null, null); } needToSaveHighScores = true; }
private StorageDevice GetStorageDevice() { storageResult = Guide.BeginShowStorageDeviceSelector(null, null); while (!storageResult.IsCompleted) { this.Tick(); } StorageDevice storageDevice = Guide.EndShowStorageDeviceSelector(storageResult); storageResult = null; return(storageDevice); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary>XBOX360ガイドを開始します。</summary> public override bool start() { bool bResult = false; if (!Guide.IsVisible) { try { Guide.BeginShowStorageDeviceSelector(callback, null); bResult = true; } catch (Exception e) { CLogger.add(e); } } return(bResult); }
//* ────________________________________* //* methods ───────────────────────────────-* //* -----------------------------------------------------------------------* /// <summary>XBOX360ガイドを開始します。</summary> public override bool start() { bool bResult = false; if (!Guide.IsVisible) { try { Guide.BeginShowStorageDeviceSelector(CALLBACK, null); bResult = true; } catch (Exception) { } } return(bResult); }
//* -----------------------------------------------------------------------* /// <summary> /// ストレージ セレクター ユーザー インターフェイスの表示を開始します。 /// </summary> /// /// <param name="callback"> /// 非同期操作が終了すると呼び出されるメソッド。 /// </param> /// <param name="state"> /// この要求を一意に識別するユーザー作成オブジェクト。 /// </param> /// <returns>メソッドの進行状況の追跡に使用されるオブジェクト。</returns> public IAsyncResult BeginShowStorageDeviceSelector(AsyncCallback callback, Object state) { IAsyncResult result = null; if (isAvaliableUseGamerService) { result = Guide.BeginShowStorageDeviceSelector(callback, state); } else { result = new CNullAsyncResult(state); callback(result); } return(result); }
/// <summary> /// Load the high scores from the drive. /// </summary> private static void LoadHighScores() { if ((MarbletsGame.StorageDevice != null) && MarbletsGame.StorageDevice.IsConnected) { LoadHighScoresCallback(null); } else { #if !MONOMAC Guide.BeginShowStorageDeviceSelector( new AsyncCallback(LoadHighScoresCallback), null); #endif } }
void OpenFile(string filename) { IAsyncResult result = null; SerializeUtils <GameVariables> gameVariables = new SerializeUtils <GameVariables>(); if (!Guide.IsVisible) { result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null); } if (result.IsCompleted) { StorageDevice device = Guide.EndShowStorageDeviceSelector(result); gameVariables.LoadData(device, filename); LoadVariables(gameVariables); } }
private void FindNameCabinet(PlayerIndex playerIndex, CabinetMode cabinetMode, string sFileName) { if (!Guide.IsVisible && !_operationPending) { _operationPending = true; if (cabinetMode == CabinetMode.Open) { Guide.BeginShowStorageDeviceSelector(playerIndex, FindNameStorageDevice, "loadRequest:" + sFileName); } if (cabinetMode == CabinetMode.Save) { Guide.BeginShowStorageDeviceSelector(playerIndex, FindNameStorageDevice, "saveRequest:" + sFileName); } } }
public void OpenLevel(string filename) { form.IncrementProgressBar(25); IAsyncResult result = null; SerializeUtils <LevelData> levelData = new SerializeUtils <LevelData>(); if (!Guide.IsVisible) { result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null); } if (result.IsCompleted) { StorageDevice device = Guide.EndShowStorageDeviceSelector(result); levelData.LoadData(device, filename); form.IncrementProgressBar(25); LoadLevel(levelData); } }
/// <summary> /// Derived classes should implement this method to call the Guide.BeginShowStorageDeviceSelector /// method with the desired parameters, using the given callback. /// </summary> /// <param name="callback">The callback to pass to Guide.BeginShowStorageDeviceSelector.</param> protected override void GetStorageDevice(AsyncCallback callback) { // gamers are required to be signed in to open a container and // save files. an exception is raised by OpenContainer if a user // is not signed in, but we want to be more proactive about this // and throw an exception before even prompting the user in case // a game doesn't happen to save a file while testing. this // should help games in peer review hit this exception more // easily in case the tester does not trigger the game to save // data on a profile that isn't signed in. if (SignedInGamer.SignedInGamers[Player] == null) { throw new InvalidOperationException(string.Format(playerException, Player)); } Guide.BeginShowStorageDeviceSelector(Player, callback, null); }
void BackgroundLoadContent() { // First thing we need to do is get a valid storage device for loading and saving // high scores. Since this is a background thread, we can block on it; rendering the guide // for Xbox 360 will happen on the main thread. IAsyncResult result = Guide.BeginShowStorageDeviceSelector(null, null); while (!result.IsCompleted) { } StorageDevice device = Guide.EndShowStorageDeviceSelector(result); ScreenManager.Game.Services.AddService(typeof(StorageDevice), device); ScreenManager.Game.Content.Load <object>("alien_hit"); ScreenManager.Game.Content.Load <object>("alien1"); ScreenManager.Game.Content.Load <object>("background"); ScreenManager.Game.Content.Load <object>("badguy_blue"); ScreenManager.Game.Content.Load <object>("badguy_green"); ScreenManager.Game.Content.Load <object>("badguy_orange"); ScreenManager.Game.Content.Load <object>("badguy_red"); ScreenManager.Game.Content.Load <object>("bullet"); ScreenManager.Game.Content.Load <object>("cloud1"); ScreenManager.Game.Content.Load <object>("cloud2"); ScreenManager.Game.Content.Load <object>("fire"); ScreenManager.Game.Content.Load <object>("gamefont"); ScreenManager.Game.Content.Load <object>("ground"); ScreenManager.Game.Content.Load <object>("hills"); ScreenManager.Game.Content.Load <object>("laser"); ScreenManager.Game.Content.Load <object>("menufont"); ScreenManager.Game.Content.Load <object>("moon"); ScreenManager.Game.Content.Load <object>("mountains_blurred"); ScreenManager.Game.Content.Load <object>("player_hit"); ScreenManager.Game.Content.Load <object>("scorefont"); ScreenManager.Game.Content.Load <object>("smoke"); ScreenManager.Game.Content.Load <object>("sun"); ScreenManager.Game.Content.Load <object>("tank"); ScreenManager.Game.Content.Load <object>("tank_fire"); ScreenManager.Game.Content.Load <object>("tank_tire"); ScreenManager.Game.Content.Load <object>("tank_top"); ScreenManager.Game.Content.Load <object>("title"); ScreenManager.Game.Content.Load <object>("titlefont"); }
//* -----------------------------------------------------------------------* /// <summary>設定データを補助記憶装置から読み出します。</summary> /// <remarks> /// XBOX360版ではアプリケーションとは非同期にダイアログが /// 表示されるので、出現中もアプリケーションは停止せず進行を続けます。 /// </remarks> public void load() { CLogger.add(string.Format(Resources.IO_INFO_LOADING, fileName, typeName)); CIOInfo info = CIOInfo.instance; if (info.deviceReady) { load(info.getPath(fileName)); } else { if (CGuideWrapper.instance == null) { Guide.BeginShowStorageDeviceSelector(onSelectedDevice, this); } else { CGuideWrapper.instance.BeginShowStorageDeviceSelector(onSelectedDevice, this); } } }
//* -----------------------------------------------------------------------* /// <summary>設定データを補助記憶装置から読み出します。</summary> /// <remarks> /// XBOX360版ではアプリケーションとは非同期にダイアログが /// 表示されるので、出現中もアプリケーションは停止せず進行を続けます。 /// </remarks> public void load() { CLogger.add(string.Format("{0}を{1}へ読込しています...。", fileName, typeName)); CIOInfo info = CIOInfo.instance; if (info.deviceReady) { load(info.getPath(fileName)); } else { if (CGuideWrapper.instance == null) { Guide.BeginShowStorageDeviceSelector(onSelectedDevice, this); } else { CGuideWrapper.instance.BeginShowStorageDeviceSelector(onSelectedDevice, this); } } }
void SaveVariables(string filename) { { IAsyncResult result = null; SerializeUtils <GameVariables> gameVariables2 = new SerializeUtils <GameVariables>(); gameVariables2.Data = gameVariables; if (!Guide.IsVisible) { result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null); } if (result.IsCompleted) { StorageDevice device = Guide.EndShowStorageDeviceSelector(result); if (device.IsConnected) { gameVariables2.SaveData(device, filename); } } } }
//* -----------------------------------------------------------------------* /// <summary> /// ストレージ セレクター ユーザー インターフェイスの表示を開始します。 /// </summary> /// /// <param name="callback"> /// 非同期操作が終了すると呼び出されるメソッド。 /// </param> /// <param name="state"> /// この要求を一意に識別するユーザー作成オブジェクト。 /// </param> /// <returns>メソッドの進行状況の追跡に使用されるオブジェクト。</returns> public IAsyncResult BeginShowStorageDeviceSelector(AsyncCallback callback, Object state) { IAsyncResult result = null; if (isAvaliableUseGamerService && !IsVisible) { try { result = Guide.BeginShowStorageDeviceSelector(callback, state); } catch (Exception e) { CLogger.add(e); } } else { result = new CNullAsyncResult(state); callback(result); } return(result); }
} // end of InitStorageContainer /// <summary> /// Callback for Guide.BeginShowStorageDeviceSelector(). /// </summary> /// <param name="result"></param> private static void SelectDoneCallback(IAsyncResult result) { requestOpen = false; storageDevice = Guide.EndShowStorageDeviceSelector(result); if (storageDevice != null) { if (!Storage.InitStorageContainer()) { // OpenContainer failed so try again. if (!requestOpen #if CLIENT && !GamerServices.IsGuideVisible #endif ) { try { Guide.BeginShowStorageDeviceSelector(SelectDoneCallback, null); requestOpen = true; } catch { /// Probably the guide got opened but IsVisible wasn't /// set yet. We'll just try again later. } } } } else { // The user chose <B> from the dialog. Inform user that they // must choose a storage device. Also allow them to quit. userChoseNoStorage = true; } } // end of SelectDoneCallback()
public IAsyncResult BeginShowStorageDeviceSelector(AsyncCallback callback, object state) { return(Guide.BeginShowStorageDeviceSelector(callback, state)); }
public IAsyncResult BeginShowStorageDeviceSelector(PlayerIndex player, AsyncCallback callback, object state) { return(Guide.BeginShowStorageDeviceSelector(player, callback, state)); }
public IAsyncResult BeginShowStorageDeviceSelector(PlayerIndex player, int sizeInBytes, int directoryCount, AsyncCallback callback, object state) { return(Guide.BeginShowStorageDeviceSelector(player, sizeInBytes, directoryCount, callback, state)); }
protected override void GetStorageDevice(AsyncCallback callback) { Guide.BeginShowStorageDeviceSelector(Player, callback, null); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allow the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { runGame = false; } // We need to load the game data if (GameLoadRequested) { if ((result != null) && result.IsCompleted) { device = Guide.EndShowStorageDeviceSelector(result); result = null; if ((device == null) || !device.IsConnected) { // Reset the request flag GameLoadRequested = false; } } if ((device != null) && device.IsConnected) { // Load game data GetSavedData(); // Reset the request flag GameLoadRequested = false; } } // Update sounds audioEngine.Update(); // Update input lastGamePadState = currentGamePadState; currentGamePadState = GamePad.GetState(PlayerIndex.One); lastKeyboardState = currentKeyboardState; currentKeyboardState = Keyboard.GetState(); // Wait 3 seconds until we start playing if (gameTime.TotalGameTime.Seconds > 3 && playingGame == false) { playingGame = true; // Get the storage device result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One, null, null); } // After 3 seconds play the game if (playingGame) { // Update the players Catapult playerCatapult.Update(gameTime); if (playerCatapult.CurrentState == CatapultState.Reset) { // reset background and log screenPosition = Vector2.Zero; endObjectPos.X = 1000; endObjectPos.Y = 500; } // Move background if (playerCatapult.CurrentState == CatapultState.ProjectileFlying) { screenPosition.X = (playerCatapult.PumpkinPosition.X - playerCatapult.PumpkinLaunchPosition) * -1.0f; endObjectPos.X = (playerCatapult.PumpkinPosition.X - playerCatapult.PumpkinLaunchPosition) * -1.0f + 1000; } // Calculate the pumpkin flying distance if (playerCatapult.CurrentState == CatapultState.ProjectileFlying || playerCatapult.CurrentState == CatapultState.ProjectileHit) { pumpkinDistance = playerCatapult.PumpkinPosition.X - playerCatapult.PumpkinLaunchPosition; pumpkinDistance /= 15.0f; } // Is this a high score if (highScore < pumpkinDistance) { highScore = (int)pumpkinDistance; } } // Exit game if (!runGame) { Exit(); } base.Update(gameTime); }