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(); }
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; }
// Constructor public PlayerBullet(World world, Player player, Vector2 position, float width, float height, float distance, float rotation, float density, bool bulletGoneOnCollision) : base(world, position, width, height, distance, rotation, density, bulletGoneOnCollision) { this.player = player; // Set up collision category based on player index Category collisionCategory = GameConstants.PlayerBulletCollisionCategory; if (player.PlayerIndex == PlayerIndex.One) { collisionCategory |= GameConstants.Player1BulletCollisionCategory; } else if (player.PlayerIndex == PlayerIndex.Two) { collisionCategory |= GameConstants.Player2BulletCollisionCategory; } else if (player.PlayerIndex == PlayerIndex.Three) { collisionCategory |= GameConstants.Player3BulletCollisionCategory; } else if (player.PlayerIndex == PlayerIndex.Four) { collisionCategory |= GameConstants.Player4BulletCollisionCategory; } this.physicsObj.CollisionCategory = collisionCategory; // We want the bullet to disappear once it hits something // bullets don't collide with the player that shot it or itself or platforms Category bulletCollidesWith = ~player.PhysicsContainer.Object.CollisionCategory & ~collisionCategory; if (bulletGoneOnCollision) { } else { bulletCollidesWith &= ~GameConstants.GroundCollisionCategory; } this.physicsObj.body.CollidesWith = bulletCollidesWith; }
public static PlayerController CreatePlayerController(Player player) { PlayerController playerController = new PlayerController(player); return playerController; }