Beispiel #1
0
        public void InitializeSprite(ContentManager Content, PolarStarSpriteState spriteState)
        {
            TileUnit tileY = spriteState.HorizontalFacing == SpriteState.HorizontalFacing.Left ?
                             Convert.ToUInt32(LeftOffset) : Convert.ToUInt32(RightOffset);

            switch (spriteState.VerticalFacing)
            {
            case SpriteState.VerticalFacing.Horizontal:
                tileY += HorizontalOffset;
                break;

            case SpriteState.VerticalFacing.Up:
                tileY += UpOffset;
                break;

            case SpriteState.VerticalFacing.Down:
                tileY += DownOffset;
                break;

            case SpriteState.VerticalFacing.LastVerticalFacing:
                break;
            }
            sprites[spriteState] = new Sprite(Content, SpritePath,
                                              Units.GameToPixel(PolarStarIndex * GunWidth), Units.TileToPixel(tileY),
                                              Units.GameToPixel(GunWidth), Units.GameToPixel(GunHeight));
        }
 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);
 }
Beispiel #3
0
        public PlayerHealth(ContentManager Content)
        {
            health = new Health(Content);
            health.healthBarSprite = new Sprite(Content, SpritePath,
                                                Units.GameToPixel(HealthBarSourceX), Units.GameToPixel(HealthBarSourceY),
                                                Units.GameToPixel(HealthBarSourceWidth), Units.GameToPixel(HealthBarSourceHeight));

            health.healthFillSprite = new VaryingWidthSprite(Content, SpritePath,
                                                             Units.GameToPixel(HealthFillSourceX), Units.GameToPixel(HealthFillSourceY),
                                                             Units.GameToPixel(MaxFillWidth), Units.GameToPixel(MaxFillWidth),
                                                             Units.GameToPixel(HealthFillSourceHeight));

            health.damageFillSprite = new VaryingWidthSprite(Content, SpritePath,
                                                             Units.GameToPixel(HealthDamageSourceX), Units.GameToPixel(HealthDamageSourceY),
                                                             Units.GameToPixel(MaxFillWidth), Units.GameToPixel(0),
                                                             Units.GameToPixel(HealthDamageSourceHeight));
            health.healthNumberSprite = NumberSprite.HudNumber(Content, 0, HealthNumberNumDigits);
        }
Beispiel #4
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);
 }
Beispiel #5
0
        public void LoadNumber()
        {
            reversedGlyphs = new List <Sprite>();
            GameUnit sourceY = color == ColorType.Red ? SourceRedY : SourceWhiteY;

            padding = 0;
            int digitCount = 0;

            do
            {
                int digit = number % Radix;
                reversedGlyphs.Add(new Sprite(Content, SpritePath,
                                              Units.GameToPixel(digit * Units.HalfTile), Units.GameToPixel(sourceY),
                                              Units.GameToPixel(SourceWidth), Units.GameToPixel(SourceHeight)));
                number /= Radix;
                digitCount++;
            }while (number != 0);

            padding = numDigits == 0 ? 0 : Units.HalfTile * (numDigits - digitCount);
            switch (op)
            {
            case OperatorType.Plus:
                reversedGlyphs.Add(new Sprite(Content, SpritePath,
                                              Units.GameToPixel(PlusSourceX), Units.GameToPixel(OpSourceY),
                                              Units.GameToPixel(SourceWidth), Units.GameToPixel(SourceHeight)));
                break;

            case OperatorType.Minus:
                reversedGlyphs.Add(new Sprite(Content, SpritePath,
                                              Units.GameToPixel(MinusSourceX), Units.GameToPixel(OpSourceY),
                                              Units.GameToPixel(SourceWidth), Units.GameToPixel(SourceHeight)));
                break;

            case OperatorType.None:
                break;
            }
        }
Beispiel #6
0
        public void Draw(SpriteBatch spriteBatch, GameUnit x, GameUnit y)
        {
            Rectangle destinationRect = new Rectangle(Units.GameToPixel(x), Units.GameToPixel(y), sourceRect.Width, sourceRect.Height);

            spriteBatch.Draw(tex, destinationRect, sourceRect, Color.White);
        }