コード例 #1
0
ファイル: App.xaml.cs プロジェクト: Maskl/MetroRetro
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create Game Manager
            _gameManager = new GameManager();

            // Place the frame in the current Window and ensure that it is active
            _mainPage = new MainPage(_gameManager);
            Window.Current.Content = _mainPage;
            Window.Current.Activate();

            // Safely dispose any previous instance
            // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC)
            _deviceManager = new DeviceManager();

            // New CubeRenderer
            _renderer = new Renderer(_gameManager);
            //    var fpsRenderer = new FpsRenderer();

            // Use CoreWindowTarget as the rendering target (Initialize SwapChain, RenderTargetView, DepthStencilView, BitmapTarget)
            _target = new SwapChainBackgroundPanelTarget(_mainPage);

            // Add Initializer to device manager
            _deviceManager.OnInitialize += _target.Initialize;
            _deviceManager.OnInitialize += _renderer.Initialize;
             //   _deviceManager.OnInitialize += fpsRenderer.Initialize;

            // Render the cube within the CoreWindow
            _target.OnRender += _renderer.Render;
             //   _target.OnRender += fpsRenderer.Render;

            // Initialize the device manager and all registered deviceManager.OnInitialize
            _deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTargetRendering;

            // Callback on DpiChanged
            DisplayProperties.LogicalDpiChanged += DisplayPropertiesLogicalDpiChanged;

            // Create colors which will be use in all games.
            GamesParams.CreateColors(_deviceManager);

            // Create Game Manager
            _gameManager.Create(_mainPage, _renderer);

            // And start first game
            _gameManager.StartSession();
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: Maskl/MetroRetro
        public void Create(MainPage mainPage, Renderer renderer)
        {
            LoadRecord();

            Page = mainPage;
            Renderer = renderer;
            IsPause = false;

            _games = new Dictionary<GameType, BaseGame>
                         {
                             {GameType.Pong, new Pong(this, 15)},
                             {GameType.Arkanoid, new Arkanoid(this, 15)},
                             {GameType.Snake, new Snake(this, 20)},
                             {GameType.Tigers, new Tigers(this, 15)},
                             {GameType.MoonPatrol, new MoonPatrol(this, 20)}
                         };

            _currentGame = null;
        }