Esempio n. 1
0
 protected override void LoadContent()
 {
     GameStateManager.AddState(new GameState("InGame", Content.Load <Song>("song1")));
     GameStateManager.AddState(new GameState("Menu", Content.Load <Song>("song2")));
 }
Esempio n. 2
0
 protected override void UnloadContent()
 {
     GameStateManager.Dispose();
 }
Esempio n. 3
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 30.0); // 30fpsにする (Kinectは30fpsのためこれに合わせる)
            this.IsMouseVisible    = true;                             // マウスカーソルを表示する

            // 画面の解像度を変更する (Kinectカメラに合わせる)
            this.graphics.PreferredBackBufferWidth  = 640;
            this.graphics.PreferredBackBufferHeight = 480;

            //-----------------
            // Runtimeの初期化
            //-----------------
            nui = new Runtime();
            try
            {
                nui.Initialize(RuntimeOptions.UseColor |
                               RuntimeOptions.UseDepth |
                               RuntimeOptions.UseDepthAndPlayerIndex |
                               RuntimeOptions.UseSkeletalTracking);
            }
            catch (InvalidOperationException)
            {
                Trace.WriteLine("Runtime initialization failed. Please make sure Kinect device is plugged in.");
                return;
            }

            // ビデオストリームをオープン
            try
            {
                nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
                nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
            }
            catch (InvalidOperationException)
            {
                Trace.WriteLine("Failed to open stream. Please make sure to specify a supported image type and resolution.");
                return;
            }

            //-------------
            //ハンドラ登録
            //-------------
            nui.VideoFrameReady    += new EventHandler <ImageFrameReadyEventArgs>(nui_VideoFrameReady);
            nui.DepthFrameReady    += new EventHandler <ImageFrameReadyEventArgs>(nui_DepthFrameReady);
            nui.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady);

            //---------------------------
            // ARオブジェクトインスタンス
            //---------------------------
            ARObjectList = new List <ARObject>();

            sampleParts = new ARObject("monkey", new AttachedPos(JointID.Head));
//            sampleParts = new ARObject("monkey", new AttachedPos(JointID.Head, JointID.ShoulderCenter, JointID.Head, 1.5f)); // 頭の上に表示する(Test)
            sampleVFX = new SampleVFX("simplesphere");

            samplePartsColor = textureColorList[0]; // テクスチャ色の設定(for Demo)

            //---------------------------
            // ジェスチャ検出モジュール
            //--------------------------
            gestureDetect = new GestureDetect(this);
            Components.Add(gestureDetect);

            //--------------------------
            // ゲーム状態管理モジュール
            //--------------------------
            gameStateManager = new GameStateManager(this);
            Components.Add(gameStateManager);
        }