protected override void CollectData(LocalEntity entity) { if (entity is LocalPlayer b) { playerPositionX = b.RigidBody.CollisionPolygon.CenterPoint.X; playerPositionY = b.RigidBody.CollisionPolygon.CenterPoint.Y; playerType = b.PlayerType; } else { throw new TypeDisagreementException(); } }
protected override void CollectData(LocalEntity entity) { if (entity is LocalPlayer b) { playerPositionX = b.RigidBody.CollisionPolygon.CenterPoint.X; playerPositionY = b.RigidBody.CollisionPolygon.CenterPoint.Y; spriteManagerData = b.SpriteManager.SpriteManagerData; playerType = b.PlayerType; playerHealth = b.CurrentHealth; } else { throw new TypeDisagreementException(); } }
public void LoadPlayer(PlayerStandards.PlayerType playerType, GameSession gameSession, Lobby lobby, int clientIndex, int entityIndex) { //Ensure unloaded if (spriteManager == null) { this.playerType = playerType; PlayerTexturePack texturePack = PlayerStandards.PlayerTypes[(int)playerType].LoadTexturePack(Content, graphicsDevice); spriteManager = new SpriteManager(texturePack, gameSession.LatestGameTime); drawDimensions = new Vector2(PlayerStandards.PlayerTypes[(int)playerType].GetPlayerScale() * MapStandards.PLAYER_SCALE, PlayerStandards.PlayerTypes[(int)playerType].GetPlayerScale() * MapStandards.PLAYER_SCALE); polygonalRepresentation = new RotationRectangle(new RectangleF(PlayerPosition.X - (DrawDimensions.X / 2), PlayerPosition.Y - (DrawDimensions.Y / 2), DrawDimensions.X, DrawDimensions.Y)); playerParticleManager = new PlayerParticleManager(texturePack, polygonalRepresentation, DrawDimensions); clientInfo = gameSession.NetworkManager.GetClientInfo(clientIndex); if (clientInfo != null) { healthBar = gameSession.graphicsUI.HealthBarManager.AddHealthBar(clientInfo.Username, Player.PLAYER_HEALTH, gameSession.LatestGameTime); } else { throw new Exception("Error with client info!"); } } }
public LocalPlayer(PlayerTexturePack texturePack, RigidBody rigidBody, GameTime gameTime, Vector2 drawDimensions, PlayerStandards.PlayerType PlayerType, GameMap gameMap) : base(texturePack, gameTime, rigidBody, drawDimensions, gameMap) { this.PlayerType = PlayerType; this.rigidBody = rigidBody; }
//Object public StandardWalker(PlayerTexturePack playerTexturePack, float strafeAcceleration, float maxStrafeVelocity, float jumpVelocity, float dodgeVelocity, float mass, CollisionReferenceMap <RigidBody> referenceMap, GameTime gameTime, Vector2 drawDimensions, PlayerStandards.PlayerType PlayerType, GameMap gameMap, bool mobile = true) : base(playerTexturePack, CreateRigidBody(playerTexturePack.LoopSheets[0].textures[0], mass, referenceMap, drawDimensions, gameMap), gameTime, drawDimensions, PlayerType, gameMap) { this.Mobile = mobile; this.strafeAcceleration = strafeAcceleration; this.maxStrafeVelocity = maxStrafeVelocity; this.jumpVelocity = jumpVelocity; this.dodgeVelocity = dodgeVelocity; movementFriction = this.strafeAcceleration; dodgeTime = playerTexturePack.EventSheets[(int)EventState.DodgeRoll][0].FrameTime * playerTexturePack.EventSheets[(int)EventState.DodgeRoll][0].spriteSheet.textures.Length; lastDodge = -dodgeTime; }
public StandardAttacker(PlayerTexturePack playerTexturePack, float strafeAcceleration, float maxStrafeVelocity, float jumpVelocity, float dodgeVelocity, AttackSpecification[] attackSpecifications, float mass, CollisionReferenceMap <RigidBody> referenceMap, GameTime gameTime, Vector2 drawDimensions, PlayerStandards.PlayerType PlayerType, GameMap gameMap, bool mobile = true) : base(playerTexturePack, strafeAcceleration, maxStrafeVelocity, jumpVelocity, dodgeVelocity, mass, referenceMap, gameTime, drawDimensions, PlayerType, gameMap, mobile) { if (attackSpecifications.Length == Enum.GetNames(typeof(AttackEvent)).Length) { this.attackSpecifications = attackSpecifications; } else { throw new Exception("Incorrect lunge speed data."); } BakeAttackColliders(playerTexturePack); }