Kaynağa Gözat

Changes to reimplement the NetworkSession code that was removed, due to 3.8 not supporting networking.

Dominique Louis 3 hafta önce
ebeveyn
işleme
9b4b723ae7
50 değiştirilmiş dosya ile 1169 ekleme ve 1219 silme
  1. BIN
      CatapultNetWars/.vs/CatapultNetWars/CopilotIndices/17.14.827.52834/CodeChunks.db
  2. BIN
      CatapultNetWars/.vs/CatapultNetWars/CopilotIndices/17.14.827.52834/SemanticSymbols.db
  3. BIN
      CatapultNetWars/.vs/CatapultNetWars/DesignTimeBuild/.dtbcache.v2
  4. BIN
      CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/49d23628-12d3-4bc7-8656-be73c2a581d3.vsidx
  5. BIN
      CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/716e22fe-36c9-458e-aaee-8dd2ac754a85.vsidx
  6. BIN
      CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/7a76b7c6-e5b4-4273-a849-5045e046ee5d.vsidx
  7. BIN
      CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/baa70943-8efe-433a-92c4-55d5070c2a88.vsidx
  8. BIN
      CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/dbacc244-7e21-4105-8601-60c698589134.vsidx
  9. BIN
      CatapultNetWars/.vs/CatapultNetWars/v17/.futdcache.v2
  10. 0 49
      CatapultNetWars/.vs/CatapultNetWars/v17/DocumentLayout.backup.json
  11. 0 49
      CatapultNetWars/.vs/CatapultNetWars/v17/DocumentLayout.json
  12. BIN
      CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.metadata.v9.bin
  13. BIN
      CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.projects.v9.bin
  14. BIN
      CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.strings.v9.bin
  15. 0 0
      CatapultNetWars/CatapultGame.cs
  16. 39 28
      CatapultNetWars/Core/Catapult/CatapultGame.cs
  17. 1 1
      CatapultNetWars/Core/CatapultNetWars.Core.csproj
  18. 0 1
      CatapultNetWars/Core/Networking/AvailableSessionMenuEntry.cs
  19. 14 0
      CatapultNetWars/Core/Networking/CatapultNetWars.code-workspace
  20. 28 21
      CatapultNetWars/Core/Networking/CreateOrFindSessionScreen.cs
  21. 15 15
      CatapultNetWars/Core/Networking/JoinSessionScreen.cs
  22. 89 97
      CatapultNetWars/Core/Networking/LobbyScreen.cs
  23. 89 61
      CatapultNetWars/Core/Networking/NetworkBusyScreen.cs
  24. 0 1
      CatapultNetWars/Core/Networking/NetworkErrorScreen.cs
  25. 19 14
      CatapultNetWars/Core/Networking/NetworkSessionComponent.cs
  26. 16 17
      CatapultNetWars/Core/Networking/OperationCompletedEventArgs.cs
  27. 1 2
      CatapultNetWars/Core/Networking/ProfileSignInScreen.cs
  28. 0 1
      CatapultNetWars/Core/Players/Human.cs
  29. 226 298
      CatapultNetWars/Core/Resources.Designer.cs
  30. 1 2
      CatapultNetWars/Core/ScreenManager/GameScreen.cs
  31. 2 2
      CatapultNetWars/Core/ScreenManager/InputState.cs
  32. 10 7
      CatapultNetWars/Core/ScreenManager/MenuEntry.cs
  33. 1 1
      CatapultNetWars/Core/ScreenManager/MenuScreen.cs
  34. 1 1
      CatapultNetWars/Core/ScreenManager/MouseGestureType.cs
  35. 1 1
      CatapultNetWars/Core/ScreenManager/PlayerIndexEventArgs.cs
  36. 1 1
      CatapultNetWars/Core/ScreenManager/ScreenManager.cs
  37. 0 1
      CatapultNetWars/Core/Screens/BackgroundScreen.cs
  38. 437 330
      CatapultNetWars/Core/Screens/GameplayScreen.cs
  39. 10 61
      CatapultNetWars/Core/Screens/InstructionsScreen.cs
  40. 101 90
      CatapultNetWars/Core/Screens/LoadingScreen.cs
  41. 25 32
      CatapultNetWars/Core/Screens/MainMenuScreen.cs
  42. 2 19
      CatapultNetWars/Core/Screens/MessageBoxScreen.cs
  43. 13 16
      CatapultNetWars/Core/Screens/PauseScreen.cs
  44. 27 0
      CatapultNetWars/Core/Utility/UIUtility.cs
  45. 0 0
      CatapultNetWars/Platforms/Android/MainActivity.cs
  46. 0 0
      CatapultNetWars/Platforms/Android/Program.cs
  47. 0 0
      CatapultNetWars/Screens/GameplayScreen.cs
  48. 0 0
      CatapultNetWars/Screens/LoadingScreen.cs
  49. 0 0
      CatapultNetWars/Screens/MainMenuScreen.cs
  50. 0 0
      CatapultNetWars/Screens/PauseScreen.cs

BIN
CatapultNetWars/.vs/CatapultNetWars/CopilotIndices/17.14.827.52834/CodeChunks.db


BIN
CatapultNetWars/.vs/CatapultNetWars/CopilotIndices/17.14.827.52834/SemanticSymbols.db


BIN
CatapultNetWars/.vs/CatapultNetWars/DesignTimeBuild/.dtbcache.v2


BIN
CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/49d23628-12d3-4bc7-8656-be73c2a581d3.vsidx


BIN
CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/716e22fe-36c9-458e-aaee-8dd2ac754a85.vsidx


BIN
CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/7a76b7c6-e5b4-4273-a849-5045e046ee5d.vsidx


BIN
CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/baa70943-8efe-433a-92c4-55d5070c2a88.vsidx


BIN
CatapultNetWars/.vs/CatapultNetWars/FileContentIndex/dbacc244-7e21-4105-8601-60c698589134.vsidx


BIN
CatapultNetWars/.vs/CatapultNetWars/v17/.futdcache.v2


+ 0 - 49
CatapultNetWars/.vs/CatapultNetWars/v17/DocumentLayout.backup.json

@@ -1,49 +0,0 @@
-{
-  "Version": 1,
-  "WorkspaceRootPath": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\",
-  "Documents": [
-    {
-      "AbsoluteMoniker": "D:0:0:{B2676159-C59D-CA93-EBBC-F1984D0F95A5}|Platforms\\Windows\\CatapultNetWars.Windows.csproj|c:\\users\\savag\\source\\repos\\cartblanche\\monogame\\monogame-samples\\catapultnetwars\\platforms\\windows\\catapultnetwars.windows.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
-      "RelativeMoniker": "D:0:0:{B2676159-C59D-CA93-EBBC-F1984D0F95A5}|Platforms\\Windows\\CatapultNetWars.Windows.csproj|solutionrelative:platforms\\windows\\catapultnetwars.windows.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
-    }
-  ],
-  "DocumentGroupContainers": [
-    {
-      "Orientation": 0,
-      "VerticalTabListWidth": 256,
-      "DocumentGroups": [
-        {
-          "DockedWidth": 200,
-          "SelectedChildIndex": 3,
-          "Children": [
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{e506b91c-c606-466a-90a9-123d1d1e12b3}"
-            },
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
-            },
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
-            },
-            {
-              "$type": "Document",
-              "DocumentIndex": 0,
-              "Title": "CatapultNetWars.Windows",
-              "DocumentMoniker": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "RelativeDocumentMoniker": "Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "ToolTip": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "RelativeToolTip": "Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAoAAAAAAAAAA==",
-              "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
-              "WhenOpened": "2025-07-14T18:15:48.421Z",
-              "EditorCaption": ""
-            }
-          ]
-        }
-      ]
-    }
-  ]
-}

+ 0 - 49
CatapultNetWars/.vs/CatapultNetWars/v17/DocumentLayout.json

@@ -1,49 +0,0 @@
-{
-  "Version": 1,
-  "WorkspaceRootPath": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\",
-  "Documents": [
-    {
-      "AbsoluteMoniker": "D:0:0:{B2676159-C59D-CA93-EBBC-F1984D0F95A5}|Platforms\\Windows\\CatapultNetWars.Windows.csproj|c:\\users\\savag\\source\\repos\\cartblanche\\monogame\\monogame-samples\\catapultnetwars\\platforms\\windows\\catapultnetwars.windows.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
-      "RelativeMoniker": "D:0:0:{B2676159-C59D-CA93-EBBC-F1984D0F95A5}|Platforms\\Windows\\CatapultNetWars.Windows.csproj|solutionrelative:platforms\\windows\\catapultnetwars.windows.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
-    }
-  ],
-  "DocumentGroupContainers": [
-    {
-      "Orientation": 0,
-      "VerticalTabListWidth": 256,
-      "DocumentGroups": [
-        {
-          "DockedWidth": 200,
-          "SelectedChildIndex": 3,
-          "Children": [
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{e506b91c-c606-466a-90a9-123d1d1e12b3}"
-            },
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
-            },
-            {
-              "$type": "Bookmark",
-              "Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
-            },
-            {
-              "$type": "Document",
-              "DocumentIndex": 0,
-              "Title": "CatapultNetWars.Windows",
-              "DocumentMoniker": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "RelativeDocumentMoniker": "Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "ToolTip": "C:\\Users\\savag\\source\\repos\\CartBlanche\\MonoGame\\MonoGame-Samples\\CatapultNetWars\\Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "RelativeToolTip": "Platforms\\Windows\\CatapultNetWars.Windows.csproj",
-              "ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAoAAAAAAAAAA==",
-              "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
-              "WhenOpened": "2025-07-14T18:15:48.421Z",
-              "EditorCaption": ""
-            }
-          ]
-        }
-      ]
-    }
-  ]
-}

BIN
CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.metadata.v9.bin


BIN
CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.projects.v9.bin


BIN
CatapultNetWars/.vs/ProjectEvaluation/catapultnetwars.strings.v9.bin


+ 0 - 0
CatapultNetWars/CatapultGame.cs


+ 39 - 28
CatapultNetWars/Core/Catapult/CatapultGame.cs

@@ -16,8 +16,7 @@ using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input;
 using Microsoft.Xna.Framework.Input.Touch;
 using Microsoft.Xna.Framework.Media;
-//using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
-using GameStateManagement;
+using Microsoft.Xna.Framework.Net;
 
 namespace CatapultGame
 {
@@ -26,7 +25,7 @@ namespace CatapultGame
 	/// </summary>
 	public class CatapultGame : Game
 	{
-		GraphicsDeviceManager graphics;
+		GraphicsDeviceManager graphicsDeviceManager;
 		ScreenManager screenManager;
 
 		// By preloading any assets used by UI rendering, we avoid framerate glitches
@@ -41,37 +40,49 @@ namespace CatapultGame
 			"chat_mute",
 		};
 
-		public CatapultGame ()
+		public CatapultGame()
 		{
-			graphics = new GraphicsDeviceManager (this);
+			graphicsDeviceManager = new GraphicsDeviceManager(this);
 			//graphics.SynchronizeWithVerticalRetrace = false;
+
+			graphicsDeviceManager.PreferredBackBufferHeight = 480;
+			graphicsDeviceManager.PreferredBackBufferWidth = 800;
+
+			if (UIUtility.IsMobile)
+			{
+				graphicsDeviceManager.IsFullScreen = true;
+				IsMouseVisible = false;
+			}
+			else if (UIUtility.IsDesktop)
+			{
+				graphicsDeviceManager.IsFullScreen = false;
+				IsMouseVisible = true;
+			}
+			else
+			{
+				throw new PlatformNotSupportedException();
+			}
+
 			Content.RootDirectory = "Content";
 
 			// Frame rate is 30 fps by default for Windows Phone.
-			TargetElapsedTime = TimeSpan.FromTicks (333333);
+			TargetElapsedTime = TimeSpan.FromTicks(333333);
 
 			//Create a new instance of the Screen Manager
-			screenManager = new ScreenManager (this);
-					Components.Add (screenManager);
-			
-			Components.Add (new MessageDisplayComponent (this));
+			screenManager = new ScreenManager(this);
+			Components.Add(screenManager);
+
+			Components.Add(new MessageDisplayComponent(this));
 			// Components.Add (new GamerServicesComponent (this)); // Not available in MonoGame 3.8
-			
+
 			//Add two new screens
-			screenManager.AddScreen (new BackgroundScreen (), null);
-			screenManager.AddScreen (new MainMenuScreen (), null);
+			screenManager.AddScreen(new BackgroundScreen(), null);
+			screenManager.AddScreen(new MainMenuScreen(), null);
 
 			// Listen for invite notification events.
-			// NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted (screenManager, e); // Not available in MonoGame 3.8
-
-			IsMouseVisible = true;
-#if ___MOBILE___
-			graphics.IsFullScreen = true;
-#endif
-			graphics.PreferredBackBufferHeight = 480;
-			graphics.PreferredBackBufferWidth = 800;
+			NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted(screenManager, e);
 
-			AudioManager.Initialize (this);
+			AudioManager.Initialize(this);
 		}
 
 		/// <summary>
@@ -80,15 +91,15 @@ namespace CatapultGame
 		/// related content.  Calling base.Initialize will enumerate through any components
 		/// and initialize them as well.
 		/// </summary>
-		protected override void Initialize ()
+		protected override void Initialize()
 		{
-			base.Initialize ();
+			base.Initialize();
 		}
 
-		protected override void LoadContent ()
+		protected override void LoadContent()
 		{
-			AudioManager.LoadSounds ();
-			base.LoadContent ();
+			AudioManager.LoadSounds();
+			base.LoadContent();
 		}
 	}
-}
+}

+ 1 - 1
CatapultNetWars/Core/CatapultNetWars.Core.csproj

@@ -6,7 +6,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
+    <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" PrivateAssets="all" />
   </ItemGroup>
 
   <ItemGroup>

+ 0 - 1
CatapultNetWars/Core/Networking/AvailableSessionMenuEntry.cs

@@ -8,7 +8,6 @@
 using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Net;
-using GameStateManagement;
 
 namespace CatapultGame
 {

+ 14 - 0
CatapultNetWars/Core/Networking/CatapultNetWars.code-workspace

@@ -0,0 +1,14 @@
+{
+	"folders": [
+		{
+			"path": "../.."
+		},
+		{
+			"path": "../../../MonoGame.Xna.Framework.Net"
+		},
+		{
+			"path": "../../../NetworkStateManagement"
+		}
+	],
+	"settings": {}
+}

+ 28 - 21
CatapultNetWars/Core/Networking/CreateOrFindSessionScreen.cs

@@ -10,7 +10,6 @@ using System.Collections.Generic;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Net;
 using Microsoft.Xna.Framework.GamerServices;
-using GameStateManagement;
 
 namespace CatapultGame
 {
@@ -23,9 +22,6 @@ namespace CatapultGame
 
 		NetworkSessionType sessionType;
 
-
-
-
 		/// <summary>
 		/// Constructor fills in the menu contents.
 		/// </summary>
@@ -86,7 +82,19 @@ namespace CatapultGame
 							ControllingPlayer.Value);
 
 				// Begin an asynchronous create network session operation.
-				IAsyncResult asyncResult = NetworkSession.BeginCreate(
+				var networkSession = NetworkSession.CreateAsync(
+						sessionType,
+						NetworkSessionComponent.MaxLocalGamers,
+						NetworkSessionComponent.MaxGamers,
+						1,
+						null);
+
+				// Activate the network busy screen, which will display
+				// an animation until this operation has completed.
+				var busyScreen = new NetworkBusyScreen<NetworkSession>(networkSession);
+
+				// Begin an asynchronous create network session operation.
+				/*var createSession = NetworkSession.CreateAsync(
 						sessionType,
 						localGamers,
 						NetworkSessionComponent.MaxGamers,
@@ -97,7 +105,7 @@ namespace CatapultGame
 
 				// Activate the network busy screen, which will display
 				// an animation until this operation has completed.
-				NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);
+				NetworkBusyScreen busyScreen = new NetworkBusyScreen(createSession);*/
 
 				busyScreen.OperationCompleted += CreateSessionOperationCompleted;
 
@@ -121,13 +129,14 @@ namespace CatapultGame
 		/// Event handler for when the asynchronous create network session
 		/// operation has completed.
 		/// </summary>
-		void CreateSessionOperationCompleted(object sender,
-					OperationCompletedEventArgs e)
+		void CreateSessionOperationCompleted(object sender, OperationCompletedEventArgs e)
 		{
 			try
 			{
-				// End the asynchronous create network session operation.
-				NetworkSession networkSession = NetworkSession.EndCreate(e.AsyncResult);
+				// Use the result directly from the event args.
+				NetworkSession networkSession = e.Result as NetworkSession;
+				if (networkSession == null)
+					throw new InvalidOperationException("NetworkSession result was null or invalid.");
 
 				// Create a component that will manage the session we just created.
 				NetworkSessionComponent.Create(ScreenManager, networkSession);
@@ -145,7 +154,6 @@ namespace CatapultGame
 			}
 		}
 
-
 		/// <summary>
 		/// Event handler for when the Find Sessions menu entry is selected.
 		/// </summary>
@@ -154,17 +162,16 @@ namespace CatapultGame
 			try
 			{
 				// Which local profiles should we include in this session?
-				IEnumerable<SignedInGamer> localGamers =
-			NetworkSessionComponent.ChooseGamers(sessionType,
-							ControllingPlayer.Value);
+				IEnumerable<SignedInGamer> localGamers = NetworkSessionComponent.ChooseGamers(sessionType, ControllingPlayer.Value);
 
 				// Begin an asynchronous find network sessions operation.
-				IAsyncResult asyncResult = NetworkSession.BeginFind(sessionType,
-							localGamers, null, null, null);
+				var availableNetworkSessions = NetworkSession.FindAsync(
+					sessionType,
+					NetworkSessionComponent.MaxLocalGamers, null);
 
 				// Activate the network busy screen, which will display
 				// an animation until this operation has completed.
-				NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);
+				var busyScreen = new NetworkBusyScreen<AvailableNetworkSessionCollection>(availableNetworkSessions);
 
 				busyScreen.OperationCompleted += FindSessionsOperationCompleted;
 
@@ -178,7 +185,6 @@ namespace CatapultGame
 			}
 		}
 
-
 		/// <summary>
 		/// Event handler for when the asynchronous find network sessions
 		/// operation has completed.
@@ -190,9 +196,10 @@ namespace CatapultGame
 
 			try
 			{
-				// End the asynchronous find network sessions operation.
-				AvailableNetworkSessionCollection availableSessions =
-						NetworkSession.EndFind(e.AsyncResult);
+				// Use the result directly from the event args.
+				AvailableNetworkSessionCollection availableSessions = e.Result as AvailableNetworkSessionCollection;
+				if (availableSessions == null)
+					throw new InvalidOperationException("AvailableNetworkSessionCollection result was null or invalid.");
 
 				if (availableSessions.Count == 0)
 				{

+ 15 - 15
CatapultNetWars/Core/Networking/JoinSessionScreen.cs

@@ -9,7 +9,6 @@ using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Net;
 using Microsoft.Xna.Framework.GamerServices;
-using GameStateManagement;
 
 namespace CatapultGame
 {
@@ -72,12 +71,11 @@ namespace CatapultGame
             try
             {
                 // Begin an asynchronous join network session operation.
-                IAsyncResult asyncResult = NetworkSession.BeginJoin(availableSession,
-                                                                    null, null);
+                var joinedSession = NetworkSession.JoinAsync(availableSession);
 
                 // Activate the network busy screen, which will display
                 // an animation until this operation has completed.
-                NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);
+                var busyScreen = new NetworkBusyScreen<NetworkSession>(joinedSession);
 
                 busyScreen.OperationCompleted += JoinSessionOperationCompleted;
 
@@ -100,17 +98,19 @@ namespace CatapultGame
         {
             try
             {
-                // End the asynchronous join network session operation.
-                NetworkSession networkSession = NetworkSession.EndJoin(e.AsyncResult);
-
-                // Create a component that will manage the session we just joined.
-                NetworkSessionComponent.Create(ScreenManager, networkSession);
-
-                // Go to the lobby screen. We pass null as the controlling player,
-                // because the lobby screen accepts input from all local players
-                // who are in the session, not just a single controlling player.
-                ScreenManager.AddScreen(new LobbyScreen(networkSession), null);
-
+                // Use the result directly from the event args.
+				NetworkSession networkSession = e.Result as NetworkSession;
+				if (networkSession == null)
+					throw new InvalidOperationException("NetworkSession result was null or invalid.");
+
+				// Create a component that will manage the session we just joined.
+				NetworkSessionComponent.Create(ScreenManager, networkSession);
+
+				// Go to the lobby screen. We pass null as the controlling player,
+				// because the lobby screen accepts input from all local players
+				// who are in the session, not just a single controlling player.
+				ScreenManager.AddScreen(new LobbyScreen(networkSession), null);
+                
                 availableSessions.Dispose();
             }
             catch (Exception exception)

+ 89 - 97
CatapultNetWars/Core/Networking/LobbyScreen.cs

@@ -11,8 +11,7 @@ using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Input;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Net;
-using GameStateManagement;
-using Microsoft.Xna.Framework.Input.Touch;
+
 
 namespace CatapultGame
 {
@@ -31,233 +30,228 @@ namespace CatapultGame
 		Texture2D isTalkingTexture;
 		Texture2D voiceMutedTexture;
 
-
-
-
 		/// <summary>
 		/// Constructs a new lobby screen.
 		/// </summary>
-		public LobbyScreen (NetworkSession networkSession)
-			{
-			EnabledGestures = GestureType.Tap;
+		public LobbyScreen(NetworkSession networkSession)
+		{
 			this.networkSession = networkSession;
 
-			TransitionOnTime = TimeSpan.FromSeconds (0.5);
-			TransitionOffTime = TimeSpan.FromSeconds (0.5);
-			
-		}
+			TransitionOnTime = TimeSpan.FromSeconds(0.5);
+			TransitionOffTime = TimeSpan.FromSeconds(0.5);
 
+		}
 
 		/// <summary>
 		/// Loads graphics content used by the lobby screen.
 		/// </summary>
-		public override void LoadContent ()
+		public override void LoadContent()
 		{
 			ContentManager content = ScreenManager.Game.Content;
 
-			isReadyTexture = content.Load<Texture2D> ("chat_ready");
-			hasVoiceTexture = content.Load<Texture2D> ("chat_able");
-			isTalkingTexture = content.Load<Texture2D> ("chat_talking");
-			voiceMutedTexture = content.Load<Texture2D> ("chat_mute");
+			isReadyTexture = content.Load<Texture2D>("chat_ready");
+			hasVoiceTexture = content.Load<Texture2D>("chat_able");
+			isTalkingTexture = content.Load<Texture2D>("chat_talking");
+			voiceMutedTexture = content.Load<Texture2D>("chat_mute");
 		}
 
-
-
-
-
 		/// <summary>
 		/// Updates the lobby screen.
 		/// </summary>
-		public override void Update (GameTime gameTime, bool otherScreenHasFocus, 
+		public override void Update(GameTime gameTime, bool otherScreenHasFocus,
 							bool coveredByOtherScreen)
 		{
-			base.Update (gameTime, otherScreenHasFocus, coveredByOtherScreen);
+			base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
 
-			if (!IsExiting) {
-				if (networkSession.SessionState == NetworkSessionState.Playing) {
+			if (!IsExiting)
+			{
+				if (networkSession.SessionState == NetworkSessionState.Playing)
+				{
 					// Check if we should leave the lobby and begin gameplay.
 					// We pass null as the controlling player, because the networked
 					// gameplay screen accepts input from any local players who
 					// are in the session, not just a single controlling player.
-					LoadingScreen.Load (ScreenManager, true, null,
-					new InstructionsScreen());
-				} else if (networkSession.IsHost && networkSession.IsEveryoneReady) {
+					LoadingScreen.Load(ScreenManager, true, null,
+					new GameplayScreen());
+				}
+				else if (networkSession.IsHost && networkSession.IsEveryoneReady)
+				{
 					// The host checks whether everyone has marked themselves
 					// as ready, and starts the game in response.
-					networkSession.StartGame ();
+					networkSession.StartGame();
 				}
 			}
 		}
 
-
 		/// <summary>
 		/// Handles user input for all the local gamers in the session. Unlike most
 		/// screens, which use the InputState class to combine input data from all
 		/// gamepads, the lobby needs to individually mark specific players as ready,
 		/// so it loops over all the local gamers and reads their inputs individually.
 		/// </summary>
-		public override void HandleInput (InputState input)
+		public override void HandleInput(InputState input)
 		{
-			foreach (LocalNetworkGamer gamer in networkSession.LocalGamers) {
-				PlayerIndex playerIndex = gamer.SignedInGamer.PlayerIndex;
+			foreach (LocalNetworkGamer gamer in networkSession.LocalGamers)
+			{
+				PlayerIndex playerIndex = (PlayerIndex)gamer.SignedInGamer.PlayerIndex;
 
 				PlayerIndex unwantedOutput;
 
-				if (input.IsMenuSelect (playerIndex, out unwantedOutput)) {
-					HandleMenuSelect (gamer);
-				} else if (input.IsMenuCancel (playerIndex, out unwantedOutput)) {
-					HandleMenuCancel (gamer);
+				if (input.IsMenuSelect(playerIndex, out unwantedOutput))
+				{
+					HandleMenuSelect(gamer);
 				}
-			}
-			
-			if (input.Gestures.Count > 0)
-			{
-				foreach(var g in input.Gestures)
+				else if (input.IsMenuCancel(playerIndex, out unwantedOutput))
 				{
-					if (g.GestureType == Microsoft.Xna.Framework.Input.Touch.GestureType.Tap)
-					{
-						HandleMenuSelect(networkSession.LocalGamers[0]);
-					}
+					HandleMenuCancel(gamer);
 				}
 			}
 		}
 
-
 		/// <summary>
 		/// Handle MenuSelect inputs by marking ourselves as ready.
 		/// </summary>
-		void HandleMenuSelect (LocalNetworkGamer gamer)
+		void HandleMenuSelect(LocalNetworkGamer localGamer)
 		{
-			if (!gamer.IsReady) {
-				gamer.IsReady = true;
-			} else if (gamer.IsHost) {
+			if (!localGamer.IsReady)
+			{
+				localGamer.IsReady = true;
+			}
+			else if (localGamer.IsHost)
+			{
 				// The host has an option to force starting the game, even if not
 				// everyone has marked themselves ready. If they press select twice
 				// in a row, the first time marks the host ready, then the second
 				// time we ask if they want to force start.
-				MessageBoxScreen messageBox = new MessageBoxScreen (
+				MessageBoxScreen messageBox = new MessageBoxScreen(
 						Resources.ConfirmForceStartGame);
 
 				messageBox.Accepted += ConfirmStartGameMessageBoxAccepted;
 
-				ScreenManager.AddScreen (messageBox, gamer.SignedInGamer.PlayerIndex);
+				ScreenManager.AddScreen(messageBox, (PlayerIndex?)localGamer.SignedInGamer.PlayerIndex);
 			}
 		}
 
-
 		/// <summary>
 		/// Event handler for when the host selects ok on the "are you sure
 		/// you want to start even though not everyone is ready" message box.
 		/// </summary>
-		void ConfirmStartGameMessageBoxAccepted (object sender, PlayerIndexEventArgs e)
+		void ConfirmStartGameMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 		{
-			if (networkSession.SessionState == NetworkSessionState.Lobby) {
-				networkSession.StartGame ();
+			if (networkSession.SessionState == NetworkSessionState.Lobby)
+			{
+				networkSession.StartGame();
 			}
 		}
 
-
 		/// <summary>
 		/// Handle MenuCancel inputs by clearing our ready status, or if it is
 		/// already clear, prompting if the user wants to leave the session.
 		/// </summary>
-		void HandleMenuCancel (LocalNetworkGamer gamer)
+		void HandleMenuCancel(LocalNetworkGamer localGamer)
 		{
-			if (gamer.IsReady) {
-				gamer.IsReady = false;
-			} else {
-				PlayerIndex playerIndex = gamer.SignedInGamer.PlayerIndex;
+			if (localGamer.IsReady)
+			{
+				localGamer.IsReady = false;
+			}
+			else
+			{
+				PlayerIndex playerIndex = (PlayerIndex)localGamer.SignedInGamer.PlayerIndex;
 
-				NetworkSessionComponent.LeaveSession (ScreenManager, playerIndex);
+				NetworkSessionComponent.LeaveSession(ScreenManager, playerIndex);
 			}
 		}
 
-
-
-
-
 		/// <summary>
 		/// Draws the lobby screen.
 		/// </summary>
-		public override void Draw (GameTime gameTime)
+		public override void Draw(GameTime gameTime)
 		{
 			SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
 			SpriteFont font = ScreenManager.Font;
 
-			Vector2 position = new Vector2 (100, 150);
+			Vector2 position = new Vector2(50, 100);
 
 			// Make the lobby slide into place during transitions.
-			float transitionOffset = (float)Math.Pow (TransitionPosition, 2);
+			float transitionOffset = (float)Math.Pow(TransitionPosition, 2);
 
 			if (ScreenState == ScreenState.TransitionOn)
 				position.X -= transitionOffset * 256;
 			else
 				position.X += transitionOffset * 512;
 
-			spriteBatch.Begin ();
+			spriteBatch.Begin();
 
 			// Draw all the gamers in the session.
 			int gamerCount = 0;
 
-			foreach (NetworkGamer gamer in networkSession.AllGamers) {
-				DrawGamer (gamer, position);
+			foreach (NetworkGamer gamer in networkSession.AllGamers)
+			{
+				DrawGamer(gamer, position);
 
 				// Advance to the next screen position, wrapping into two
 				// columns if there are more than 8 gamers in the session.
-				if (++gamerCount == 8) {
+				if (++gamerCount == 8)
+				{
 					position.X += 433;
 					position.Y = 150;
-				} else
+				}
+				else
 					position.Y += ScreenManager.Font.LineSpacing;
 			}
 
 			// Draw the screen title.
 			string title = Resources.Lobby;
 
-			Vector2 titlePosition = new Vector2 (533, 80);
-			Vector2 titleOrigin = font.MeasureString (title) / 2;
-			Color titleColor = new Color (192, 192, 192) * TransitionAlpha;
+			Vector2 titlePosition = new Vector2(100, 80);
+			Vector2 titleOrigin = font.MeasureString(title) / 2;
+			Color titleColor = new Color(192, 192, 192) * TransitionAlpha;
 			float titleScale = 1.25f;
 
 			titlePosition.Y -= transitionOffset * 100;
 
-			spriteBatch.DrawString (font, title, titlePosition, titleColor, 0, 
+			spriteBatch.DrawString(font, title, titlePosition, titleColor, 0,
 				titleOrigin, titleScale, SpriteEffects.None, 0);
 
-			spriteBatch.End ();
+			spriteBatch.End();
 		}
 
-
 		/// <summary>
 		/// Helper draws the gamertag and status icons for a single NetworkGamer.
 		/// </summary>
-		void DrawGamer (NetworkGamer gamer, Vector2 position)
+		void DrawGamer(NetworkGamer gamer, Vector2 position)
 		{
 			SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
 			SpriteFont font = ScreenManager.Font;
 
-			Vector2 iconWidth = new Vector2 (34, 0);
-			Vector2 iconOffset = new Vector2 (0, 12);
+			Vector2 iconWidth = new Vector2(34, 0);
+			Vector2 iconOffset = new Vector2(0, 12);
 
 			Vector2 iconPosition = position + iconOffset;
 
 			// Draw the "is ready" icon.
-			if (gamer.IsReady) {
-				spriteBatch.Draw (isReadyTexture, iconPosition, 
+			if (gamer.IsReady)
+			{
+				spriteBatch.Draw(isReadyTexture, iconPosition,
 				Color.Lime * TransitionAlpha);
 			}
 
 			iconPosition += iconWidth;
 
 			// Draw the "is muted", "is talking", or "has voice" icon.
-			if (gamer.IsMutedByLocalUser) {
-				spriteBatch.Draw (voiceMutedTexture, iconPosition, 
+			if (gamer.IsMutedByLocalUser)
+			{
+				spriteBatch.Draw(voiceMutedTexture, iconPosition,
 				Color.Red * TransitionAlpha);
-			} else if (gamer.IsTalking) {
-				spriteBatch.Draw (isTalkingTexture, iconPosition, 
+			}
+			else if (gamer.IsTalking)
+			{
+				spriteBatch.Draw(isTalkingTexture, iconPosition,
 				Color.Yellow * TransitionAlpha);
-			} else if (gamer.HasVoice) {
-				spriteBatch.Draw (hasVoiceTexture, iconPosition, 
+			}
+			else if (gamer.HasVoice)
+			{
+				spriteBatch.Draw(hasVoiceTexture, iconPosition,
 				Color.White * TransitionAlpha);
 			}
 
@@ -269,10 +263,8 @@ namespace CatapultGame
 
 			Color color = (gamer.IsLocal) ? Color.Yellow : Color.White;
 
-			spriteBatch.DrawString (font, text, position + iconWidth * 2, 
+			spriteBatch.DrawString(font, text, position + iconWidth * 2,
 				color * TransitionAlpha);
 		}
-
-
 	}
-}
+}

+ 89 - 61
CatapultNetWars/Core/Networking/NetworkBusyScreen.cs

@@ -6,52 +6,54 @@
 //-----------------------------------------------------------------------------
 
 using System;
+using System.Threading;
+using System.Threading.Tasks;
+
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
-using GameStateManagement;
+using Microsoft.Xna.Framework.Input;
 
 namespace CatapultGame
 {
 	/// <summary>
 	/// When an asynchronous network operation (for instance searching for or joining a
-	/// session) is in progress, we want to display some sort of busy indicator to let
-	/// the user know the game hasn't just locked up. We also want to make sure they
-	/// can't pick some other menu option before the current operation has finished.
-	/// This screen takes care of both requirements in a single stroke. It monitors
-	/// the IAsyncResult returned by an asynchronous network call, displaying a busy
-	/// indicator for as long as the call is still in progress. When it notices the
-	/// IAsyncResult has completed, it raises an event to let the game know it should
-	/// proceed to the next step, after which the busy screen automatically goes away.
-	/// Because this screen is on top of all others for as long as the asynchronous
-	/// operation is in progress, it automatically takes over all user input,
-	/// preventing any other menu entries being selected until the operation completes.
+	/// session) is in progress, this screen displays a busy indicator and blocks input.
+	/// It monitors a Task&lt;T&gt; returned by the async call, showing the indicator while
+	/// the task is running. When the task completes, it raises an event with the
+	/// operation result (or null on failure), then automatically dismisses itself.
+	/// Because this screen sits on top while the async operation is in progress, it
+	/// captures all user input to prevent interaction with underlying screens until
+	/// the operation completes.
 	/// </summary>
-	class NetworkBusyScreen : GameScreen
+	class NetworkBusyScreen<T> : GameScreen
 	{
-
-		IAsyncResult asyncResult;
+		readonly Task<T> task;
+		readonly CancellationTokenSource cts;
+		bool completionRaised;
 		Texture2D gradientTexture;
 		Texture2D catTexture;
 
-
-
-		public event EventHandler<OperationCompletedEventArgs> OperationCompleted;
-
-
-
+		event EventHandler<OperationCompletedEventArgs> operationCompleted;
+		public event EventHandler<OperationCompletedEventArgs> OperationCompleted
+		{
+			add { operationCompleted += value; }
+			remove { operationCompleted -= value; }
+		}
 
 		/// <summary>
 		/// Constructs a network busy screen for the specified asynchronous operation.
+		/// Accepts a Task&lt;T&gt; representing the in-flight operation.
 		/// </summary>
-		public NetworkBusyScreen (IAsyncResult asyncResult)
-			{
-			this.asyncResult = asyncResult;
+		public NetworkBusyScreen(Task<T> task)
+		{
+			this.task = task;
+			this.cts = null;
 
 			IsPopup = true;
 
-			TransitionOnTime = TimeSpan.FromSeconds (0.1);
-			TransitionOffTime = TimeSpan.FromSeconds (0.2);
+			TransitionOnTime = TimeSpan.FromSeconds(0.1);
+			TransitionOffTime = TimeSpan.FromSeconds(0.2);
 		}
 
 
@@ -61,37 +63,65 @@ namespace CatapultGame
 		/// Whenever a subsequent NetworkBusyScreen tries to load this same content,
 		/// it will just get back another reference to the already loaded data.
 		/// </summary>
-		public override void LoadContent ()
+		public override void LoadContent()
 		{
 			ContentManager content = ScreenManager.Game.Content;
 
-			gradientTexture = content.Load<Texture2D> ("gradient");
-			catTexture = content.Load<Texture2D> ("cat");
+			gradientTexture = content.Load<Texture2D>("gradient");
+			catTexture = content.Load<Texture2D>("cat");
 		}
 
-
-
-
-
 		/// <summary>
-		/// Updates the NetworkBusyScreen.
+		/// Updates the NetworkBusyScreen, checking whether the underlying Task has
+		/// completed and raising OperationCompleted when it does.
 		/// </summary>
-		public override void Update (GameTime gameTime, bool otherScreenHasFocus, 
+		public override void Update(GameTime gameTime, bool otherScreenHasFocus,
 							bool coveredByOtherScreen)
 		{
-			base.Update (gameTime, otherScreenHasFocus, coveredByOtherScreen);
+			base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
+
+			// Optional: allow user to cancel (Esc or B)
+			if (!completionRaised && cts != null)
+			{
+				var kb = Keyboard.GetState();
+				if (kb.IsKeyDown(Keys.Escape))
+				{
+					cts.Cancel();
+				}
+				var gp = GamePad.GetState(PlayerIndex.One);
+				if (gp.IsConnected && gp.IsButtonDown(Buttons.B))
+				{
+					cts.Cancel();
+				}
+			}
 
 			// Has our asynchronous operation completed?
-			if ((asyncResult != null) && asyncResult.IsCompleted) {
-				// If so, raise the OperationCompleted event.
-				if (OperationCompleted != null) {
-					OperationCompleted (this, 
-					new OperationCompletedEventArgs (asyncResult));
+			if (!completionRaised && task != null && task.IsCompleted)
+			{
+				object resultObject = default(T);
+				Exception error = null;
+				try
+				{
+					// Accessing Result will throw if the task faulted/canceled.
+					// We catch here and allow handlers to present error UI.
+					resultObject = task.Result;
+				}
+				catch (Exception ex)
+				{
+					// Leave result as default (usually null) to signal failure to handlers.
+					error = (task?.Exception?.GetBaseException()) ?? ex;
 				}
 
-				ExitScreen ();
+				var handler = operationCompleted;
+				if (handler != null)
+				{
+					handler(this, new OperationCompletedEventArgs(resultObject, error));
+				}
 
-				asyncResult = null;
+				completionRaised = true;
+				// Clear handlers to avoid reentry if this screen lingers during transition off
+				operationCompleted = null;
+				ExitScreen();
 			}
 		}
 
@@ -99,31 +129,31 @@ namespace CatapultGame
 		/// <summary>
 		/// Draws the NetworkBusyScreen.
 		/// </summary>
-		public override void Draw (GameTime gameTime)
+		public override void Draw(GameTime gameTime)
 		{
 			SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
 			SpriteFont font = ScreenManager.Font;
 
 			string message = Resources.NetworkBusy;
 
-			const int hPad = 32 ; 
-			const int vPad = 16 ; 
+			const int hPad = 32;
+			const int vPad = 16;
 
 			// Center the message text in the viewport.
 			Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
-			Vector2 viewportSize = new Vector2 (viewport.Width, viewport.Height);
-			Vector2 textSize = font.MeasureString (message);
+			Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
+			Vector2 textSize = font.MeasureString(message);
 
 			// Add enough room to spin a cat.
-			Vector2 catSize = new Vector2 (catTexture.Width);
+			Vector2 catSize = new Vector2(catTexture.Width);
 
-			textSize.X = Math.Max (textSize.X, catSize.X);
+			textSize.X = Math.Max(textSize.X, catSize.X);
 			textSize.Y += catSize.Y + vPad;
 
 			Vector2 textPosition = (viewportSize - textSize) / 2;
 
 			// The background includes a border somewhat larger than the text itself.
-			Rectangle backgroundRectangle = new Rectangle ((int)textPosition.X - hPad,
+			Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad,
 							(int)textPosition.Y - vPad,
 							(int)textSize.X + hPad * 2,
 							(int)textSize.Y + vPad * 2);
@@ -131,27 +161,25 @@ namespace CatapultGame
 			// Fade the popup alpha during transitions.
 			Color color = Color.White * TransitionAlpha;
 
-			spriteBatch.Begin ();
+			spriteBatch.Begin();
 
 			// Draw the background rectangle.
-			spriteBatch.Draw (gradientTexture, backgroundRectangle, color);
+			spriteBatch.Draw(gradientTexture, backgroundRectangle, color);
 
 			// Draw the message box text.
-			spriteBatch.DrawString (font, message, textPosition, color);
+			spriteBatch.DrawString(font, message, textPosition, color);
 
 			// Draw the spinning cat progress indicator.
 			float catRotation = (float)gameTime.TotalGameTime.TotalSeconds * 3;
 
-			Vector2 catPosition = new Vector2 (textPosition.X + textSize.X / 2,
-						textPosition.Y + textSize.Y - 
+			Vector2 catPosition = new Vector2(textPosition.X + textSize.X / 2,
+						textPosition.Y + textSize.Y -
 								catSize.Y / 2);
 
-			spriteBatch.Draw (catTexture, catPosition, null, color, catRotation, 
+			spriteBatch.Draw(catTexture, catPosition, null, color, catRotation,
 				catSize / 2, 1, SpriteEffects.None, 0);
 
-			spriteBatch.End ();
+			spriteBatch.End();
 		}
-
-
 	}
-}
+}

+ 0 - 1
CatapultNetWars/Core/Networking/NetworkErrorScreen.cs

@@ -9,7 +9,6 @@ using System;
 using System.Diagnostics;
 using Microsoft.Xna.Framework.GamerServices;
 using Microsoft.Xna.Framework.Net;
-using GameStateManagement;
 
 namespace CatapultGame
 {

+ 19 - 14
CatapultNetWars/Core/Networking/NetworkSessionComponent.cs

@@ -12,7 +12,6 @@ using System.Collections.Generic;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Net;
 using Microsoft.Xna.Framework.GamerServices;
-using GameStateManagement;
 
 namespace CatapultGame
 {
@@ -211,17 +210,22 @@ namespace CatapultGame
 					InviteAcceptedEventArgs e)
 		{
 			// If we are already in a network session, leave it now.
-			NetworkSessionComponent self = FindSessionComponent (screenManager.Game);
+			NetworkSessionComponent self = FindSessionComponent(screenManager.Game);
 
 			if (self != null)
-				self.Dispose ();
+				self.Dispose(true);
 
-			try			{
+			try
+			{
 				// Which local profiles should we include in this session?
-				IEnumerable<SignedInGamer> localGamers = ChooseGamers (NetworkSessionType.PlayerMatch, e.Gamer.PlayerIndex);
+				PlayerIndex defaultPlayerIndex = PlayerIndex.One;
+				IEnumerable<SignedInGamer> localGamers =
+					ChooseGamers(NetworkSessionType.PlayerMatch, defaultPlayerIndex);
 
-				// Begin an asynchronous join-from-invite operation.
-				IAsyncResult asyncResult = NetworkSession.BeginJoinInvited (localGamers, null, null);
+				// Begin an asynchronous join-from-invite operation using the modern API.
+				var joinSession = NetworkSession.JoinInvitedAsync(
+					localGamers,
+					null);
 
 				// Use the loading screen to replace whatever screens were previously
 				// active. This will completely reset the screen state, regardless of
@@ -229,11 +233,11 @@ namespace CatapultGame
 				// delivered. When the loading screen finishes, it will activate the
 				// network busy screen, which displays an animation as it waits for
 				// the join operation to complete.
-				NetworkBusyScreen busyScreen = new NetworkBusyScreen (asyncResult);
+				var busyScreen = new NetworkBusyScreen<NetworkSession>(joinSession);
 
 				busyScreen.OperationCompleted += JoinInvitedOperationCompleted;
 
-				LoadingScreen.Load (screenManager, false, null, new BackgroundScreen (), 
+				LoadingScreen.Load(screenManager, false, null, new BackgroundScreen(),
 							busyScreen);
 			} catch (Exception exception) {
 				NetworkErrorScreen errorScreen = new NetworkErrorScreen (exception);
@@ -255,15 +259,16 @@ namespace CatapultGame
 			ScreenManager screenManager = ((GameScreen)sender).ScreenManager;
 
 			try			{
-				// End the asynchronous join-from-invite operation.
-				NetworkSession networkSession = 
-					NetworkSession.EndJoinInvited (e.AsyncResult);
+				// Use the result directly from the event args.
+				NetworkSession networkSession = e.Result as NetworkSession;
+				if (networkSession == null)
+					throw new InvalidOperationException("NetworkSession result was null or invalid.");
 
 				// Create a component that will manage the session we just created.
-				NetworkSessionComponent.Create (screenManager, networkSession);
+				NetworkSessionComponent.Create(screenManager, networkSession);
 
 				// Go to the lobby screen.
-				screenManager.AddScreen (new LobbyScreen (networkSession), null);
+				screenManager.AddScreen(new LobbyScreen(networkSession), null);
 			} catch (Exception exception) {
 				screenManager.AddScreen (new MainMenuScreen (), null);
 				screenManager.AddScreen (new NetworkErrorScreen (exception), null);

+ 16 - 17
CatapultNetWars/Core/Networking/OperationCompletedEventArgs.cs

@@ -14,32 +14,31 @@ namespace CatapultGame
     /// </summary>
     class OperationCompletedEventArgs : EventArgs
     {
+        /// <summary>
+        /// Gets or sets the result of the network operation that has just completed.
+        /// </summary>
+        public object Result { get; set; }
 
+        /// <summary>
+        /// Gets or sets the exception that caused the operation to fail, if any.
+        /// </summary>
+        public Exception Exception { get; set; }
 
         /// <summary>
-        /// Gets or sets the IAsyncResult associated with
-        /// the network operation that has just completed.
+        /// Constructs a new event arguments class.
         /// </summary>
-        public IAsyncResult AsyncResult
+        public OperationCompletedEventArgs(object result)
         {
-            get { return asyncResult; }
-            set { asyncResult = value; }
+            this.Result = result;
         }
 
-        IAsyncResult asyncResult;
-
-
-
-
-
         /// <summary>
-        /// Constructs a new event arguments class.
+        /// Constructs a new event arguments class with an optional exception.
         /// </summary>
-        public OperationCompletedEventArgs(IAsyncResult asyncResult)
+        public OperationCompletedEventArgs(object result, Exception exception)
         {
-            this.asyncResult = asyncResult;
+            this.Result = result;
+            this.Exception = exception;
         }
-
-
     }
-}
+}

+ 1 - 2
CatapultNetWars/Core/Networking/ProfileSignInScreen.cs

@@ -9,7 +9,6 @@ using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Net;
 using Microsoft.Xna.Framework.GamerServices;
-using GameStateManagement;
 
 namespace CatapultGame
 {
@@ -165,7 +164,7 @@ namespace CatapultGame
 
             confirmMarketplaceMessageBox.Accepted += delegate
             {
-                Guide.ShowMarketplace(ControllingPlayer.HasValue ? (int)ControllingPlayer.Value : (int)PlayerIndex.One);
+                // TODO Guide.ShowMarketplace(ControllingPlayer.HasValue ? (int)ControllingPlayer.Value : (int)PlayerIndex.One);
             };
 
             ScreenManager.AddScreen(confirmMarketplaceMessageBox, ControllingPlayer);

+ 0 - 1
CatapultNetWars/Core/Players/Human.cs

@@ -19,7 +19,6 @@ using System.Text;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input.Touch;
-using GameStateManagement;
 
 namespace CatapultGame
 {

+ 226 - 298
CatapultNetWars/Core/Resources.Designer.cs

@@ -8,10 +8,11 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace CatapultGame {
+namespace CatapultGame
+{
     using System;
-    
-    
+
+
     /// <summary>
     ///   A strongly-typed resource class, for looking up localized strings, etc.
     /// </summary>
@@ -22,573 +23,500 @@ namespace CatapultGame {
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources {
-        
+    internal class Resources
+    {
+
         private static global::System.Resources.ResourceManager resourceMan;
-        
+
         private static global::System.Globalization.CultureInfo resourceCulture;
-        
+
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources() {
+        internal Resources()
+        {
         }
-        
+
         /// <summary>
         ///   Returns the cached ResourceManager instance used by this class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager {
-            get {
-                if (object.ReferenceEquals(resourceMan, null)) {
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if (object.ReferenceEquals(resourceMan, null))
+                {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CatapultGame.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-        
+
         /// <summary>
         ///   Overrides the current thread's CurrentUICulture property for all
         ///   resource lookups using this strongly typed resource class.
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture {
-            get {
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
                 return resourceCulture;
             }
-            set {
+            set
+            {
                 resourceCulture = value;
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Back.
         /// </summary>
-        internal static string Back {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.Back);
-#else				
+        internal static string Back
+        {
+            get
+            {
                 return ResourceManager.GetString("Back", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to end this session?.
         /// </summary>
-        internal static string ConfirmEndSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmEndSession);
-#else				
-				
+        internal static string ConfirmEndSession
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmEndSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to exit this sample?.
         /// </summary>
-        internal static string ConfirmExitSample {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmExitSample);
-#else								
+        internal static string ConfirmExitSample
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmExitSample", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to start the game,
         ///even though not all players are ready?.
         /// </summary>
-        internal static string ConfirmForceStartGame {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmForceStartGame);
-#else								
+        internal static string ConfirmForceStartGame
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmForceStartGame", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to leave this session?.
         /// </summary>
-        internal static string ConfirmLeaveSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmLeaveSession);
-#else								
+        internal static string ConfirmLeaveSession
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmLeaveSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Online gameplay is not available in trial mode.
         ///Would you like to purchase this game?.
         /// </summary>
-        internal static string ConfirmMarketplace {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmMarketplace);
-#else								
+        internal static string ConfirmMarketplace
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmMarketplace", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Are you sure you want to quit this game?.
         /// </summary>
-        internal static string ConfirmQuitGame {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ConfirmQuitGame);
-#else								
+        internal static string ConfirmQuitGame
+        {
+            get
+            {
                 return ResourceManager.GetString("ConfirmQuitGame", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Create Session.
         /// </summary>
-        internal static string CreateSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.CreateSession);
-#else								
+        internal static string CreateSession
+        {
+            get
+            {
                 return ResourceManager.GetString("CreateSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to End Session.
         /// </summary>
-        internal static string EndSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.EndSession);
-#else								
+        internal static string EndSession
+        {
+            get
+            {
                 return ResourceManager.GetString("EndSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Lost connection to the network session.
         /// </summary>
-        internal static string ErrorDisconnected {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorDisconnected);
-#else								
+        internal static string ErrorDisconnected
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorDisconnected", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to You must sign in a suitable gamer profile
         ///in order to access this functionality.
         /// </summary>
-        internal static string ErrorGamerPrivilege {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorGamerPrivilege);
-#else				
+        internal static string ErrorGamerPrivilege
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorGamerPrivilege", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Host ended the session.
         /// </summary>
-        internal static string ErrorHostEndedSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorHostEndedSession);
-#else								
+        internal static string ErrorHostEndedSession
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorHostEndedSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to There was an error while
         ///accessing the network.
         /// </summary>
-        internal static string ErrorNetwork {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorNetwork);
-#else								
+        internal static string ErrorNetwork
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorNetwork", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Networking is turned
         ///off or not connected.
         /// </summary>
-        internal static string ErrorNetworkNotAvailable {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorNetworkNotAvailable);
-#else								
+        internal static string ErrorNetworkNotAvailable
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorNetworkNotAvailable", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Host kicked you out of the session.
         /// </summary>
-        internal static string ErrorRemovedByHost {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorRemovedByHost);
-#else								
+        internal static string ErrorRemovedByHost
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorRemovedByHost", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to This session is already full.
         /// </summary>
-        internal static string ErrorSessionFull {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorSessionFull);
-#else								
+        internal static string ErrorSessionFull
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorSessionFull", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Session not found. It may have ended,
         ///or there may be no network connectivity
         ///between the local machine and session host.
         /// </summary>
-        internal static string ErrorSessionNotFound {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorSessionNotFound);
-#else								
+        internal static string ErrorSessionNotFound
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorSessionNotFound", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to You must wait for the host to return to
         ///the lobby before you can join this session.
         /// </summary>
-        internal static string ErrorSessionNotJoinable {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorSessionNotJoinable);
-#else								
+        internal static string ErrorSessionNotJoinable
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorSessionNotJoinable", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to This functionality is not available in trial mode.
         /// </summary>
-        internal static string ErrorTrialMode {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorTrialMode);
-#else								
+        internal static string ErrorTrialMode
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorTrialMode", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to An unknown error occurred.
         /// </summary>
-        internal static string ErrorUnknown {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ErrorUnknown);
-#else								
+        internal static string ErrorUnknown
+        {
+            get
+            {
                 return ResourceManager.GetString("ErrorUnknown", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Exit.
         /// </summary>
-        internal static string Exit {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.Exit);
-#else								
+        internal static string Exit
+        {
+            get
+            {
                 return ResourceManager.GetString("Exit", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Find Sessions.
         /// </summary>
-        internal static string FindSessions {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.FindSessions);
-#else								
+        internal static string FindSessions
+        {
+            get
+            {
                 return ResourceManager.GetString("FindSessions", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to  (host).
         /// </summary>
-        internal static string HostSuffix {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.HostSuffix);
-#else								
+        internal static string HostSuffix
+        {
+            get
+            {
                 return ResourceManager.GetString("HostSuffix", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Join Session.
         /// </summary>
-        internal static string JoinSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.JoinSession);
-#else								
+        internal static string JoinSession
+        {
+            get
+            {
                 return ResourceManager.GetString("JoinSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Leave Session.
         /// </summary>
-        internal static string LeaveSession {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.LeaveSession);
-#else								
+        internal static string LeaveSession
+        {
+            get
+            {
                 return ResourceManager.GetString("LeaveSession", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Loading.
         /// </summary>
-        internal static string Loading {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.Loading);
-#else								
+        internal static string Loading
+        {
+            get
+            {
                 return ResourceManager.GetString("Loading", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Lobby.
         /// </summary>
-        internal static string Lobby {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.Lobby);
-#else								
+        internal static string Lobby
+        {
+            get
+            {
                 return ResourceManager.GetString("Lobby", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Main Menu.
         /// </summary>
-        internal static string MainMenu {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.MainMenu);
-#else								
+        internal static string MainMenu
+        {
+            get
+            {
                 return ResourceManager.GetString("MainMenu", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to 
         ///A button, Space, Enter = ok
         ///B button, Esc = cancel.
         /// </summary>
-        internal static string MessageBoxUsage {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.MessageBoxUsage);
-#else								
+        internal static string MessageBoxUsage
+        {
+            get
+            {
                 return ResourceManager.GetString("MessageBoxUsage", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to {0} joined.
         /// </summary>
-        internal static string MessageGamerJoined {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.MessageGamerJoined);
-#else								
+        internal static string MessageGamerJoined
+        {
+            get
+            {
                 return ResourceManager.GetString("MessageGamerJoined", resourceCulture);
-#endif				
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to {0} left.
         /// </summary>
-        internal static string MessageGamerLeft {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.MessageGamerLeft);
-#else								
+        internal static string MessageGamerLeft
+        {
+            get
+            {
                 return ResourceManager.GetString("MessageGamerLeft", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Networking....
         /// </summary>
-        internal static string NetworkBusy {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.NetworkBusy);
-#else								
+        internal static string NetworkBusy
+        {
+            get
+            {
                 return ResourceManager.GetString("NetworkBusy", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to No sessions found.
         /// </summary>
-        internal static string NoSessionsFound {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.NoSessionsFound);
-#else								
+        internal static string NoSessionsFound
+        {
+            get
+            {
                 return ResourceManager.GetString("NoSessionsFound", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Paused.
         /// </summary>
-        internal static string Paused {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.Paused);
-#else								
+        internal static string Paused
+        {
+            get
+            {
                 return ResourceManager.GetString("Paused", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to LIVE.
         /// </summary>
-        internal static string PlayerMatch {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.PlayerMatch);
-#else								
+        internal static string PlayerMatch
+        {
+            get
+            {
                 return ResourceManager.GetString("PlayerMatch", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Quit Game.
         /// </summary>
-        internal static string QuitGame {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.QuitGame);
-#else								
+        internal static string QuitGame
+        {
+            get
+            {
                 return ResourceManager.GetString("QuitGame", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Resume Game.
         /// </summary>
-        internal static string ResumeGame {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ResumeGame);
-#else								
+        internal static string ResumeGame
+        {
+            get
+            {
                 return ResourceManager.GetString("ResumeGame", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Return to Lobby.
         /// </summary>
-        internal static string ReturnToLobby {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.ReturnToLobby);
-#else								
+        internal static string ReturnToLobby
+        {
+            get
+            {
                 return ResourceManager.GetString("ReturnToLobby", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to Single Player.
         /// </summary>
-        internal static string SinglePlayer {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.SinglePlayer);
-#else								
+        internal static string SinglePlayer
+        {
+            get
+            {
                 return ResourceManager.GetString("SinglePlayer", resourceCulture);
-#endif
             }
         }
-        
+
         /// <summary>
         ///   Looks up a localized string similar to System Link.
         /// </summary>
-        internal static string SystemLink {
-            get {
-#if ANDROID				
-				return  Android.App.Application.Context.Resources.GetString(CatapultWarsNet.Resource.String.SystemLink);
-#else								
+        internal static string SystemLink
+        {
+            get
+            {
                 return ResourceManager.GetString("SystemLink", resourceCulture);
-#endif
             }
         }
     }
-}
+}

+ 1 - 2
CatapultNetWars/Core/ScreenManager/GameScreen.cs

@@ -8,10 +8,9 @@
 using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Input.Touch;
-//using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
 using System.IO;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// Enum describes the screen transition state.

+ 2 - 2
CatapultNetWars/Core/ScreenManager/InputState.cs

@@ -11,7 +11,7 @@ using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Input;
 using Microsoft.Xna.Framework.Input.Touch;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
 	/// <summary>
 	/// Helper for reading input from keyboard, gamepad, and touch input. This class 
@@ -63,7 +63,7 @@ namespace GameStateManagement
 				LastKeyboardStates [i] = CurrentKeyboardStates [i];
 				LastGamePadStates [i] = CurrentGamePadStates [i];
 
-				CurrentKeyboardStates [i] = Keyboard.GetState ((PlayerIndex)i);
+				CurrentKeyboardStates [i] = Keyboard.GetState ();
 				CurrentGamePadStates [i] = GamePad.GetState ((PlayerIndex)i);
 
 				// Keep track of whether a gamepad has ever been

+ 10 - 7
CatapultNetWars/Core/ScreenManager/MenuEntry.cs

@@ -10,7 +10,7 @@ using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// Helper class represents a single entry in a MenuScreen. By default this
@@ -91,9 +91,11 @@ namespace GameStateManagement
         {
             // there is no such thing as a selected item on Windows Phone, so we always
             // force isSelected to be false
-#if WINDOWS_PHONE
-            isSelected = false;
-#endif
+            if (UIUtility.IsMobile)
+            {
+                isSelected = false;
+            }
+
             // When the menu selection changes, entries gradually fade between
             // their selected and deselected appearance, rather than instantly
             // popping to the new state.
@@ -113,9 +115,10 @@ namespace GameStateManagement
         {
             // there is no such thing as a selected item on Windows Phone, so we always
             // force isSelected to be false
-#if WINDOWS_PHONE
-            isSelected = false;
-#endif
+            if (UIUtility.IsMobile)
+            {
+                isSelected = false;
+            }
 
             // Draw the selected entry in yellow, otherwise white.
             Color color = isSelected ? Color.Yellow : Color.White;

+ 1 - 1
CatapultNetWars/Core/ScreenManager/MenuScreen.cs

@@ -12,7 +12,7 @@ using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework.Input.Touch;
 using Microsoft.Xna.Framework.Input;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// Base class for screens that contain a menu of options. The user can

+ 1 - 1
CatapultNetWars/Core/ScreenManager/MouseGestureType.cs

@@ -37,7 +37,7 @@
 // */
 using System;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
 	[Flags]
 	public enum MouseGestureType

+ 1 - 1
CatapultNetWars/Core/ScreenManager/PlayerIndexEventArgs.cs

@@ -8,7 +8,7 @@
 using System;
 using Microsoft.Xna.Framework;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// Custom event argument which includes the index of the player who

+ 1 - 1
CatapultNetWars/Core/ScreenManager/ScreenManager.cs

@@ -15,7 +15,7 @@ using Microsoft.Xna.Framework.Input.Touch;
 using System.IO;
 using System.IO.IsolatedStorage;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// The screen manager is a component which manages one or more GameScreen

+ 0 - 1
CatapultNetWars/Core/Screens/BackgroundScreen.cs

@@ -11,7 +11,6 @@ using System.Linq;
 using System.Text;
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework;
-using GameStateManagement;
 
 namespace CatapultGame
 {

Dosya farkı çok büyük olduğundan ihmal edildi
+ 437 - 330
CatapultNetWars/Core/Screens/GameplayScreen.cs


+ 10 - 61
CatapultNetWars/Core/Screens/InstructionsScreen.cs

@@ -13,19 +13,8 @@ using System.Threading;
 
 using Microsoft.Xna.Framework.Graphics;
 using Microsoft.Xna.Framework;
-using GameStateManagement;
 using Microsoft.Xna.Framework.Input.Touch;
-
-#if MONOMAC
-using MonoMac.AppKit;
-using MonoMac.Foundation;
-#endif
-
-#if IPHONE
-using MonoTouch.UIKit;
-using MonoTouch.Foundation;
-#endif
-
+using Microsoft.Xna.Framework.Input;
 
 namespace CatapultGame
 {
@@ -73,38 +62,29 @@ namespace CatapultGame
 		{
 			if (isLoading == true)
             {
-#if ANDROID || IPHONE || LINUX || WINDOWS
                 // Exit the screen and show the gameplay screen 
 					// with pre-loaded assets
 				ExitScreen ();
 				ScreenManager.AddScreen (gameplayScreen, null);
-#endif						
+					
 				base.HandleInput (input);
 				return;
 			}
+
 			PlayerIndex player;
-			if (input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Space, ControllingPlayer, out player) ||
-			    input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Enter, ControllingPlayer, out player) ||
+			if (input.IsNewKeyPress (Keys.Space, ControllingPlayer, out player) ||
+			    input.IsNewKeyPress (Keys.Enter, ControllingPlayer, out player) ||
 			    input.MouseGesture.HasFlag(MouseGestureType.LeftClick) ||
-			    input.IsNewButtonPress (Microsoft.Xna.Framework.Input.Buttons.Start, ControllingPlayer, out player)) {
+			    input.IsNewButtonPress (Buttons.Start, ControllingPlayer, out player)) {
 				// Create a new instance of the gameplay screen
 				gameplayScreen = new GameplayScreen ();
 				gameplayScreen.ScreenManager = ScreenManager;
 
-                // Start loading the resources in additional thread
-#if !LINUX && !WINDOWS
-#if MONOMAC
-				// create a new thread using BackgroundWorkerThread as method to execute
-				thread = new Thread (LoadAssetsWorkerThread as ThreadStart);
-#else     
-				thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));    
-#endif
+                // Start loading the resources in additional thread    
+				thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
 				isLoading = true;
 				// start it
 				thread.Start ();
-#else
-                isLoading = true;
-#endif
 			}
 
 			foreach (var gesture in input.Gestures) {
@@ -112,48 +92,17 @@ namespace CatapultGame
 					// Create a new instance of the gameplay screen
 					gameplayScreen = new GameplayScreen ();
 					gameplayScreen.ScreenManager = ScreenManager;
-
-#if ANDROID || IPHONE	|| LINUX || WINDOWS
-                    isLoading = true;									
-#else						
+						
 					// Start loading the resources in additional thread
 					thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
 					isLoading = true;
-					thread.Start ();
-#endif					
+					thread.Start ();				
 				}
 			}
 
 			base.HandleInput (input);
 		}
 
-		void LoadAssetsWorkerThread ()
-		{
-
-
-#if MONOMAC || IPHONE			
-			// Create an Autorelease Pool or we will leak objects.
-			using (var pool = new NSAutoreleasePool()) {
-#else				
-				
-#endif
-				// Make sure we invoke this on the Main Thread or OpenGL will throw an error
-#if MONOMAC
-				MonoMac.AppKit.NSApplication.SharedApplication.BeginInvokeOnMainThread (delegate {
-#endif
-#if IPHONE
-				var invokeOnMainThredObj = new NSObject();
-				invokeOnMainThredObj.InvokeOnMainThread(delegate {
-#endif
-					gameplayScreen.LoadAssets ();
-#if MONOMAC || IPHONE						
-				});
-					
-			}				
-#endif	
-
-		}
-
 		public override void Draw (GameTime gameTime)
 		{
 			SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

+ 101 - 90
CatapultNetWars/Core/Screens/LoadingScreen.cs

@@ -10,8 +10,7 @@ using System.Threading;
 using System.Diagnostics;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Graphics;
-//using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
-using GameStateManagement;
+using Microsoft.Xna.Framework.Net;
 
 namespace CatapultGame
 {
@@ -38,7 +37,7 @@ namespace CatapultGame
 		Thread backgroundThread;
 		EventWaitHandle backgroundThreadExit;
 		GraphicsDevice graphicsDevice;
-		// NetworkSession networkSession; // Not available in MonoGame 3.8
+		NetworkSession networkSession;
 		IMessageDisplay messageDisplay;
 		GameTime loadStartTime;
 		TimeSpan loadAnimationTimer;
@@ -50,30 +49,31 @@ namespace CatapultGame
 		/// The constructor is private: loading screens should
 		/// be activated via the static Load method instead.
 		/// </summary>
-		private LoadingScreen (ScreenManager screenManager,bool loadingIsSlow, 
+		private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
 				GameScreen[] screensToLoad)
-			{
+		{
 			this.loadingIsSlow = loadingIsSlow;
 			this.screensToLoad = screensToLoad;
 
-			TransitionOnTime = TimeSpan.FromSeconds (0.5);
+			TransitionOnTime = TimeSpan.FromSeconds(0.5);
 
 			// If this is going to be a slow load operation, create a background
 			// thread that will update the network session and draw the load screen
 			// animation while the load is taking place.
-			if (loadingIsSlow) {
-				backgroundThread = new Thread (BackgroundWorkerThread);
-				backgroundThreadExit = new ManualResetEvent (false);
+			if (loadingIsSlow)
+			{
+				backgroundThread = new Thread(BackgroundWorkerThread);
+				backgroundThreadExit = new ManualResetEvent(false);
 
 				graphicsDevice = screenManager.GraphicsDevice;
-			// Look up some services that will be used by the background thread.
-			IServiceProvider services = screenManager.Game.Services;
+				// Look up some services that will be used by the background thread.
+				IServiceProvider services = screenManager.Game.Services;
 
-			// networkSession = (NetworkSession)services.GetService (
-			//		typeof(NetworkSession)); // Not available in MonoGame 3.8
+				networkSession = (NetworkSession)services.GetService(
+						typeof(NetworkSession));
 
-			messageDisplay = (IMessageDisplay)services.GetService (
-						typeof(IMessageDisplay));
+				messageDisplay = (IMessageDisplay)services.GetService(
+							typeof(IMessageDisplay));
 			}
 		}
 
@@ -81,20 +81,20 @@ namespace CatapultGame
 		/// <summary>
 		/// Activates the loading screen.
 		/// </summary>
-		public static void Load (ScreenManager screenManager, bool loadingIsSlow,
+		public static void Load(ScreenManager screenManager, bool loadingIsSlow,
 				PlayerIndex? controllingPlayer,
 				params GameScreen[] screensToLoad)
 		{
 			// Tell all the current screens to transition off.
-			foreach (GameScreen screen in screenManager.GetScreens ())
-				screen.ExitScreen ();
+			foreach (GameScreen screen in screenManager.GetScreens())
+				screen.ExitScreen();
 
 			// Create and activate the loading screen.
-			LoadingScreen loadingScreen = new LoadingScreen (screenManager,
+			LoadingScreen loadingScreen = new LoadingScreen(screenManager,
 							loadingIsSlow,
 							screensToLoad);
 
-			screenManager.AddScreen (loadingScreen, controllingPlayer);
+			screenManager.AddScreen(loadingScreen, controllingPlayer);
 		}
 
 
@@ -104,40 +104,45 @@ namespace CatapultGame
 		/// <summary>
 		/// Updates the loading screen.
 		/// </summary>
-		public override void Update (GameTime gameTime, bool otherScreenHasFocus,
+		public override void Update(GameTime gameTime, bool otherScreenHasFocus,
 							bool coveredByOtherScreen)
 		{
-			base.Update (gameTime, otherScreenHasFocus, coveredByOtherScreen);
+			base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
 
 			// If all the previous screens have finished transitioning
 			// off, it is time to actually perform the load.
-			if (otherScreensAreGone) {
+			if (otherScreensAreGone)
+			{
 				// Start up the background thread, which will update the network
 				// session and draw the animation while we are loading.
-				if (backgroundThread != null) {
+				if (backgroundThread != null)
+				{
 					loadStartTime = gameTime;
-					backgroundThread.Start ();
+					backgroundThread.Start();
 				}
 
 				// Perform the load operation.
-				ScreenManager.RemoveScreen (this);
+				ScreenManager.RemoveScreen(this);
 
-				foreach (GameScreen screen in screensToLoad) {
-					if (screen != null) {
-						ScreenManager.AddScreen (screen, ControllingPlayer);
+				foreach (GameScreen screen in screensToLoad)
+				{
+					if (screen != null)
+					{
+						ScreenManager.AddScreen(screen, ControllingPlayer);
 					}
 				}
 
 				// Signal the background thread to exit, then wait for it to do so.
-				if (backgroundThread != null) {
-					backgroundThreadExit.Set ();
-					backgroundThread.Join ();
+				if (backgroundThread != null)
+				{
+					backgroundThreadExit.Set();
+					backgroundThread.Join();
 				}
 
 				// Once the load has finished, we use ResetElapsedTime to tell
 				// the  game timing mechanism that we have just finished a very
 				// long frame, and that it should not try to catch up.
-				ScreenManager.Game.ResetElapsedTime ();
+				ScreenManager.Game.ResetElapsedTime();
 			}
 		}
 
@@ -145,15 +150,16 @@ namespace CatapultGame
 		/// <summary>
 		/// Draws the loading screen.
 		/// </summary>
-		public override void Draw (GameTime gameTime)
+		public override void Draw(GameTime gameTime)
 		{
 			// If we are the only active screen, that means all the previous screens
 			// must have finished transitioning off. We check for this in the Draw
 			// method, rather than in Update, because it isn't enough just for the
 			// screens to be gone: in order for the transition to look good we must
 			// have actually drawn a frame without them before we perform the load.
-			if ((ScreenState == ScreenState.Active) && 
-		(ScreenManager.GetScreens ().Length == 1)) {
+			if ((ScreenState == ScreenState.Active) &&
+		(ScreenManager.GetScreens().Length == 1))
+			{
 				otherScreensAreGone = true;
 			}
 
@@ -163,7 +169,8 @@ namespace CatapultGame
 			// second while returning from the game to the menus. This parameter
 			// tells us how long the loading is going to take, so we know whether
 			// to bother drawing the message.
-			if (loadingIsSlow) {
+			if (loadingIsSlow)
+			{
 				SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
 				SpriteFont font = ScreenManager.Font;
 
@@ -171,8 +178,8 @@ namespace CatapultGame
 
 				// Center the text in the viewport.
 				Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
-				Vector2 viewportSize = new Vector2 (viewport.Width, viewport.Height);
-				Vector2 textSize = font.MeasureString (message);
+				Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
+				Vector2 textSize = font.MeasureString(message);
 				Vector2 textPosition = (viewportSize - textSize) / 2;
 
 				Color color = Color.White * TransitionAlpha;
@@ -182,12 +189,12 @@ namespace CatapultGame
 
 				int dotCount = (int)(loadAnimationTimer.TotalSeconds * 5) % 10;
 
-				message += new string ('.', dotCount);
+				message += new string('.', dotCount);
 
 				// Draw the text.
-				spriteBatch.Begin ();
-				spriteBatch.DrawString (font, message, textPosition, color);
-				spriteBatch.End ();
+				spriteBatch.Begin();
+				spriteBatch.DrawString(font, message, textPosition, color);
+				spriteBatch.End();
 			}
 		}
 
@@ -199,65 +206,70 @@ namespace CatapultGame
 		/// Worker thread draws the loading animation and updates the network
 		/// session while the load is taking place.
 		/// </summary>
-		void BackgroundWorkerThread ()
+		void BackgroundWorkerThread()
 		{
-			long lastTime = Stopwatch.GetTimestamp ();
+			long lastTime = Stopwatch.GetTimestamp();
 
 			// EventWaitHandle.WaitOne will return true if the exit signal has
 			// been triggered, or false if the timeout has expired. We use the
 			// timeout to update at regular intervals, then break out of the
 			// loop when we are signalled to exit.
-			while (!backgroundThreadExit.WaitOne (1000 / 30)) {
+			while (!backgroundThreadExit.WaitOne(1000 / 30))
+			{
 				//GameTime gameTime = GetGameTime (ref lastTime);
 
 				//DrawLoadAnimation (gameTime);
 
-				UpdateNetworkSession ();
+				UpdateNetworkSession();
 			}
 		}
 
 
-//		/// <summary>
-//		/// Works out how long it has been since the last background thread update.
-//		/// </summary>
-//		GameTime GetGameTime (ref long lastTime)
-//		{
-//			long currentTime = Stopwatch.GetTimestamp ();
-//			long elapsedTicks = currentTime - lastTime;
-//			lastTime = currentTime;
-//
-//			TimeSpan elapsedTime = TimeSpan.FromTicks (elapsedTicks * 
-//						TimeSpan.TicksPerSecond / 
-//						Stopwatch.Frequency);
-//
-//			return new GameTime (loadStartTime.TotalGameTime + elapsedTime, elapsedTime);
-//		}
+		//		/// <summary>
+		//		/// Works out how long it has been since the last background thread update.
+		//		/// </summary>
+		//		GameTime GetGameTime (ref long lastTime)
+		//		{
+		//			long currentTime = Stopwatch.GetTimestamp ();
+		//			long elapsedTicks = currentTime - lastTime;
+		//			lastTime = currentTime;
+		//
+		//			TimeSpan elapsedTime = TimeSpan.FromTicks (elapsedTicks * 
+		//						TimeSpan.TicksPerSecond / 
+		//						Stopwatch.Frequency);
+		//
+		//			return new GameTime (loadStartTime.TotalGameTime + elapsedTime, elapsedTime);
+		//		}
 
 
 		/// <summary>
 		/// Calls directly into our Draw method from the background worker thread,
 		/// so as to update the load animation in parallel with the actual loading.
 		/// </summary>
-		void DrawLoadAnimation (GameTime gameTime)
+		void DrawLoadAnimation(GameTime gameTime)
 		{
 			if ((graphicsDevice == null) || graphicsDevice.IsDisposed)
 				return;
 
-			try			{
-				graphicsDevice.Clear (Color.Black);
+			try
+			{
+				graphicsDevice.Clear(Color.Black);
 
 				// Draw the loading screen.
-				Draw (gameTime);
+				Draw(gameTime);
 
 				// If we have a message display component, we want to display
 				// that over the top of the loading screen, too.
-				if (messageDisplay != null) {
-					messageDisplay.Update (gameTime);
-					messageDisplay.Draw (gameTime);
+				if (messageDisplay != null)
+				{
+					messageDisplay.Update(gameTime);
+					messageDisplay.Draw(gameTime);
 				}
 
-				graphicsDevice.Present ();
-			} catch {
+				graphicsDevice.Present();
+			}
+			catch
+			{
 				// If anything went wrong (for instance the graphics device was lost
 				// or reset) we don't have any good way to recover while running on a
 				// background thread. Setting the device to null will stop us from
@@ -271,25 +283,24 @@ namespace CatapultGame
 		/// Updates the network session from the background worker thread, to avoid
 		/// disconnecting due to network timeouts even if loading takes a long time.
 		/// </summary>
-		void UpdateNetworkSession ()
+		void UpdateNetworkSession()
 		{
-			// if ((networkSession == null) || 
-			//	(networkSession.SessionState == NetworkSessionState.Ended))
-			//	return;
-
-			// try			{
-			//	networkSession.Update ();
-			// } catch {
-			//	// If anything went wrong, we don't have a good way to report that
-			//	// error while running on a background thread. Setting the session to
-			//	// null will stop us from updating it, so the main game can deal with
-			//	// the problem later on.
-			//	networkSession = null;
-			// }
-			
-			// No networking in MonoGame 3.8 version
-		}
-
+			if ((networkSession == null) ||
+			   (networkSession.SessionState == NetworkSessionState.Ended))
+				return;
 
+			try
+			{
+				networkSession.Update();
+			}
+			catch
+			{
+				// If anything went wrong, we don't have a good way to report that
+				// error while running on a background thread. Setting the session to
+				// null will stop us from updating it, so the main game can deal with
+				// the problem later on.
+				networkSession = null;
+			}
+		}
 	}
-}
+}

+ 25 - 32
CatapultNetWars/Core/Screens/MainMenuScreen.cs

@@ -9,9 +9,9 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using GameStateManagement;
+
 using Microsoft.Xna.Framework;
-//using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
+using Microsoft.Xna.Framework.Net;
 
 namespace CatapultGame
 {
@@ -60,9 +60,9 @@ namespace CatapultGame
         /// <param name="e"></param>
         void StartGameMenuEntrySelected(object sender, EventArgs e)
         {
-		// Lets make sure we get rid of our network session
-		// so we can start up clean
-		// ScreenManager.Game.Services.RemoveService(typeof(NetworkSession)); // Not available in MonoGame 3.8
+            // Lets make sure we get rid of our network session
+            // so we can start up clean
+            ScreenManager.Game.Services.RemoveService(typeof(NetworkSession));
             ScreenManager.AddScreen(new InstructionsScreen(), null);
         }
 
@@ -75,38 +75,31 @@ namespace CatapultGame
             ScreenManager.Game.Exit();
         }
 
-        void StartMultiPlayerGameMenuEntrySelected (object sender, PlayerIndexEventArgs e)
+        void StartMultiPlayerGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
         {
-		// Networking disabled in MonoGame 3.8 - start single player game instead
-		LoadingScreen.Load (ScreenManager, true, e.PlayerIndex, new GameplayScreen ());
+            CreateOrFindSession(NetworkSessionType.SystemLink, e.PlayerIndex);
         }
 
-		/// <summary>
-		/// Helper method shared by the Live and System Link menu event handlers.
-		/// </summary>
-		/*
-		// Networking methods disabled in MonoGame 3.8
-		void CreateOrFindSession (NetworkSessionType sessionType,
-				PlayerIndex playerIndex)
-		{
-
-			// First, we need to make sure a suitable gamer profile is signed in.
-			ProfileSignInScreen profileSignIn = new ProfileSignInScreen (sessionType);
-
-			// Hook up an event so once the ProfileSignInScreen is happy,
-			// it will activate the CreateOrFindSessionScreen.
-			profileSignIn.ProfileSignedIn += delegate
-				{
-					GameScreen createOrFind = new CreateOrFindSessionScreen (sessionType);
+        /// <summary>
+        /// Helper method shared by the Live and System Link menu event handlers.
+        /// </summary>
+        void CreateOrFindSession(NetworkSessionType sessionType, PlayerIndex playerIndex)
+        {
 
-					ScreenManager.AddScreen (createOrFind, playerIndex);
-				};
+            // First, we need to make sure a suitable gamer profile is signed in.
+            ProfileSignInScreen profileSignIn = new ProfileSignInScreen(sessionType);
 
-			// Activate the ProfileSignInScreen.
-			ScreenManager.AddScreen (profileSignIn, playerIndex);
-		}
-		*/
+            // Hook up an event so once the ProfileSignInScreen is happy,
+            // it will activate the CreateOrFindSessionScreen.
+            profileSignIn.ProfileSignedIn += delegate
+                {
+                    GameScreen createOrFind = new CreateOrFindSessionScreen(sessionType);
 
+                    ScreenManager.AddScreen(createOrFind, playerIndex);
+                };
 
+            // Activate the ProfileSignInScreen.
+            ScreenManager.AddScreen(profileSignIn, playerIndex);
+        }
     }
-}
+}

+ 2 - 19
CatapultNetWars/Core/Screens/MessageBoxScreen.cs

@@ -9,10 +9,8 @@ using System;
 using Microsoft.Xna.Framework;
 using Microsoft.Xna.Framework.Content;
 using Microsoft.Xna.Framework.Graphics;
-using CatapultGame;
-using Microsoft.Xna.Framework.Input.Touch;
 
-namespace GameStateManagement
+namespace CatapultGame
 {
     /// <summary>
     /// A popup message box screen, used to display "are you sure?"
@@ -47,8 +45,6 @@ namespace GameStateManagement
         /// </summary>
         public MessageBoxScreen(string message, bool includeUsageText)
         {
-			EnabledGestures = GestureType.Tap;
-			
             if (includeUsageText)
                 this.message = message + Resources.MessageBoxUsage;
             else
@@ -106,19 +102,6 @@ namespace GameStateManagement
 
                 ExitScreen();
             }
-			if (input.Gestures.Count > 0)
-			{
-				foreach(var g in input.Gestures)
-				{
-					if (g.GestureType == Microsoft.Xna.Framework.Input.Touch.GestureType.Tap)
-					{
-						if (Accepted != null)
-                           Accepted(this, new PlayerIndexEventArgs(playerIndex));
-
-                        ExitScreen();
-					}
-				}
-			}
         }
 
 
@@ -167,4 +150,4 @@ namespace GameStateManagement
 
 
     }
-}
+}

+ 13 - 16
CatapultNetWars/Core/Screens/PauseScreen.cs

@@ -9,9 +9,8 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using GameStateManagement;
 using Microsoft.Xna.Framework;
-//using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
+using Microsoft.Xna.Framework.Net;
 
 namespace CatapultGame
 {
@@ -98,22 +97,20 @@ namespace CatapultGame
         /// 
         protected override void OnCancel(PlayerIndex playerIndex)
         {
-		// Tear down our network session
-		/* // Networking disabled in MonoGame 3.8
-		NetworkSession session = ScreenManager.Game.Services.GetService (typeof(NetworkSession)) as NetworkSession;
-		if (session != null) {
-			if (session.AllGamers.Count == 1) {
-				session.EndGame();
-			}
-			session.Dispose();
-			ScreenManager.Game.Services.RemoveService(typeof(NetworkSession));
-		}
-		*/
+            // Tear down our network session
+            NetworkSession session = ScreenManager.Game.Services.GetService(typeof(NetworkSession)) as NetworkSession;
+            if (session != null)
+            {
+                if (session.AllGamers.Count == 1)
+                {
+                    session.EndGame();
+                }
+                session.Dispose();
+                ScreenManager.Game.Services.RemoveService(typeof(NetworkSession));
+            }
             AudioManager.StopSounds();
             ScreenManager.AddScreen(new MainMenuScreen(), null);
             ExitScreen();
-
-
         }
     }
-}
+}

+ 27 - 0
CatapultNetWars/Core/Utility/UIUtility.cs

@@ -0,0 +1,27 @@
+//-----------------------------------------------------------------------------
+// UIUtilty.cs
+//
+// Microsoft XNA Community Game Platform
+// Copyright (C) Microsoft Corporation. All rights reserved.
+//-----------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CatapultGame
+{
+    public static class UIUtility
+    {
+        /// <summary>
+        /// Indicates if the game is running on a mobile platform.
+        /// </summary>
+        public readonly static bool IsMobile = OperatingSystem.IsAndroid() || OperatingSystem.IsIOS();
+
+        /// <summary>
+        /// Indicates if the game is running on a desktop platform.
+        /// </summary>
+        public readonly static bool IsDesktop = OperatingSystem.IsMacOS() || OperatingSystem.IsLinux() || OperatingSystem.IsWindows();
+
+    }
+}

+ 0 - 0
CatapultNetWars/Platforms/Android/Activity1.cs → CatapultNetWars/Platforms/Android/MainActivity.cs


+ 0 - 0
CatapultNetWars/Platforms/Android/Program.cs


+ 0 - 0
CatapultNetWars/Screens/GameplayScreen.cs


+ 0 - 0
CatapultNetWars/Screens/LoadingScreen.cs


+ 0 - 0
CatapultNetWars/Screens/MainMenuScreen.cs


+ 0 - 0
CatapultNetWars/Screens/PauseScreen.cs


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor