Exemple #1
0
 public GameManager(Canvas refCanvas, GameWindow refMainWindow, MenuUI.MenuUI mainMenuWindow)
 {
     gameCanvas            = refCanvas;
     collider              = new Collider(this);
     levelCreator          = new LevelCreator(this, resourceManager, gameCanvas);
     gameWindow            = refMainWindow;
     gameWindow.Activated += delegate
     {
         if (!isLoaded)
         {
             isLoaded = true;
             StartTimer();
             DoMovement();
         }
     };
     gameUI = new GameUI(gameCanvas, resourceManager, this);
     this.mainMenuWindow    = mainMenuWindow;
     refMainWindow.KeyDown += RefMainWindow_KeyDown;
 }
Exemple #2
0
        public GameWindow(MenuUI.MenuUI mainMenu, string gameFileName, bool isLoadingGame)
        {
            double monitorResolutionCanvasRatio = System.Windows.SystemParameters.WorkArea.Height - (2 * System.Windows.SystemParameters.CaptionHeight);

            InitializeComponent();
            GameCanvas.Focus();
            GameCanvas.Width  = monitorResolutionCanvasRatio;
            GameCanvas.Height = monitorResolutionCanvasRatio;
            IGameManager gameManager = new GameManager(GameCanvas, this, mainMenu);

            this.Closed += delegate { Environment.Exit(0); };
            if (isLoadingGame)
            {
                gameManager.LoadGame(gameFileName);
            }
            else
            {
                gameManager.StartGame();
            }
        }