예제 #1
0
        public override void LoadContent()
        {
            base.LoadContent();

            headingFont = ScreenManager.Content.Load<SpriteFont>("HighScoreHeading");
            scoresFont = ScreenManager.Content.Load<SpriteFont>("Font");
            highScoreHeadingPosition = new Vector2(-headingFont.MeasureString(highScoreTitle).X/2, -ScreenManager.GraphicsDevice.Viewport.Height / 2);

            xNamePosition = highScoreHeadingPosition.X - 100;
            xScorePosition = highScoreHeadingPosition.X + 100;

            kinectPongDAL = new KinectPongDAL();
            Dictionary<String, long> highScores = kinectPongDAL.GetHighScores();
            highScoreDisplay = new Dictionary<String, String>();

            foreach (String name in highScores.Keys)
            {
                TimeSpan t = TimeSpan.FromMilliseconds(highScores[name]);
                string answer = string.Format("{0:D2}:{1:D2}:{2:D3}", t.Minutes, t.Seconds, t.Milliseconds);

                highScoreDisplay.Add(name, answer);
            }
        }
예제 #2
0
        public override void LoadContent()
        {
            base.LoadContent();

            Player initialPlayer = new Player(new VodafoneMascot(ScreenManager.Content));

            players = new Dictionary<int, Player>();

            baskets = new List<ComplexBodies.Basket>();
            if (KinectSensor.KinectSensors.Count > 0)
            {
                kinect = KinectSensor.KinectSensors[0];
                kinect.SkeletonStream.Enable();
                kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinectSkeletonFrameReady);
                kinect.Start();

                initialPlayer.inputPosition = new KinectController(0, 0, 0);
            }
            else
            {
                initialPlayer.inputPosition = new KeyboardController(0, 0);
                initialPlayer.basketId = createBasket(new Vector2((int)(-ScreenManager.GraphicsDevice.Viewport.Width / 2.5), ScreenManager.GraphicsDevice.Viewport.Height / 3));
                players.Add(0, initialPlayer);
            }

            background = ScreenManager.Content.Load<Texture2D>("space-earth-stratosphere");
            explosionTexture = ScreenManager.Content.Load<Texture2D>("star");

            xScorePosition = -ScreenManager.GraphicsDevice.Viewport.Width / 2 + 20;
            yScorePosition = -ScreenManager.GraphicsDevice.Viewport.Height / 2 + 20;
            scoreFont = ScreenManager.Content.Load<SpriteFont>("Font");
            scoreColors = new Color[2];
            scoreColors[0] = Color.Red;
            scoreColors[1] = Color.Yellow;

            presentBodies = new List<Body>();
            presentSpriteBodyMapping = new Dictionary<int, Sprite>();
            explosionsStopwatch = Stopwatch.StartNew();
            explosionTimesLocationsMapping = new Dictionary<double, Vector2>();

            presentTextures = new List<Texture2D>();
            presentTextures.Add(ScreenManager.Content.Load<Texture2D>("PresentPictures/present_1_transparent"));
            presentTextures.Add(ScreenManager.Content.Load<Texture2D>("PresentPictures/present_2_transparent"));
            presentTextures.Add(ScreenManager.Content.Load<Texture2D>("PresentPictures/present_3_transparent"));
            presentTextures.Add(ScreenManager.Content.Load<Texture2D>("PresentPictures/present_4_transparent"));

            if (players.Count > 0)
            {
                initPlankBody(players[0]);
            }

            initEdges();
            int radius = 5;
            int outerRadius = radius * 2 + 2; // So circle doesn't go out of bounds
            Texture2D texture = new Texture2D(ScreenManager.GraphicsDevice, outerRadius, outerRadius);

            circleTexture = TextureParser.CreateCircle(radius, outerRadius, texture);
            random = new Random();

            World.Gravity = new Vector2(0, ScreenManager.GraphicsDevice.Viewport.Height / 15);

            jointTexture = ScreenManager.Content.Load<Texture2D>("joint");

            gestureControllerHandler = new GestureControllerHandler();

            kinectPongDAL = new KinectPongDAL();
            lowestHighscore = kinectPongDAL.getLowestHighscore(maximumTopScorers);

            gameStopwatch = new Stopwatch();
            gameStopwatch.Start();
            base.EnableCameraControl = false;
        }
예제 #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            if (KinectSensor.KinectSensors.Count > 0)
            {
                kinect = KinectSensor.KinectSensors[0];
                kinect.SkeletonStream.Enable();
                kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
                kinect.Start();
            }
            else
            {
                cursorSprite = new Sprite(ScreenManager.Content.Load<Texture2D>("Common/cursor"));
                camera = new Camera2D(ScreenManager.GraphicsDevice);
                usingMouse = true;
            }

            // Slaven, just for testing
            jointTexture = ScreenManager.Content.Load<Texture2D>("joint");

            scoreFont = ScreenManager.Content.Load<SpriteFont>("Font");
            keyboardPosition = new Vector2(-ScreenManager.GraphicsDevice.Viewport.Width / 3, -ScreenManager.GraphicsDevice.Viewport.Height / 8);
            keyboard = new KeyboardBody(keyboardPosition, World, ScreenManager, scoreFont);

            currentName = "";
            currentNamePosition = new Vector2(0, keyboardPosition.Y - ScreenManager.GraphicsDevice.Viewport.Height / 8);

            TimeSpan t = TimeSpan.FromMilliseconds(scoreToEnter);
            string answer = string.Format("{0:D2}:{1:D2}:{2:D3}", t.Minutes, t.Seconds, t.Milliseconds);
            congratulationsMessage = "Congratulations, you've made to High Scores with score " + answer;
            scorePosition = new Vector2(-scoreFont.MeasureString(congratulationsMessage).X/2, currentNamePosition.Y - ScreenManager.GraphicsDevice.Viewport.Height / 8);

            gestureControllerHandler = new GestureControllerHandler();
            keyboard.ActivationChanged += new EventHandler(keyboard_ActivationChanged);

            kinectPongDAL = new KinectPongDAL();
        }