public Player(ContentManager Content, ParticleTools particleTools, GameUnit x, GameUnit y) : base(CollisionType.StickyCollision) { sprites = new Dictionary<SpriteState, Sprite>(); InitializeSprites(Content); this.particleTools = particleTools; kinematicsX = new Kinematics(x, 0); kinematicsY = new Kinematics(y, 0); accelerationX = 0; horizontalFacing = SpriteState.HorizontalFacing.Left; intendedVerticalFacing = SpriteState.VerticalFacing.Horizontal; walkingAnimation = new WalkingAnimation(); maybeGroundTile = null; jumpActive = false; playerHealth = new PlayerHealth(Content); interacting = false; invincibleTimer = new Timer(InvincibleTime); damageText = new FloatingNumber(Content, FloatingNumber.NumberType.Damage); experienceText = new FloatingNumber(Content, FloatingNumber.NumberType.Experience); gunExperienceHud = new GunExperienceHud(Content); polarStar = new PolarStar(Content); collisionRectangle = new CompositeCollisionRectangle(new Rectangle((int)Math.Round(CollisionTopLeft), (int)Math.Round(CollisionYTop), (int)Math.Round(CollisionTopWidth), (int)Math.Round(CollisionYHeight / 2)), new Rectangle((int)Math.Round(CollisionBottomLeft), (int)Math.Round(CollisionYTop + CollisionYHeight / 2), (int)Math.Round(CollisionBottomWidth), (int)Math.Round(CollisionYHeight / 2)), new Rectangle(6, 10, 10, 12), new Rectangle(16, 10, 10, 12)); }
public void InitializeSprites(ContentManager Content) { for (GunLevelUnit gunLevel = 0; gunLevel < Units.MaxGunLevel; gunLevel++) { horizontalProjectiles[gunLevel] = new Sprite(Content, "Bullet", Units.TileToPixel(HorizontalProjectileSourceXs[gunLevel]), Units.TileToPixel(ProjectileSourceYs[gunLevel]), Units.TileToPixel(1), Units.TileToPixel(1)); verticalProjectiles[gunLevel] = new Sprite(Content, "Bullet", Units.TileToPixel(HorizontalProjectileSourceXs[gunLevel] + 1), Units.TileToPixel(ProjectileSourceYs[gunLevel]), Units.TileToPixel(1), Units.TileToPixel(1)); } for (SpriteState.HorizontalFacing horizontalFacing = SpriteState.HorizontalFacing.FirstHorizontalFacing; horizontalFacing < SpriteState.HorizontalFacing.LastHorizontalFacing; ++horizontalFacing) { for (SpriteState.VerticalFacing verticalFacing = SpriteState.VerticalFacing.FirstVerticalFacing; verticalFacing < SpriteState.VerticalFacing.LastVerticalFacing; ++verticalFacing) { InitializeSprite(Content, new PolarStarSpriteState( new Tuple <SpriteState.HorizontalFacing, SpriteState.VerticalFacing>( horizontalFacing, verticalFacing))); } } }
public void InitializeSprites(ContentManager Content) { //healthNumberSprite = new NumberSprite(Content, 52, HealthNumberNumDigits); for (SpriteState.MotionType motionType = SpriteState.MotionType.FirstMotionType; motionType < SpriteState.MotionType.LastMotionType; ++motionType) { for (SpriteState.HorizontalFacing horizontalFacing = SpriteState.HorizontalFacing.FirstHorizontalFacing; horizontalFacing < SpriteState.HorizontalFacing.LastHorizontalFacing; ++horizontalFacing) { for (SpriteState.VerticalFacing verticalFacing = SpriteState.VerticalFacing.FirstVerticalFacing; verticalFacing < SpriteState.VerticalFacing.LastVerticalFacing; ++verticalFacing) { for (SpriteState.StrideType strideType = SpriteState.StrideType.FirstStrideType; strideType < SpriteState.StrideType.LastStrideType; ++strideType) { InitializeSprite(Content, new SpriteState( new Tuple <SpriteState.MotionType, SpriteState.HorizontalFacing, SpriteState.VerticalFacing, SpriteState.StrideType>( motionType, horizontalFacing, verticalFacing, strideType))); } } } } }
public Player(ContentManager Content, ParticleTools particleTools, GameUnit x, GameUnit y) : base(CollisionType.StickyCollision) { sprites = new Dictionary <SpriteState, Sprite>(); InitializeSprites(Content); this.particleTools = particleTools; kinematicsX = new Kinematics(x, 0); kinematicsY = new Kinematics(y, 0); accelerationX = 0; horizontalFacing = SpriteState.HorizontalFacing.Left; intendedVerticalFacing = SpriteState.VerticalFacing.Horizontal; walkingAnimation = new WalkingAnimation(); maybeGroundTile = null; jumpActive = false; playerHealth = new PlayerHealth(Content); interacting = false; invincibleTimer = new Timer(InvincibleTime); damageText = new FloatingNumber(Content, FloatingNumber.NumberType.Damage); experienceText = new FloatingNumber(Content, FloatingNumber.NumberType.Experience); gunExperienceHud = new GunExperienceHud(Content); polarStar = new PolarStar(Content); collisionRectangle = new CompositeCollisionRectangle(new Rectangle((int)Math.Round(CollisionTopLeft), (int)Math.Round(CollisionYTop), (int)Math.Round(CollisionTopWidth), (int)Math.Round(CollisionYHeight / 2)), new Rectangle((int)Math.Round(CollisionBottomLeft), (int)Math.Round(CollisionYTop + CollisionYHeight / 2), (int)Math.Round(CollisionBottomWidth), (int)Math.Round(CollisionYHeight / 2)), new Rectangle(6, 10, 10, 12), new Rectangle(16, 10, 10, 12)); }
public void LookDown() { if (intendedVerticalFacing == SpriteState.VerticalFacing.Down) { return; } interacting = OnGround; intendedVerticalFacing = SpriteState.VerticalFacing.Down; }
public Projectile(Sprite sprite, SpriteState.HorizontalFacing horizontalDirection, SpriteState.VerticalFacing verticalDirection, GameUnit x, GameUnit y, GunLevelUnit gunLevel, ParticleTools particleTools) { this.sprite = sprite; this.horizontalDirection = horizontalDirection; this.verticalDirection = verticalDirection; this.x = x; this.y = y; this.gunLevel = gunLevel; offset = 0; alive = true; particleTools.FrontSystem.AddNewParticle(ProjectileStarParticle.Create(particleTools.Content, x, y)); }
public static SideType FromFacing(SpriteState.HorizontalFacing horizontalFacing, SpriteState.VerticalFacing verticalFacing) { if (verticalFacing == SpriteState.VerticalFacing.Up) { return(SideType.TopSide); } if (verticalFacing == SpriteState.VerticalFacing.Down) { return(SideType.BottomSide); } if (horizontalFacing == SpriteState.HorizontalFacing.Left) { return(SideType.LeftSide); } return(SideType.RightSide); }
private GameUnit GunY(SpriteState.VerticalFacing verticalFacing, bool gunUp, GameUnit playerY) { GameUnit gunY = playerY; if (verticalFacing == SpriteState.VerticalFacing.Up) { gunY -= Units.HalfTile / 2; } else if (verticalFacing == SpriteState.VerticalFacing.Down) { gunY += Units.HalfTile / 2; } if (gunUp) { gunY -= 2; } return(gunY); }
public void Draw(SpriteBatch spriteBatch, SpriteState.HorizontalFacing horizontalFacing, SpriteState.VerticalFacing verticalFacing, bool gunUp, GameUnit playerX, GameUnit playerY) { GameUnit x = GunX(horizontalFacing, playerX); GameUnit y = GunY(verticalFacing, gunUp, playerY); sprites[new PolarStarSpriteState(new Tuple <SpriteState.HorizontalFacing, SpriteState.VerticalFacing>( horizontalFacing, verticalFacing))].Draw(spriteBatch, x, y); if (projectileA != null) { projectileA.Draw(spriteBatch); } if (projectileB != null) { projectileB.Draw(spriteBatch); } }
public void LookUp() { interacting = false; intendedVerticalFacing = SpriteState.VerticalFacing.Up; }
public void LookHorizontal() { intendedVerticalFacing = SpriteState.VerticalFacing.Horizontal; }
public void LookDown() { if (intendedVerticalFacing == SpriteState.VerticalFacing.Down) { return; } interacting = OnGround; intendedVerticalFacing = SpriteState.VerticalFacing.Down; }
public Projectile(Sprite sprite, SpriteState.HorizontalFacing horizontalDirection, SpriteState.VerticalFacing verticalDirection, GameUnit x, GameUnit y, GunLevelUnit gunLevel, ParticleTools particleTools) { this.sprite = sprite; this.horizontalDirection = horizontalDirection; this.verticalDirection = verticalDirection; this.x = x; this.y = y; this.gunLevel = gunLevel; offset = 0; alive = true; particleTools.FrontSystem.AddNewParticle(ProjectileStarParticle.Create(particleTools.Content, x, y)); }
public void StartFire(GameUnit playerX, GameUnit playerY, SpriteState.HorizontalFacing horizontalFacing, SpriteState.VerticalFacing verticalFacing, bool gunUp, ParticleTools particleTools) { if (projectileA != null && projectileB != null) { return; } GameUnit bulletX = GunX(horizontalFacing, playerX) - Units.HalfTile; GameUnit bulletY = GunY(verticalFacing, gunUp, playerY) - Units.HalfTile; switch (verticalFacing) { case SpriteState.VerticalFacing.Horizontal: bulletY += NozzleHorizontalY; if (horizontalFacing == SpriteState.HorizontalFacing.Left) { bulletX += NozzleHorizontalLeftX; } else { bulletX += NozzleHorizontalRightX; } break; case SpriteState.VerticalFacing.Up: bulletY += NozzleUpY; if (horizontalFacing == SpriteState.HorizontalFacing.Left) { bulletX += NozzleUpLeftX; } else { bulletX += NozzleUpRightX; } break; case SpriteState.VerticalFacing.Down: bulletY += NozzleDownY; if (horizontalFacing == SpriteState.HorizontalFacing.Left) { bulletX += NozzleDownLeftX; } else { bulletX += NozzleDownRightX; } break; default: break; } if (projectileA == null) { projectileA = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ? horizontalProjectiles[CurrentLevel - 1] : verticalProjectiles[CurrentLevel - 1], horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools); } else if (projectileB == null) { projectileB = new Projectile(verticalFacing == SpriteState.VerticalFacing.Horizontal ? horizontalProjectiles[CurrentLevel - 1] : verticalProjectiles[CurrentLevel - 1], horizontalFacing, verticalFacing, bulletX, bulletY, CurrentLevel, particleTools); } }
public void LookHorizontal() { intendedVerticalFacing = SpriteState.VerticalFacing.Horizontal; }
public void LookUp() { interacting = false; intendedVerticalFacing = SpriteState.VerticalFacing.Up; }