public QuestPopup(GraphicsDevice graphics, SpriteFont font, int windowWidth, int windowHeight, User user, Texture2D coinIcon, Action skip) { this.font = font; bgImg = DrawHelper.AddBorder(new Texture2D(graphics, WIDTH, HEIGHT), BORDER_SIZE, Color.Gray, Color.LightGray); bgRect = new Rectangle(windowWidth / 2 - WIDTH / 2, windowHeight / 2 - HEIGHT / 2, WIDTH, HEIGHT); questTextLoc.Y = bgRect.Y + BORDER_SIZE + SPACING * 2; progressBar = new FillBar(0, bgRect.X + bgRect.Width / 2 - PROGRESSBAR_WIDTH / 2, (int)(questTextLoc.Y + font.MeasureString(questText).Y + BIG_SPACING), PROGRESSBAR_WIDTH, PROGRESSBAR_HEIGHT, quest.GoalNumber, font); progressBar.ShowFraction = true; this.coinIcon = coinIcon; rewardString = Language.Translate("Reward") + ": " + 0; coinRect = new Rectangle((int)(bgRect.X + bgRect.Width / 2 - (font.MeasureString(rewardString).X + COIN_SIZE) / 2), progressBar.Y + progressBar.Height + BIG_SPACING, COIN_SIZE, COIN_SIZE); rewardLoc = new Vector2(coinRect.Right, coinRect.Y); closeButton = new MenuButton(Hide, Language.Translate("Close"), 0, 0, true, font, graphics); closeButton.X = bgRect.X + bgRect.Width / 2 - closeButton.Width / 2; closeButton.Y = bgRect.Bottom - closeButton.Height - BORDER_SIZE - SPACING; this.skip = skip; skipButton = new MenuButton(Skip, Language.Translate("Skip Quest"), 0, 0, true, font, graphics); skipButton.X = bgRect.X + bgRect.Width / 2 - skipButton.Width / 2; skipButton.Y = closeButton.Y - skipButton.Height - BORDER_SIZE - SPACING; if (user != null) { Initialize(user); } }
public PlayerInterface(int windowWidth, int windowHeight, Texture2D sweepImg, GraphicsDevice graphics, SpriteFont bigFont, SpriteFont mediumFont, int healthMax, Texture2D lifeImg, Texture2D rapidFireIcon, Texture2D crossImg) { this.windowWidth = windowWidth; this.windowHeight = windowHeight; this.lifeImg = lifeImg; bgImg = Utilities.RectImage; bgBottomRect = new Rectangle(0, windowHeight - BOTTOM_HEIGHT, windowWidth, BOTTOM_HEIGHT); bgTopRect = new Rectangle(0, 0, windowWidth, TOP_HEIGHT); sweeper = new Sweeper(graphics, windowWidth, windowHeight - BOTTOM_HEIGHT); sweeperButton = new MenuButton(new System.Action(sweeper.Sweep), 0, 0, true, graphics, sweepImg); sweeperButton.X = bgBottomRect.Width - sweeperButton.Width - SPACING; sweeperButton.Y = bgBottomRect.Y + (bgBottomRect.Height / 2 - (sweeperButton.Height / 2)); rapidFireButton = new ToggleButton(rapidFireIcon, crossImg, graphics, 0, sweeperButton.Y, sweeperButton.Width, sweeperButton.Height); rapidFireButton.Toggled = true; rapidFireButton.X = sweeperButton.X - rapidFireIcon.Width - SPACING; coinDisplayRect = new Rectangle(windowWidth - COIN_DISP_WIDTH - SPACING, TOP_HEIGHT / 2 - (COIN_DISP_HEIGHT / 2), COIN_DISP_WIDTH, COIN_DISP_HEIGHT); displayCoin = new Coin(Utilities.CoinImage, coinDisplayRect.X + SPACING, coinDisplayRect.Y + (coinDisplayRect.Height / 2 - (COIN_SIZE / 2)), COIN_SIZE, COIN_SIZE, 0); this.bigFont = bigFont; this.mediumFont = mediumFont; healthBar = new FillBar(healthMax, SPACING, SPACING, FILLBAR_WIDTH, HEALTHBAR_HEIGHT, healthMax, bigFont); //xpBar = new FillBar(0, healthBar.X, healthBar.Y + healthBar.Height + SPACING, FILLBAR_WIDTH, XPBAR_HEIGHT, // GameInfo.STARTING_XP_MAX, smallFont); projRects.AddRange(Enumerable.Repeat(new Rectangle(), GameInfo.HOTBAR_SLOTS)); projImgs.AddRange(Enumerable.Repeat(Utilities.RectImage, GameInfo.HOTBAR_SLOTS)); projAmountStrings.AddRange(Enumerable.Repeat("", GameInfo.HOTBAR_SLOTS)); projAmountPositions.AddRange(Enumerable.Repeat(new Vector2(), GameInfo.HOTBAR_SLOTS)); projAmounts.AddRange(Enumerable.Repeat(0, GameInfo.HOTBAR_SLOTS)); projs.AddRange(Enumerable.Repeat(ProjectileType.None, GameInfo.HOTBAR_SLOTS)); highlightedImg = new Texture2D(graphics, PROJ_SIZE, PROJ_SIZE); Color[] data = new Color[PROJ_SIZE * PROJ_SIZE]; highlightedImg.SetData(data); DrawHelper.AddBorder(highlightedImg, 2, Color.Lime, Color.Transparent); highlightedRect = new Rectangle(0, 0, PROJ_SIZE, PROJ_SIZE); usernamePos = new Vector2(); progressBar = new FillBar(0, 0, (int)(usernamePos.Y + bigFont.MeasureString("A").Y - (SPACING * 1.5f)), PROGRESSBAR_WIDTH, PROGRESSBAR_HEIGHT, 1, null); progressBar.ShowFraction = false; progressBar.X = windowWidth / 2 - (progressBar.Width / 2); }
public AlienLaserCannon(Texture2D img, int x, int y, int width, int height) { this.img = img; drawRect = new Rectangle(x, y, width, height); fireTimer = new Timer(9.0f, TimerUnits.Seconds); Health = INIT_HEALTH; laserImg = Utilities.LaserImg; laserRect = new Rectangle(0, 0, LASER_WIDTH, 0); healthBar = new FillBar(Health, 0, 0, HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT, INIT_HEALTH, null); callFailTimer = new Timer(2, TimerUnits.Seconds); playNextSoundTimer = new Timer(5, TimerUnits.Seconds); }
public Alien(Texture2D img, Texture2D eyeImg, int x, int y, int width, int height, int worth, int health, Color color, OnItemCollect itemCollected) { this.itemCollected = itemCollected; drawRect = new Rectangle(x, y, width, height); eyeRect = new Rectangle(drawRect.X + (int)(EYE_SPACING * 1.6f), drawRect.Y + EYE_SPACING, SPACING * 8, SPACING * 2); this.y = y; eyeY = eyeRect.Y; this.img = img; this.eyeImg = eyeImg; Worth = worth; Health = health; origColor = color; Color red = new Color(255, 0, 0); color.R = (byte)((color.R + red.R) / 2.0f); color.G = (byte)((color.G + red.G) / 2.0f); color.B = (byte)((color.B + red.B) / 2.0f); hurtColor = color; currentColor = origColor; effTimer = new Timer(2, TimerUnits.Seconds); shieldRect = new Rectangle(0, 0, SHIELD_SIZE, SHIELD_SIZE); shieldRect.X = drawRect.Right - shieldRect.Width / 2; shieldRect.Y = drawRect.Bottom - shieldRect.Height / 2; for (int i = 0; i < worth; i++) { Coin newC = new Coin(Utilities.CoinImage, 0, 0, COIN_SIZE, COIN_SIZE, 1); newC.AddOnCollectHandler(itemCollected); Drops.Add(newC); } eyeMoveTimer = new Timer(200, TimerUnits.Milliseconds); healthBar = new FillBar(health, drawRect.X, 0, drawRect.Width, HEALTHBAR_HEIGHT, health, null); healthBar.Y = drawRect.Y - healthBar.Height - SPACING; mechImg = Utilities.MechImg; mechRect = new Rectangle(); mechRect.Width = (int)(MECH_RATIO * height); mechRect.Height = mechRect.Width; mechRect.X = drawRect.Right - (mechRect.Width / 2); mechRect.Y = drawRect.Bottom - (mechRect.Height / 2); mechY = mechRect.Y; }
public Cage(int x, int y, int width, int height) { img = Utilities.CageImg; drawRect = new Rectangle(x, y, width, height); healthBar = new FillBar((int)Health, x + SPACING / 2, y, width - SPACING, HEALTHBAR_HEIGHT, INIT_HEALTH, null); }