Beispiel #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);
        }
Beispiel #2
0
        public static Player CreatePlayer(World world, PlayerIndex playerIndex, PlayerEvent playerEvent, Vector2 playerPosition)
        {
            ConfigFile configFile        = new ConfigFile(Player.SettingsIni);
            int        health            = configFile.SettingGroups[generalSettings].Settings["health"].GetValueAsInt();
            bool       enableWallJumping = configFile.SettingGroups[generalSettings].Settings["enableWallJumping"].GetValueAsBool();
            bool       enableWallSliding = configFile.SettingGroups[generalSettings].Settings["enableWallSliding"].GetValueAsBool();
            bool       enableShooting    = configFile.SettingGroups[generalSettings].Settings["enableShooting"].GetValueAsBool();

            Player player = new Player(world, (PlayerIndex)playerIndex, playerEvent);

            player.SetUpPlayer(playerPosition, health);

            if (enableWallJumping)
            {
                player.enableWallJumping();
            }
            if (enableWallSliding)
            {
                player.enableWallSliding();
            }
            if (enableShooting)
            {
                player.enableShooting();
            }

            return(player);
        }
Beispiel #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;
        }
 // Constructor
 public PlayerRepresentation(Player player, PlayerEvent playerEvent)
     : base(player)
 {
     this.player = player;
     this.playerEvent = playerEvent;
     this.color = Color.White;
     dashTrailEmitter = new TrailParticleEmitter();
 }
Beispiel #5
0
 // Constructor
 public PlayerRepresentation(Player player, PlayerEvent playerEvent)
     : base(player)
 {
     this.player      = player;
     this.playerEvent = playerEvent;
     this.color       = Color.White;
     dashTrailEmitter = new TrailParticleEmitter();
 }
Beispiel #6
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);
        }
Beispiel #7
0
        public static Player CreatePlayer(World world, PlayerIndex playerIndex, PlayerEvent playerEvent, Vector2 playerPosition)
        {
            ConfigFile configFile = new ConfigFile(Player.SettingsIni);
            int health = configFile.SettingGroups[generalSettings].Settings["health"].GetValueAsInt();
            bool enableWallJumping = configFile.SettingGroups[generalSettings].Settings["enableWallJumping"].GetValueAsBool();
            bool enableWallSliding = configFile.SettingGroups[generalSettings].Settings["enableWallSliding"].GetValueAsBool();
            bool enableShooting = configFile.SettingGroups[generalSettings].Settings["enableShooting"].GetValueAsBool();

            Player player = new Player(world, (PlayerIndex)playerIndex, playerEvent);
            player.SetUpPlayer(playerPosition, health);

            if (enableWallJumping)
                player.enableWallJumping();
            if (enableWallSliding)
                player.enableWallSliding();
            if (enableShooting)
                player.enableShooting();

            return player;
        }
Beispiel #8
0
        // Constructor
        public Player(World world, PlayerIndex playerIndex, PlayerEvent playerEvent)
            : base(world)
        {
            // Load resources
            ConfigFile configFile = new ConfigFile(SettingsIni);

            screenWidth                   = configFile.SettingGroups[initSettings].Settings["screenWidth"].GetValueAsFloat();
            screenHeight                  = configFile.SettingGroups[initSettings].Settings["screenHeight"].GetValueAsFloat();
            jumpDelay                     = configFile.SettingGroups[initSettings].Settings["jumpDelay"].GetValueAsFloat();
            jumpStateBufferDelay          = configFile.SettingGroups[initSettings].Settings["jumpStateBufferDelay"].GetValueAsFloat();
            hitDelay                      = configFile.SettingGroups[initSettings].Settings["hitDelay"].GetValueAsFloat();
            recoveryDelay                 = configFile.SettingGroups[initSettings].Settings["recoveryDelay"].GetValueAsFloat();
            respawnDelay                  = configFile.SettingGroups[initSettings].Settings["respawnDelay"].GetValueAsFloat();
            swordDistance                 = configFile.SettingGroups[initSettings].Settings["swordDistance"].GetValueAsFloat();
            addedSwordDistanceWhenRunning = configFile.SettingGroups[initSettings].Settings["addedSwordDistanceWhenRunning"].GetValueAsFloat();
            addedSwordDistanceWhenDashing = configFile.SettingGroups[initSettings].Settings["addedSwordDistanceWhenDashing"].GetValueAsFloat();
            dashDelay                     = configFile.SettingGroups[initSettings].Settings["dashDelay"].GetValueAsFloat();

            this.PlayerIndex      = playerIndex;
            this.playerEvent      = playerEvent;
            this.PhysicsContainer = new PhysicsContainer <PlayerPhysicsCharacter>();
            wallJumpEnabled       = false;
            wallSlideEnabled      = false;
            shootEnabled          = false;
            canJump     = false;
            canWallJump = false;

            // Accessories:
            this.Gun = null;
            this.Gun = new PlayerWeapon(world, this);
            this.Gun.SetUpWeapon(2, 0.3f, 20, 5, 200f, 1f, true);
            this.Sword = null;
            this.Sword = new PlayerWeapon(world, this);
            this.Sword.SetUpWeapon(1, 0.8f, 10, 36, swordDistance, 3f, false);
            this.Sword.RotateWhenShooting(40f, 0, 180);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        // Constructor
        public Player(World world, PlayerIndex playerIndex, PlayerEvent playerEvent)
            : base(world)
        {
            // Load resources
            ConfigFile configFile = new ConfigFile(SettingsIni);
            screenWidth = configFile.SettingGroups[initSettings].Settings["screenWidth"].GetValueAsFloat();
            screenHeight = configFile.SettingGroups[initSettings].Settings["screenHeight"].GetValueAsFloat();
            jumpDelay = configFile.SettingGroups[initSettings].Settings["jumpDelay"].GetValueAsFloat();
            jumpStateBufferDelay = configFile.SettingGroups[initSettings].Settings["jumpStateBufferDelay"].GetValueAsFloat();
            hitDelay = configFile.SettingGroups[initSettings].Settings["hitDelay"].GetValueAsFloat();
            recoveryDelay = configFile.SettingGroups[initSettings].Settings["recoveryDelay"].GetValueAsFloat();
            respawnDelay = configFile.SettingGroups[initSettings].Settings["respawnDelay"].GetValueAsFloat();
            swordDistance = configFile.SettingGroups[initSettings].Settings["swordDistance"].GetValueAsFloat();
            addedSwordDistanceWhenRunning = configFile.SettingGroups[initSettings].Settings["addedSwordDistanceWhenRunning"].GetValueAsFloat();
            addedSwordDistanceWhenDashing = configFile.SettingGroups[initSettings].Settings["addedSwordDistanceWhenDashing"].GetValueAsFloat();
            dashDelay = configFile.SettingGroups[initSettings].Settings["dashDelay"].GetValueAsFloat();

            this.PlayerIndex = playerIndex;
            this.playerEvent = playerEvent;
            this.PhysicsContainer = new PhysicsContainer<PlayerPhysicsCharacter>();
            wallJumpEnabled = false;
            wallSlideEnabled = false;
            shootEnabled = false;
            canJump = false;
            canWallJump = false;

            // Accessories:
            this.Gun = null;
            this.Gun = new PlayerWeapon(world, this);
            this.Gun.SetUpWeapon(2, 0.3f, 20, 5, 200f, 1f, true);
            this.Sword = null;
            this.Sword = new PlayerWeapon(world, this);
            this.Sword.SetUpWeapon(1, 0.8f, 10, 36, swordDistance, 3f, false);
            this.Sword.RotateWhenShooting(40f, 0, 180);
        }