Exemple #1
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;
        }