Esempio n. 1
0
        private void CreatePlayer(int playerIndex)
        {
            PlayerEvent playerEvent = new PlayerEvent();

            Player player = PlayerFactory.CreatePlayer(physicsSystem.world, (PlayerIndex)playerIndex, playerEvent, Vector2.Zero);

            entityManager.Add(player);

            Viewport playerViewport = defaultViewport;

            if ((PlayerIndex)playerIndex == PlayerIndex.One)
            {
                playerViewport = topLeftViewport;
            }
            else if ((PlayerIndex)playerIndex == PlayerIndex.Two)
            {
                playerViewport = topRightViewport;
            }
            else if ((PlayerIndex)playerIndex == PlayerIndex.Three)
            {
                playerViewport = bottomLeftViewport;
            }
            else if ((PlayerIndex)playerIndex == PlayerIndex.Four)
            {
                playerViewport = bottomRightViewport;
            }
            PlayerRepresentation playerRepresentation = PlayerFactory.CreatePlayerRepresentation(player, playerEvent, Content, playerViewport, map.LevelMap.Width, map.LevelMap.Height);

            representationManager.Add(playerRepresentation);

            PlayerController playerController = PlayerFactory.CreatePlayerController(player);

            controllerManager.Add(playerController);
        }
Esempio n. 2
0
        public static PlayerRepresentation CreatePlayerRepresentation(Player player, PlayerEvent playerEvent, ContentManager content, Viewport playerViewport, float levelWidth, float levelHeight)
        {
            PlayerRepresentation playerRepresentation = new PlayerRepresentation(player, playerEvent);
            playerRepresentation.LoadContent(content);
            playerRepresentation.SetUpCamera(playerViewport, levelWidth, levelHeight);

            return playerRepresentation;
        }
Esempio n. 3
0
        public static PlayerRepresentation CreatePlayerRepresentation(Player player, PlayerEvent playerEvent, ContentManager content, Viewport playerViewport, float levelWidth, float levelHeight)
        {
            PlayerRepresentation playerRepresentation = new PlayerRepresentation(player, playerEvent);

            playerRepresentation.LoadContent(content);
            playerRepresentation.SetUpCamera(playerViewport, levelWidth, levelHeight);

            return(playerRepresentation);
        }
Esempio n. 4
0
        public void Remove(EntityRepresentation representation)
        {
            PlayerRepresentation playerRepresentation = representation as PlayerRepresentation;

            if (playerRepresentation != null)
            {
                playerRepresentations.Remove(playerRepresentation);
            }
            else
            {
                entityRepresentations.Remove(representation);
            }
        }
Esempio n. 5
0
        // Drop-out
        public void SubtractPlayer() // here *** so refactor this then refactor the above, [AddPlayer()]
        {
            int numPlayers = GameVariables.NumPlayers;

            if (numPlayers < 2)
            {
                return;
            }

            PlayerIndex playerIndex;

            if (numPlayers > 3)
            {
                playerIndex = PlayerIndex.Four;
            }
            else if (numPlayers > 2)
            {
                playerIndex = PlayerIndex.Three;
            }
            else if (numPlayers > 1)
            {
                playerIndex = PlayerIndex.Two;
            }
            else
            {
                return;
            }

            Player player = entityManager.GetPlayerWithIndex(playerIndex);

            entityManager.Remove(player);
            PlayerRepresentation playerRepresentation = representationManager.GetPlayerRepresentationWithIndex(playerIndex);

            representationManager.Remove(playerRepresentation);
            PlayerController playerController = controllerManager.GetPlayerControllerWithIndex(playerIndex);

            controllerManager.Remove(playerController);

            player.Dispose();

            numPlayers--;
            GameVariables.NumPlayers = numPlayers;

            SetUpSplitScreen();
            ResetPlayerCameras();
        }
Esempio n. 6
0
        protected void DrawDebugScene(int playerIndex)
        {
            // get the current player representation
            PlayerRepresentation playerRepresentation = representationManager.GetPlayerRepresentationWithIndex((PlayerIndex)playerIndex);

            playerRepresentation.Cam.Zoom = resolutionRatio();
            if (GameVariables.NumPlayers == 1)
            {
                playerRepresentation.Cam.Zoom *= 2;
            }

            //Matrix _projection = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(GraphicsDevice.Viewport.Height), 0f, 0f, 1f);
            Matrix _projection = playerRepresentation.Cam.SimProjection;
            Matrix _view       = playerRepresentation.Cam.SimView;

            DebugView.RenderDebugData(ref _projection, ref _view);
        }
Esempio n. 7
0
        protected void DrawScene(int playerIndex)
        {
            // get the current player representation
            PlayerRepresentation playerRepresentation = representationManager.GetPlayerRepresentationWithIndex((PlayerIndex)playerIndex);

            // depends on the current resolution
            playerRepresentation.Cam.Zoom = resolutionRatio();
            if (GameVariables.NumPlayers == 1)
            {
                playerRepresentation.Cam.Zoom *= 2;
            }


            // Draw the parallax background

            playerRepresentation.Cam.Parallax = 0.66f;
            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              SamplerState.PointClamp,
                              null,
                              null,
                              null,
                              playerRepresentation.Cam.ParallaxView);

            GameVariables.CamPosition = playerRepresentation.Cam.ParallaxPosition;
            representationManager.MapRepresentation.DrawBackground(spriteBatch);
            spriteBatch.End();


            // Draw the other things

            playerRepresentation.Cam.Parallax = 1f;
            spriteBatch.Begin(SpriteSortMode.BackToFront,
                              BlendState.AlphaBlend,
                              SamplerState.PointClamp,
                              null,
                              null,
                              null,
                              playerRepresentation.Cam.View);

            GameVariables.CamPosition = playerRepresentation.Cam.Position;
            representationManager.Draw(spriteBatch);
            spriteBatch.End();
        }
Esempio n. 8
0
        public void Add(EntityRepresentation representation)
        {
            PlayerRepresentation playerRepresentation = representation as PlayerRepresentation;

            if (playerRepresentation != null)
            {
                playerRepresentations.Add(playerRepresentation);
            }
            else
            {
                entityRepresentations.Add(representation);

                if (this.MapRepresentation == null)
                {
                    MapRepresentation mapRepresentation = representation as MapRepresentation;
                    if (mapRepresentation != null)
                    {
                        this.MapRepresentation = mapRepresentation;
                    }
                }
            }
        }