Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 public Health(ContentManager Content)
 {
     damage = 0;
     damageTimer = new Timer(PlayerHealth.DamageDelay);
     maxHealth = 6;
     currentHealth = 6;
 }
Esempio n. 3
0
 public FloatingNumber(ContentManager Content, NumberType type)
 {
     this.Content = Content;
     shouldRise = true;
     timer = new Timer(DamageTime);
     this.type = type;
     offsetY = 0;
     val = 0;
     centerX = 0;
     centerY = 0;
 }
Esempio n. 4
0
 public PowerDoritoPickup(ContentManager Content, GameUnit centerX, GameUnit centerY, SizeType size)
     : base(CollisionType.BouncingCollision)
 {
     kinematicsX = new Kinematics(centerX - Units.HalfTile, (Game1.Random.Next(0, 11) - 5) * 0.025f);
     kinematicsY = new Kinematics(centerY - Units.HalfTile, (Game1.Random.Next(0, 11) - 5) * 0.025f);
     sprite = new AnimatedSprite(Content, SpriteName,
         Units.TileToPixel(SourceX), Units.TileToPixel(SourceYs[(int)size]),
         Units.TileToPixel(SourceWidth), Units.TileToPixel(SourceHeight),
         Fps, NumFrames);
     this.size = size;
     timer = new Timer(LifeTime, true);
 }
Esempio n. 5
0
 public AnimatedSprite(ContentManager Content,
     string fileName,
     PixelUnit sourceX, PixelUnit sourceY,
     PixelUnit width, PixelUnit height,
     int fps, FrameUnit numberOfFrames)
     : base(Content, fileName, sourceX, sourceY, width, height)
 {
     frameTimer = new Timer(TimeSpan.FromMilliseconds(1000 / fps));
     this.numberOfFrames = numberOfFrames;
     currentFrame = 0;
     numCompletedLoops = 0;
 }
Esempio n. 6
0
 public HeadBumpParticle(ContentManager Content,
     GameUnit centerX, GameUnit centerY)
 {
     this.centerX = centerX;
     this.centerY = centerY;
     sprite = new Sprite(Content, "Caret",
         Units.GameToPixel(SourceX), Units.GameToPixel(SourceY),
         Units.GameToPixel(Width), Units.GameToPixel(Height));
     timer = new Timer(LifeTime, true);
     particleA = new PolarVector(0, Game1.Random.Next(0, 360));
     maxOffsetA = 4 + Game1.Random.Next(0, 16);
     particleB = new PolarVector(0, Game1.Random.Next(0, 360));
     maxOffsetB = 4 + Game1.Random.Next(0, 16);
 }
Esempio n. 7
0
 public GunExperienceHud(ContentManager Content)
 {
     experienceBarSprite = new Sprite(Content, SpriteName,
         Units.GameToPixel(ExperienceBarSourceX), Units.GameToPixel(ExperienceBarSourceY),
         Units.GameToPixel(ExperienceBarSourceWidth), Units.GameToPixel(ExperienceBarSourceHeight));
     levelSprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(LevelSourceX), Units.GameToPixel(LevelSourceY),
         Units.TileToPixel(LevelSourceWidth), Units.GameToPixel(LevelSourceHeight));
     flashSprite = new Sprite(Content, SpriteName,
         Units.GameToPixel(FlashSourceX), Units.TileToPixel(FlashSourceY),
         Units.GameToPixel(ExperienceBarSourceWidth), Units.GameToPixel(ExperienceBarSourceHeight));
     fillSprite = new VaryingWidthSprite(Content, SpriteName,
         Units.TileToPixel(FillSourceX), Units.TileToPixel(FillSourceY),
         Units.GameToPixel(ExperienceBarSourceWidth), 0,
         Units.GameToPixel(ExperienceBarSourceHeight));
     maxSprite = new Sprite(Content, SpriteName,
         Units.GameToPixel(MaxSourceX), Units.GameToPixel(MaxSourceY),
         Units.GameToPixel(ExperienceBarSourceWidth), Units.GameToPixel(ExperienceBarSourceHeight));
     flashTimer = new Timer(FlashTime);
     number = NumberSprite.HudNumber(Content, 0, 2);
 }
Esempio n. 8
0
 private FlashingPickup(ContentManager Content,
     GameUnit centerX, GameUnit centerY,
     TileUnit sourceX, TileUnit sourceY,
     Rectangle rectangle,
     int value, Pickup.PickupType type)
 {
     sprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(sourceX), Units.TileToPixel(sourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     flashSprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(sourceX + 1), Units.TileToPixel(sourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     dissipatingSprite = new Sprite(Content, SpriteName,
         Units.TileToPixel(DissipatingSourceX), Units.TileToPixel(DissipatingSourceY),
         Units.TileToPixel(1), Units.TileToPixel(1));
     x = centerX - Units.HalfTile;
     y = centerY - Units.HalfTile;
     timer = new Timer(LifeTime, true);
     flashPeriod = StartPeriod;
     this.rectangle = rectangle;
     this.value = value;
     this.type = type;
 }
Esempio n. 9
0
 public WalkingAnimation()
 {
     frameTimer = new Timer(TimeSpan.FromMilliseconds(1000 / WalkFps));
     currentFrame = 0;
     forward = true;
 }