Exemplo n.º 1
0
        public static void Main()
        {
            ConsoleWindow.CustomizeConsole();

            IDrawManager drawManager = new ConsoleDrawManager();

            IBorder border = new Border(
                new Point(middleConsoleWidth - 25, middleConsoleHeight - 15),
                new Point(middleConsoleWidth + 25, middleConsoleHeight + 15));
            IFoodFactory foodFactory   = new FoodFactory(new Random(), border);
            IScene       pauseScene    = new PauseScene(drawManager);
            IScene       infoScene     = new InfoScene(drawManager);
            IScene       gameOverScene = new GameOverScene
                                         (
                drawManager,
                new PlayAgainButton(new Point(middleConsoleWidth, 30)),
                new MenuButton(new Point(middleConsoleWidth, 35))
                                         );
            IButton playButton = new PlayButton
                                 (
                new Point(middleConsoleWidth, 30),
                new Point(border.TopLeftCorner.CoordinateX + 2, border.TopLeftCorner.CoordinateY + 2),
                drawManager, foodFactory, border, pauseScene, gameOverScene);
            IScene startMenu = new StartMenuScene(drawManager, playButton, new InfoButton(new Point(middleConsoleWidth, 35), infoScene), new ExitButton(new Point(middleConsoleWidth, 40)));

            Engine engine = new Engine(startMenu);

            engine.Run();
        }
Exemplo n.º 2
0
 public void Init()
 {
     if (!Directory.Exists("Levels")) Directory.CreateDirectory("Levels");
     if (!Directory.Exists("Saves")) Directory.CreateDirectory("Saves");
     if (!File.Exists("Saves\\Highscores_MP.xml"))
     {
         var scores = new Highscores();
         FileController.Save(scores, "Saves\\Highscores_MP.xml");
     }
     if (!File.Exists("Saves\\Highscores_SP.xml"))
     {
         var scores = new Highscores();
         FileController.Save(scores, "Saves\\Highscores_SP.xml");
     }
     Pause = new PauseScene(this);
     MainMenu = new MainMenuScene(this);
     InGame = new GameScene(this);
     Question = new ExitQuestion(this);
     SaveQuestion = new SaveSelectScene(this);
     LoadQuestion = new LoadSelectScene(this);
     HighscoreScn = new HighscoresScene(this);
 }
Exemplo n.º 3
0
        protected override void _Update(GameStatus status)
        {
            base._Update(status);
            if (Mouse.Left || Mouse.Middle || Mouse.Right
                || Mouse.X != previousMouseX || Mouse.Y != previousMouseY)
            {
                previousActionTime = status.CurrentTimeInMillis;
            }

            UpdateBullet(status);

            if (Keyboard.GetHitPeriod(DX.KEY_INPUT_AT) == 1)
            {
                directShot = !directShot;
            }

            foreach (var obj in gameObjects)
            {
                obj.Update(status);
            }

            if (Keyboard.IsHit(DX.KEY_INPUT_ESCAPE))
            {
                PauseScene s = new PauseScene();
                s.Init(GameSettings);
                CallScene(s);
            }

            // 一定時間無操作なら、オープニング画面へ。
            if ((status.CurrentTimeInMillis - previousActionTime) > 30 * 1000)
            {
                var s = new OpeningScene();
                s.Init(GameSettings);
                s.SerialPort = SerialPort;
                GotoScene(s);
            }

            previousMouseX = Mouse.X;
            previousMouseY = Mouse.Y;
        }