From 701b860f7ef3d5316473a0fe0ee94df2c88f33ac Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 14 Feb 2012 16:22:54 +0000 Subject: Added initial solution --- wpspec.sln | 54 ++++++ wpspec/wpspec/App.xaml | 23 +++ wpspec/wpspec/App.xaml.cs | 196 +++++++++++++++++++++ wpspec/wpspec/AppServiceProvider.cs | 63 +++++++ wpspec/wpspec/ApplicationIcon.png | Bin 0 -> 1881 bytes wpspec/wpspec/Background.png | Bin 0 -> 3521 bytes wpspec/wpspec/GamePage.xaml | 18 ++ wpspec/wpspec/GamePage.xaml.cs | 84 +++++++++ wpspec/wpspec/MainPage.xaml | 50 ++++++ wpspec/wpspec/MainPage.xaml.cs | 30 ++++ wpspec/wpspec/Properties/AppManifest.xml | 5 + wpspec/wpspec/Properties/AssemblyInfo.cs | 37 ++++ wpspec/wpspec/Properties/WMAppManifest.xml | 35 ++++ wpspec/wpspec/SplashScreenImage.jpg | Bin 0 -> 9417 bytes wpspec/wpspec/wpspec.csproj | 124 +++++++++++++ wpspec/wpspecLib/Properties/AssemblyInfo.cs | 36 ++++ wpspec/wpspecLib/wpspecLib.csproj | 76 ++++++++ .../wpspecLibContent/wpspecLibContent.contentproj | 52 ++++++ 18 files changed, 883 insertions(+) create mode 100644 wpspec.sln create mode 100644 wpspec/wpspec/App.xaml create mode 100644 wpspec/wpspec/App.xaml.cs create mode 100644 wpspec/wpspec/AppServiceProvider.cs create mode 100644 wpspec/wpspec/ApplicationIcon.png create mode 100644 wpspec/wpspec/Background.png create mode 100644 wpspec/wpspec/GamePage.xaml create mode 100644 wpspec/wpspec/GamePage.xaml.cs create mode 100644 wpspec/wpspec/MainPage.xaml create mode 100644 wpspec/wpspec/MainPage.xaml.cs create mode 100644 wpspec/wpspec/Properties/AppManifest.xml create mode 100644 wpspec/wpspec/Properties/AssemblyInfo.cs create mode 100644 wpspec/wpspec/Properties/WMAppManifest.xml create mode 100644 wpspec/wpspec/SplashScreenImage.jpg create mode 100644 wpspec/wpspec/wpspec.csproj create mode 100644 wpspec/wpspecLib/Properties/AssemblyInfo.cs create mode 100644 wpspec/wpspecLib/wpspecLib.csproj create mode 100644 wpspec/wpspecLibContent/wpspecLibContent.contentproj diff --git a/wpspec.sln b/wpspec.sln new file mode 100644 index 0000000..5c4295c --- /dev/null +++ b/wpspec.sln @@ -0,0 +1,54 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Express for Windows Phone +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wpspec", "wpspec\wpspec\wpspec.csproj", "{915C2100-66C8-4C32-8980-0504548D291A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wpspecLib", "wpspec\wpspecLib\wpspecLib.csproj", "{54C6C396-4BCE-4E3C-936C-846FFEFD44FB}" +EndProject +Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "wpspecLibContent", "wpspec\wpspecLibContent\wpspecLibContent.contentproj", "{D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Windows Phone = Debug|Windows Phone + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Windows Phone = Release|Windows Phone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Any CPU.Build.0 = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Any CPU.Deploy.0 = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU + {915C2100-66C8-4C32-8980-0504548D291A}.Release|Windows Phone.ActiveCfg = Release|Any CPU + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Debug|Windows Phone.Build.0 = Debug|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Release|Any CPU.ActiveCfg = Release|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Release|Mixed Platforms.Build.0 = Release|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + {54C6C396-4BCE-4E3C-936C-846FFEFD44FB}.Release|Windows Phone.Build.0 = Release|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Release|Any CPU.ActiveCfg = Release|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone + {D1AEDB5A-7350-4E29-8F2F-5AFCFAD8D000}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/wpspec/wpspec/App.xaml b/wpspec/wpspec/App.xaml new file mode 100644 index 0000000..52ae9e0 --- /dev/null +++ b/wpspec/wpspec/App.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wpspec/wpspec/App.xaml.cs b/wpspec/wpspec/App.xaml.cs new file mode 100644 index 0000000..f7d26ef --- /dev/null +++ b/wpspec/wpspec/App.xaml.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace wpspec +{ + public partial class App : Application + { + /// + /// Provides easy access to the root frame of the Phone Application. + /// + /// The root frame of the Phone Application. + public PhoneApplicationFrame RootFrame { get; private set; } + + /// + /// Provides access to a ContentManager for the application. + /// + public ContentManager Content { get; private set; } + + /// + /// Provides access to a GameTimer that is set up to pump the FrameworkDispatcher. + /// + public GameTimer FrameworkDispatcherTimer { get; private set; } + + /// + /// Provides access to the AppServiceProvider for the application. + /// + public AppServiceProvider Services { get; private set; } + + /// + /// Constructor for the Application object. + /// + public App() + { + // Global handler for uncaught exceptions. + UnhandledException += Application_UnhandledException; + + // Standard Silverlight initialization + InitializeComponent(); + + // Phone-specific initialization + InitializePhoneApplication(); + + // XNA initialization + InitializeXnaApplication(); + + // Show graphics profiling information while debugging. + if (System.Diagnostics.Debugger.IsAttached) + { + // Display the current frame rate counters. + Application.Current.Host.Settings.EnableFrameRateCounter = true; + + // Show the areas of the app that are being redrawn in each frame. + //Application.Current.Host.Settings.EnableRedrawRegions = true; + + // Enable non-production analysis visualization mode, + // which shows areas of a page that are handed off to GPU with a colored overlay. + //Application.Current.Host.Settings.EnableCacheVisualization = true; + + // Disable the application idle detection by setting the UserIdleDetectionMode property of the + // application's PhoneApplicationService object to Disabled. + // Caution:- Use this under debug mode only. Applications that disable user idle detection will continue to run + // and consume battery power when the user is not using the phone. + PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; + } + } + + // Code to execute when the application is launching (eg, from Start) + // This code will not execute when the application is reactivated + private void Application_Launching(object sender, LaunchingEventArgs e) + { + } + + // Code to execute when the application is activated (brought to foreground) + // This code will not execute when the application is first launched + private void Application_Activated(object sender, ActivatedEventArgs e) + { + } + + // Code to execute when the application is deactivated (sent to background) + // This code will not execute when the application is closing + private void Application_Deactivated(object sender, DeactivatedEventArgs e) + { + } + + // Code to execute when the application is closing (eg, user hit Back) + // This code will not execute when the application is deactivated + private void Application_Closing(object sender, ClosingEventArgs e) + { + } + + // Code to execute if a navigation fails + private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) + { + if (System.Diagnostics.Debugger.IsAttached) + { + // A navigation has failed; break into the debugger + System.Diagnostics.Debugger.Break(); + } + } + + // Code to execute on Unhandled Exceptions + private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (System.Diagnostics.Debugger.IsAttached) + { + // An unhandled exception has occurred; break into the debugger + System.Diagnostics.Debugger.Break(); + } + } + + #region Phone application initialization + + // Avoid double-initialization + private bool phoneApplicationInitialized = false; + + // Do not add any additional code to this method + private void InitializePhoneApplication() + { + if (phoneApplicationInitialized) + return; + + // Create the frame but don't set it as RootVisual yet; this allows the splash + // screen to remain active until the application is ready to render. + RootFrame = new PhoneApplicationFrame(); + RootFrame.Navigated += CompleteInitializePhoneApplication; + + // Handle navigation failures + RootFrame.NavigationFailed += RootFrame_NavigationFailed; + + // Ensure we don't initialize again + phoneApplicationInitialized = true; + } + + // Do not add any additional code to this method + private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) + { + // Set the root visual to allow the application to render + if (RootVisual != RootFrame) + RootVisual = RootFrame; + + // Remove this handler since it is no longer needed + RootFrame.Navigated -= CompleteInitializePhoneApplication; + } + + #endregion + + #region XNA application initialization + + // Performs initialization of the XNA types required for the application. + private void InitializeXnaApplication() + { + // Create the service provider + Services = new AppServiceProvider(); + + // Add the SharedGraphicsDeviceManager to the Services as the IGraphicsDeviceService for the app + foreach (object obj in ApplicationLifetimeObjects) + { + if (obj is IGraphicsDeviceService) + Services.AddService(typeof(IGraphicsDeviceService), obj); + } + + // Create the ContentManager so the application can load precompiled assets + Content = new ContentManager(Services, "Content"); + + // Create a GameTimer to pump the XNA FrameworkDispatcher + FrameworkDispatcherTimer = new GameTimer(); + FrameworkDispatcherTimer.FrameAction += FrameworkDispatcherFrameAction; + FrameworkDispatcherTimer.Start(); + } + + // An event handler that pumps the FrameworkDispatcher each frame. + // FrameworkDispatcher is required for a lot of the XNA events and + // for certain functionality such as SoundEffect playback. + private void FrameworkDispatcherFrameAction(object sender, EventArgs e) + { + FrameworkDispatcher.Update(); + } + + #endregion + } +} \ No newline at end of file diff --git a/wpspec/wpspec/AppServiceProvider.cs b/wpspec/wpspec/AppServiceProvider.cs new file mode 100644 index 0000000..5b02182 --- /dev/null +++ b/wpspec/wpspec/AppServiceProvider.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; + +namespace wpspec +{ + /// + /// Implements IServiceProvider for the application. This type is exposed through the App.Services + /// property and can be used for ContentManagers or other types that need access to an IServiceProvider. + /// + public class AppServiceProvider : IServiceProvider + { + // A map of service type to the services themselves + private readonly Dictionary services = new Dictionary(); + + /// + /// Adds a new service to the service provider. + /// + /// The type of service to add. + /// The service object itself. + public void AddService(Type serviceType, object service) + { + // Validate the input + if (serviceType == null) + throw new ArgumentNullException("serviceType"); + if (service == null) + throw new ArgumentNullException("service"); + if (!serviceType.IsAssignableFrom(service.GetType())) + throw new ArgumentException("service does not match the specified serviceType"); + + // Add the service to the dictionary + services.Add(serviceType, service); + } + + /// + /// Gets a service from the service provider. + /// + /// The type of service to retrieve. + /// The service object registered for the specified type.. + public object GetService(Type serviceType) + { + // Validate the input + if (serviceType == null) + throw new ArgumentNullException("serviceType"); + + // Retrieve the service from the dictionary + return services[serviceType]; + } + + /// + /// Removes a service from the service provider. + /// + /// The type of service to remove. + public void RemoveService(Type serviceType) + { + // Validate the input + if (serviceType == null) + throw new ArgumentNullException("serviceType"); + + // Remove the service from the dictionary + services.Remove(serviceType); + } + } +} diff --git a/wpspec/wpspec/ApplicationIcon.png b/wpspec/wpspec/ApplicationIcon.png new file mode 100644 index 0000000..5859393 Binary files /dev/null and b/wpspec/wpspec/ApplicationIcon.png differ diff --git a/wpspec/wpspec/Background.png b/wpspec/wpspec/Background.png new file mode 100644 index 0000000..e46f21d Binary files /dev/null and b/wpspec/wpspec/Background.png differ diff --git a/wpspec/wpspec/GamePage.xaml b/wpspec/wpspec/GamePage.xaml new file mode 100644 index 0000000..69a5bd9 --- /dev/null +++ b/wpspec/wpspec/GamePage.xaml @@ -0,0 +1,18 @@ + + + + + diff --git a/wpspec/wpspec/GamePage.xaml.cs b/wpspec/wpspec/GamePage.xaml.cs new file mode 100644 index 0000000..97f4c92 --- /dev/null +++ b/wpspec/wpspec/GamePage.xaml.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Microsoft.Phone.Controls; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; + +namespace wpspec +{ + public partial class GamePage : PhoneApplicationPage + { + ContentManager contentManager; + GameTimer timer; + SpriteBatch spriteBatch; + + public GamePage() + { + InitializeComponent(); + + // Get the content manager from the application + contentManager = (Application.Current as App).Content; + + // Create a timer for this page + timer = new GameTimer(); + timer.UpdateInterval = TimeSpan.FromTicks(333333); + timer.Update += OnUpdate; + timer.Draw += OnDraw; + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + // Set the sharing mode of the graphics device to turn on XNA rendering + SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true); + + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice); + + // TODO: use this.content to load your game content here + + // Start the timer + timer.Start(); + + base.OnNavigatedTo(e); + } + + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + // Stop the timer + timer.Stop(); + + // Set the sharing mode of the graphics device to turn off XNA rendering + SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false); + + base.OnNavigatedFrom(e); + } + + /// + /// Allows the page to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + private void OnUpdate(object sender, GameTimerEventArgs e) + { + // TODO: Add your update logic here + } + + /// + /// Allows the page to draw itself. + /// + private void OnDraw(object sender, GameTimerEventArgs e) + { + SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue); + + // TODO: Add your drawing code here + } + } +} \ No newline at end of file diff --git a/wpspec/wpspec/MainPage.xaml b/wpspec/wpspec/MainPage.xaml new file mode 100644 index 0000000..3043378 --- /dev/null +++ b/wpspec/wpspec/MainPage.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + +