Example #1
0
 public static void RunGameTest(GameBase game)
 {
     using (game)
     {
         game.Run();
     }
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameSystemBase" /> class.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <remarks>
 /// The GameSystem is expecting the following services to be registered: <see cref="IGame"/> and <see cref="IAssetManager"/>.
 /// </remarks>
 protected GameSystemBase(IServiceRegistry registry)
 {
     if (registry == null) throw new ArgumentNullException("registry");
     this.registry = registry;
     game = (GameBase)Services.GetServiceAs<IGame>();
     assetManager = Services.GetSafeServiceAs<IAssetManager>();
 }
Example #3
0
        public static GamePlatform Create(GameBase game)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
            return(new GamePlatformWindowsRuntime(game));
#elif SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
            return(new GamePlatformOpenTK(game));
#elif SILICONSTUDIO_PLATFORM_ANDROID
            return(new GamePlatformAndroid(game));
#elif SILICONSTUDIO_PLATFORM_IOS
            return(new GamePlatformiOS(game));
#else
            return(new GamePlatformDesktop(game));
#endif
        }
Example #4
0
        public static GamePlatform Create(GameBase game)
        {
#if SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME
            return new GamePlatformWindowsRuntime(game);
#elif SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
            return new GamePlatformOpenTK(game);
#elif SILICONSTUDIO_PLATFORM_ANDROID
            return new GamePlatformAndroid(game);
#elif SILICONSTUDIO_PLATFORM_IOS
            return new GamePlatformiOS(game);
#else
            return new GamePlatformDesktop(game);
#endif
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        internal GraphicsDeviceManager(GameBase game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            lockDeviceCreation = new object();

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredColorSpace            = ColorSpace.Linear;
            PreferredBackBufferFormat      = PixelFormat.R8G8B8A8_UNorm;;
            PreferredDepthStencilFormat    = PixelFormat.D24_UNorm_S8_UInt;
            preferredBackBufferWidth       = DefaultBackBufferWidth;
            preferredBackBufferHeight      = DefaultBackBufferHeight;
            preferredRefreshRate           = new Rational(60, 1);
            PreferMultiSampling            = false;
            PreferredGraphicsProfile       = new[]
            {
#if SILICONSTUDIO_PLATFORM_WINDOWS_PHONE
                GraphicsProfile.Level_9_3,
#else
                GraphicsProfile.Level_11_1,
                GraphicsProfile.Level_11_0,
                GraphicsProfile.Level_10_1,
                GraphicsProfile.Level_10_0,
                GraphicsProfile.Level_9_3,
                GraphicsProfile.Level_9_2,
                GraphicsProfile.Level_9_1,
#endif
            };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
 public GamePlatformDesktop(GameBase game) : base(game)
 {
     IsBlockingRun = true;
 }
 public GamePlatformAndroid(GameBase game) : base(game)
 {
 }
Example #8
0
 protected GamePlatform(GameBase game)
 {
     this.game = game;
     Services  = game.Services;
     Services.AddService(typeof(IGraphicsDeviceFactory), this);
 }
Example #9
0
 protected GamePlatform(GameBase game)
 {
     this.game = game;
     Services = game.Services;
     Services.AddService(typeof(IGraphicsDeviceFactory), this);
 }
Example #10
0
 public GamePlatformAndroid(GameBase game) : base(game)
 {
 }
Example #11
0
        public static void RunGameTest(GameBase game)
        {
            // Prepare finish callback
            var tcs = new TaskCompletionSource<bool>();
            EventHandler<EventArgs> gameFinishedCallback = (sender, e) =>
            {
                // Notify waiter that game has exited
                Logger.Info("Game finished.");
                tcs.TrySetResult(true);
            };

            EventHandler<GameUnhandledExceptionEventArgs> exceptionhandler = (sender, e) =>
            {
                Logger.Info("Game finished with exception ={0}.", e);
                tcs.TrySetException((Exception)e.ExceptionObject);
            };

            // Transmit data to activity
            // TODO: Avoid static with string intent + Dictionary?
            try
            {
                game.UnhandledException += exceptionhandler;

                Logger.Info(@"Starting activity");

#if SILICONSTUDIO_PLATFORM_IOS
                game.Exiting += gameFinishedCallback;

                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var rootNavigationController = (UINavigationController)window.RootViewController;

                    // create the paradox game view 
                    var bounds = UIScreen.MainScreen.Bounds;
                    var paradoxGameView = new Starter.ParadoxApplicationDelegate.iOSParadoxView((System.Drawing.RectangleF)bounds) { ContentScaleFactor = UIScreen.MainScreen.Scale };

                    // create the view controller used to display the paradox game
                    var paradoxGameController = new iOSGameTestController(game) { View = paradoxGameView };

                    // create the game context
                    var gameContext = new GameContext(window, paradoxGameView, paradoxGameController);

                    // push view
                    rootNavigationController.PushViewController(gameContext.GameViewController, false);

                    // launch the game
                    game.Run(gameContext);
                });
#elif SILICONSTUDIO_PLATFORM_ANDROID
                // Start activity
                AndroidGameTestActivity.Game = game;
                AndroidGameTestActivity.Destroyed += gameFinishedCallback;
                PlatformAndroid.Context.StartActivity(typeof (AndroidGameTestActivity));
#endif

                // Wait for completion of task
                // TODO: Should we put a timeout and issue a Game.Exit() in main thread if too long?
                tcs.Task.Wait();

                Logger.Info(@"Activity ended");
            }
            catch (AggregateException e)
            {
                // Unwrap aggregate exceptions
                if (e.InnerExceptions.Count == 1)
                    ExceptionDispatchInfo.Capture(e.InnerException).Throw();
            }
            finally
            {
#if SILICONSTUDIO_PLATFORM_IOS
                // iOS Cleanup
                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var rootNavigationController = (UINavigationController)window.RootViewController;

                    rootNavigationController.PopViewController(false);
                });
#elif SILICONSTUDIO_PLATFORM_ANDROID
                AndroidGameTestActivity.Game = null;
                AndroidGameTestActivity.Destroyed -= gameFinishedCallback;
#endif

                // Cleanup
                game.Exiting -= gameFinishedCallback;
                game.UnhandledException -= exceptionhandler;
            }
        }
Example #12
0
 public static void RunGameTest(GameBase game)
 {
     throw new NotImplementedException();
 }
Example #13
0
 public GamePlatformWindowsRuntime(GameBase game) : base(game)
 {
 }
Example #14
0
 public GamePlatformiOS(GameBase game) : base(game)
 {
 }
 public GamePlatformWindowsRuntime(GameBase game) : base(game)
 {
 }
Example #16
0
 public GamePlatformOpenTK(GameBase game) : base(game)
 {
 }
Example #17
0
 public GamePlatformOpenTK(GameBase game) : base(game)
 {
 }
Example #18
0
 public GamePlatformiOS(GameBase game) : base(game)
 {
 }
Example #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        internal GraphicsDeviceManager(GameBase game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            lockDeviceCreation = new object();

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredColorSpace = ColorSpace.Linear;
            PreferredBackBufferFormat = PixelFormat.R8G8B8A8_UNorm;;
            PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt;
            preferredBackBufferWidth = DefaultBackBufferWidth;
            preferredBackBufferHeight = DefaultBackBufferHeight;
            preferredRefreshRate = new Rational(60, 1);
            PreferMultiSampling = false;
            PreferredGraphicsProfile = new[]
                {
#if SILICONSTUDIO_PLATFORM_WINDOWS_PHONE
                    GraphicsProfile.Level_9_3, 
#else
                    GraphicsProfile.Level_11_1, 
                    GraphicsProfile.Level_11_0, 
                    GraphicsProfile.Level_10_1, 
                    GraphicsProfile.Level_10_0, 
                    GraphicsProfile.Level_9_3, 
                    GraphicsProfile.Level_9_2, 
                    GraphicsProfile.Level_9_1, 
#endif
                };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
 public iOSGameTestController(GameBase game)
 {
     this.game = game;
 }
Example #21
0
 public GamePlatformDesktop(GameBase game) : base(game)
 {
     IsBlockingRun = true;
 }