Beispiel #1
0
        ////////////////////////////////
        /** XNA Run time functions **/
        ////////////////////////////////
        protected override void Initialize()
        {
            kinectRuntime = new Runtime();
            kinectRuntime.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseDepthAndPlayerIndex);
            kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);

            kinectRuntime.VideoFrameReady    += VideoFrameReady;
            kinectRuntime.SkeletonFrameReady += SkeletonFrameReady;

            particleEffect.Initialise();

            // Init Debugger overlay
            skeletonDebugger = new SkeletonOverlayDebugger(this.kinectRuntime);


            base.Initialize();
        }
Beispiel #2
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                {
                    content = new ContentManager(ScreenManager.Game.Services, "Content");
                }

                kinectRGBVideo.Texture = new Texture2D(ScreenManager.GraphicsDevice, 640, 480, false, SurfaceFormat.Color);

                kinectRuntime = new Runtime();
                kinectRuntime.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseDepthAndPlayerIndex);
                kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);

                kinectRuntime.VideoFrameReady    += VideoFrameReady;
                kinectRuntime.SkeletonFrameReady += SkeletonFrameReady;

                kinectRGBVideo.Position = new Vector2(183, 225);
                UI_KinectFrameOffset    = new Vector2(183, 225);

                // Game Set inits.
                //Game Level is initiated which has all the number of sets game and instruction
                gameLevelManager = new GameLevelManager(this.currentLevel, ref content);
                generateGameSet();

                // Load sounds
                correct_snd = new GameSFX(content.Load <SoundEffect>("kling"));

                //Loads the background music and plays it
                GameMusic background = new GameMusic(content.Load <Song>("background_music3"));
                background.PlayLooping();

                particleEffect   = new ParticleEffect();
                particleRenderer = new SpriteBatchRenderer
                {
                    GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService))
                };
                particleRenderer.LoadContent(content);
                particleEffect = content.Load <ParticleEffect>(("BasicExplosion"));
                particleEffect.LoadContent(content);
                particleEffect.Initialise();

                //Interface Layer
                UI_FrameLayer               = content.Load <Texture2D>("frame");
                UI_FrameLayerPosition       = new Vector2(0, 0);
                UI_Font_Instruction         = content.Load <SpriteFont>("SpriteFont");
                UI_FontPosition_Instruction = new Vector2(500, 90);
                UI_Font_Score               = content.Load <SpriteFont>("SpriteFont");
                UI_FontPosition_Score       = new Vector2(500, 22);
                UI_Font_Level               = content.Load <SpriteFont>("SpriteFont");
                UI_FontPosition_Level       = new Vector2(80, 22);
                UI_Font_Time         = content.Load <SpriteFont>("SpriteFont");
                UI_FontPosition_Time = new Vector2(850, 22);

                //Interactive Elements
                textAnim_GoodJob  = new TextAnimator(content.Load <SpriteFont>("SpriteFont"));
                textAnim_GameOver = new TextAnimator(content.Load <SpriteFont>("SpriteFont"));

                // once the load has finished, we use ResetElapsedTime to tell the game's
                // timing mechanism that we have just finished a very long frame, and that
                // it should not try to catch up.
                ScreenManager.Game.ResetElapsedTime();

                // Debugger
                if (debuggerOn)
                {
                    skeletonDebugger = new SkeletonOverlayDebugger(kinectRuntime);
                    shapeDebugger.init(ScreenManager.GraphicsDevice);
                }
            }
        }