public override void Draw(GameTime gameTime, GraphicsDevice device, SpriteBatch spriteBatch, SpriteFont font) { if (Selected) { spriteBatch.DrawString(font, SpecialCharacters.RightArrow, new Vector2(X, Y + Height - SpriteManager.CharHeight - 20), SpriteManager.ForegroundColor); } decimal hpPercent = ((decimal)monster.CurrentHP) / monster.Stats.HP; bool onFrame2 = false; if (hpPercent > 0.5m) { onFrame2 = frameCounter % 10 > 5; } else if (hpPercent > 0.2m) { onFrame2 = frameCounter % 30 > 15; } else { onFrame2 = frameCounter % 60 > 30; } Rectangle iconSource; if (Selected && onFrame2) { iconSource = new Rectangle(SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight * (int)monster.Species.BodyType, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight); } else { iconSource = new Rectangle(0, SpriteManager.PartyIconHeight * (int)monster.Species.BodyType, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight); } spriteBatch.Draw(SpriteManager.PartyIcons, new Rectangle(X + SpriteManager.CharWidth, Y, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight), iconSource, Color.White); spriteBatch.DrawString(font, SpecialCharacters.ReplaceChars(monster.Name).PadRight(10, ' ') + string.Format("{0}{1}", SpecialCharacters.ColonL, monster.Level).PadRight(4, ' ') + monster.StatusText, new Vector2(X + 100, Y), SpriteManager.ForegroundColor); spriteBatch.DrawString(font, string.Format("{0,3}/{1,3}", monster.CurrentHP, monster.Stats.HP).PadLeft(17, ' '), new Vector2(X + 100, Y + SpriteManager.CharHeight), SpriteManager.ForegroundColor); spriteBatch.Draw(SpriteManager.HPBar, new Rectangle(X + 136, Y + SpriteManager.CharHeight + 8, SpriteManager.HPBar.Width, SpriteManager.HPBar.Height), SpriteManager.ForegroundColor); Color color = hpPercent > 0.5m ? SpriteManager.HPBarHighColor : hpPercent > 0.2m ? SpriteManager.HPBarMediumColor : SpriteManager.HPBarLowColor; spriteBatch.Draw(SpriteManager.White, new Rectangle(X + 196, Y + SpriteManager.CharHeight + 12, (int)(192 * hpPercent), 8), color); }
public override void Update(GameTime gameTime) { frameCounter++; if (state == State.ReadyForNext && queue.Count > 0 && (currentParagraph == null || currentParagraph.Count == 0)) { currentParagraph = new Queue <string>(); string[] lines = FormatText(SpecialCharacters.ReplaceChars(queue.Dequeue())); for (int i = 0; i < lines.Length; i += 2) { if (i < lines.Length - 1) { currentParagraph.Enqueue(lines[i] + Environment.NewLine + lines[i + 1]); } else { currentParagraph.Enqueue(lines[i]); } } currentText = currentParagraph.Dequeue(); state = State.Animating; animationCounter = 0; } }
public override void AddMenuItem(string text) { if (items.Count % 2 == 0) { items.Add(new MenuItem(parent, X + 25, Y + 50 + (items.Count / 2) * (SpriteManager.CharHeight + 30), (Width - 50) * 55 / 100, SpriteManager.CharHeight, text, items.Count == 0)); } else { items.Add(new MenuItem(parent, items[0].X + items[0].Width + 20, Y + 50 + (items.Count / 2) * (SpriteManager.CharHeight + 30), (Width - 50) * 45 / 100, SpriteManager.CharHeight, SpecialCharacters.ReplaceChars(text), items.Count == 0)); } }
public override void Draw(GameTime gameTime, GraphicsDevice device, SpriteBatch spriteBatch) { if (monster == null || monster.Monster == null) { return; } try { if (monster.Monster != lastMonster) { lastMonster = monster.Monster; UpdateStatus(); } if (ShowParty) { spriteBatch.Draw(SpriteManager.HudFrame, new Rectangle(hudRect.X, hudRect.Y + hudRect.Height - SpriteManager.HudFrame.Height, SpriteManager.HudFrame.Width, SpriteManager.HudFrame.Height), null, SpriteManager.HudColor, 0f, new Vector2(), mirror ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); if (monster.Trainer.Party.Length <= 6) { int[] offsets = new int[6]; for (int i = 0; i < monster.Trainer.Party.Length; i++) { if (monster.Trainer.Party[i] == null) { offsets[i] = 3; } else if (monster.Trainer.Party[i].CurrentHP > 0) { if (monster.Trainer.Party[i].Status == StatusCondition.None) { offsets[i] = 0; } else { offsets[i] = 1; } } else { offsets[i] = 2; } } for (int i = monster.Trainer.Party.Length; i < 6; i++) { offsets[i] = 3; } Rectangle drawTo = new Rectangle(hudRect.X + (mirror ? 64 : 52), hudRect.Y + hudRect.Height - 52, 32, 32); if (mirror) { offsets = offsets.Reverse().ToArray(); } for (int i = offsets.Length - 1; i >= 0; i--) { spriteBatch.Draw(SpriteManager.Balls, drawTo, new Rectangle(offsets[i] * 32, 0, 32, 32), Color.White); drawTo.Offset(32, 0); } } else { int healthy = monster.Trainer.Party.Count(m => m.CurrentHP > 0 && m.Status == StatusCondition.None); int unhealthy = monster.Trainer.Party.Count(m => m.CurrentHP > 0 && m.Status != StatusCondition.None); int fainted = monster.Trainer.Party.Count(m => m.CurrentHP <= 0); string healthyStr = string.Format("{0}{1}", SpecialCharacters.MultiplicationX, healthy); string unhealthyStr = string.Format("{0}{1}", SpecialCharacters.MultiplicationX, unhealthy); string faintedStr = string.Format("{0}{1}", SpecialCharacters.MultiplicationX, fainted); int totalLength = 72 + (int)SpriteManager.Font.MeasureString(healthyStr + faintedStr + (unhealthy > 0 ? unhealthyStr : "")).X + (unhealthy > 0 ? 40 : 0); Rectangle drawTo = new Rectangle(hudRect.X + (mirror ? hudRect.Width - totalLength - 12 : 32), hudRect.Y + hudRect.Height - 52, 32, 32); spriteBatch.Draw(SpriteManager.Balls, drawTo, new Rectangle(0, 0, 32, 32), Color.White); drawTo.Offset(32, 0); spriteBatch.DrawString(SpriteManager.Font, healthyStr, new Vector2(drawTo.X, drawTo.Y), SpriteManager.HudColor); drawTo.Offset((int)SpriteManager.Font.MeasureString(healthyStr).X + 8, 0); if (unhealthy > 0) { spriteBatch.Draw(SpriteManager.Balls, drawTo, new Rectangle(32, 0, 32, 32), Color.White); drawTo.Offset(32, 0); spriteBatch.DrawString(SpriteManager.Font, unhealthyStr, new Vector2(drawTo.X, drawTo.Y), SpriteManager.HudColor); drawTo.Offset((int)SpriteManager.Font.MeasureString(unhealthyStr).X + 8, 0); } spriteBatch.Draw(SpriteManager.Balls, drawTo, new Rectangle(64, 0, 32, 32), Color.White); drawTo.Offset(32, 0); spriteBatch.DrawString(SpriteManager.Font, faintedStr, new Vector2(drawTo.X, drawTo.Y), SpriteManager.HudColor); } } else if (monster.Monster.Status != StatusCondition.Faint) { spriteBatch.Draw(hudSprite, hudRect, SpriteManager.HudColor); spriteBatch.DrawString(SpriteManager.Font, SpecialCharacters.ReplaceChars(monster.Monster.Name), nameCoords, SpriteManager.HudColor); string line2 = " " + SpecialCharacters.ColonL + monster.Monster.Level.ToString(); if (!string.IsNullOrWhiteSpace(statusText)) { line2 = " " + statusText; } spriteBatch.DrawString(SpriteManager.Font, line2, statusCoords, SpriteManager.HudColor); decimal hpPercent = ((decimal)monster.Monster.CurrentHP) / monster.Monster.Stats.HP; int hpToDraw = monster.Monster.CurrentHP; if (state == State.Animating || extraAnimationCounter >= 0) { int change = hpFrom > hpTo ? (int)-frameCounter : (int)frameCounter; if (Math.Abs(hpTo - hpFrom) < Math.Abs(change)) { change = hpTo - hpFrom; } hpPercent = ((decimal)hpFrom + change) / monster.Monster.Stats.HP; hpToDraw = hpFrom + change; } if (state != State.Animating && extraAnimationCounter >= 0) { extraAnimationCounter++; } if (extraAnimationCounter > 5) { extraAnimationCounter = -1; } Color color = hpPercent > 0.5m ? SpriteManager.HPBarHighColor : hpPercent > 0.2m ? SpriteManager.HPBarMediumColor : SpriteManager.HPBarLowColor; spriteBatch.Draw(SpriteManager.White, new Rectangle((int)hpBarCoords.X, (int)hpBarCoords.Y, (int)(192 * hpPercent), 8), color); if (drawHPText) { spriteBatch.DrawString(SpriteManager.Font, string.Format("{0,4}/{1,3}", hpToDraw, monster.Monster.Stats.HP), hpTextCoords, SpriteManager.HudColor); } } } catch (NullReferenceException) { } }
public virtual void AddMenuItem(string text) { items.Add(new MenuItem(parent, X + 25, Y + 25 + items.Count * (SpriteManager.CharHeight + 5), Width - 50, SpriteManager.CharHeight, SpecialCharacters.ReplaceChars(text), items.Count == 0)); }