示例#1
0
        /// <summary>
        /// 初期化する
        /// </summary>
        /// <returns>成功したら0</returns>
        public int Init()
        {
            Configuration gconf = Configuration.GetGlobal();

            if (sensor.Init() != 0)
            {
                Error("Failed to initialize Kinect sensor");
                return(-1);
            }

            int screenX, screenY, screenBits;

            if (DX.GetScreenState(out screenX, out screenY, out screenBits) != 0)
            {
                Error("Failed to get screen state");
                return(-1);
            }
            gameSettings.WindowWidth  = screenX;
            gameSettings.WindowHeight = screenY;
            gameSettings.ScreenBits   = screenBits;
            gameSettings.GameLogic    = this;

            debugWindow.Height = screenY / 2 - 10;
            debugWindow.Width  = screenX / 4 - 10;
            debugWindow.Top    = screenY - debugWindow.Height - 5;
            debugWindow.Left   = 5;

            //serialPort.Open();

            /*
             * var mainScene = new MainScene();
             * mainScene.SerialPort = serialPort;
             * mainScene.Init(gameSettings);
             * sceneStack.Push(mainScene);
             */
            var s = new OpeningScene();

            s.SerialPort = serialPort;
            s.Init(gameSettings);
            sceneStack.Push(s);

            return(0);
        }
示例#2
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;
        }