/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { AppSpriteBatch.Begin(); AppSpriteBatch.Draw(background, new Rectangle(0, 0, 1280, 720), Color.White); AppSpriteBatch.DrawString(DeathFont, DeathText, new Vector2(100, 200), Color.LightGray); // Draw things here AppSpriteBatch.End(); gui.Draw(GameTime); }
/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { AppSpriteBatch.Begin(); AppSpriteBatch.DrawString(LoseTitleFont, Game.EndGameTitle, new Vector2(100, 100), Color.White); AppSpriteBatch.DrawString(LoseTextFont, Game.EndGameText, new Vector2(100, 250), Color.GhostWhite); AppSpriteBatch.DrawString(LoseTextFont, "(Press any key to quit)", new Vector2(100, 300), Color.GhostWhite); AppSpriteBatch.End(); }
/// <summary> /// Draw the last turns log to the screen /// </summary> /// <remarks>Sprite batch must be open</remarks> public void DrawLog(Vector2 drawLocation) { float currentLineY = 0.0f; foreach (var message in G.LastTurnMessages) { var coord = new Vector2(0, currentLineY) + drawLocation; var messageDimensions = LogFont.MeasureString(message.ToString()); AppSpriteBatch.DrawString(LogFont, message.ToString(), coord, Color.White); currentLineY += messageDimensions.Y; } }
/// <summary> /// Draw the stats to the screen /// </summary> /// <param name="drawLocation"></param> public void DrawStats(Vector2 drawLocation) { string statText = $"HP {G.Player.CurrentHealth} ({G.Player.MaxHealth})"; AppSpriteBatch.DrawString(StatFont, statText, drawLocation, Color.Red); }
/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { // Draw map to texture // Needs to happen before sprite batch begins, as it needs to begin it itself with a // different RenderTarget var MapTexture = MapView.DrawMap(GameTime, AppSpriteBatch); // Scale, in case high DPI float scale = (float)ScreenWidth / (float)MapTexture.Width; // Scale for log // Should stay a consistent size... it's twice the DPI of my real life screen, which // means that 14pt is about half the physical size on the phone as it is on my screen // which feels about right to me, I guess float logScale = Dpi / 220; AppSpriteBatch.Begin(); // Draw map texture to screen AppSpriteBatch.Draw(MapTexture, // VS's clam that (float) is redundant is a lie. If it's not cast - no right side // off new Rectangle(0, 0, (int)((float)MapTexture.Width * scale), (int)((float)MapTexture.Height * scale)), Color.White); // Draw guides if (ShowGuides) { float regionWidth = ScreenWidth / 3; float regionHeight = ScreenHeight / 4; for (int ix = 0; ix < 3; ix++) { AppSpriteBatch.DrawLine(new Vector2(ix * regionWidth, 0), new Vector2(ix * regionWidth, ScreenHeight), Color.Gray); } for (int iy = 0; iy < 4; iy++) { AppSpriteBatch.DrawLine(new Vector2(0, iy * regionHeight), new Vector2(ScreenWidth, iy * regionHeight), Color.Gray); } } // Draw log on bottom of screen float currentLineY = ScreenHeight; foreach (var message in G.LastTurnMessages) { currentLineY -= logScale * LogFont.MeasureString(message.ToString()).Y; } foreach (var message in G.LastTurnMessages) { var coord = new Vector2(0, currentLineY); var messageDimensions = LogFont.MeasureString(message.ToString()); AppSpriteBatch.DrawString(LogFont, message.ToString(), coord, Color.White, 0.0f, new Vector2(0.0f, 0.0f), logScale, SpriteEffects.None, 1.0f); currentLineY += messageDimensions.Y; } // Draw stats string statText = $"HP {G.Player.CurrentHealth} ({G.Player.MaxHealth})"; AppSpriteBatch.DrawString(StatFont, statText, new Vector2(10.0f, (float)MapTexture.Height * scale), Color.Red, 0.0f, new Vector2(0.0f, 0.0f), logScale, SpriteEffects.None, 0); AppSpriteBatch.End(); }
/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { AppSpriteBatch.Begin(); // Draw things here var mapToDraw = G.VisibleMap; var tileWidth = 64; var tileHeight = 64; for (var ix = 0; ix < G.CameraWidth; ++ix) { for (var iy = 0; iy < G.CameraHeight; ++iy) { var srcX = tileWidth * (mapToDraw[ix, iy].DrawTile % mapToDraw[ix, iy].Tileset.Columns); var srcY = tileHeight * (mapToDraw[ix, iy].DrawTile / mapToDraw[ix, iy].Tileset.Columns); AppSpriteBatch.Draw(mapToDraw[ix, iy].Tileset.Texture, // Dest new Rectangle(drawLeft + tileWidth * ix, drawTop + tileHeight * iy, tileWidth, tileHeight), // Src new Rectangle(srcX, srcY, tileWidth, tileHeight), Color.White); } } foreach (var i in G.VisibleActors) { var drawX = drawLeft + tileWidth * (i.Location.X - G.CameraTopLeft.X); var drawY = drawTop + tileHeight * (i.Location.Y - G.CameraTopLeft.Y); AppSpriteBatch.Draw(PCSprites, //Dest new Rectangle(drawX, drawY, tileWidth, tileHeight), //Src new Rectangle(i.Sprite * tileWidth, 0, tileWidth, tileHeight), Color.White); // Draw HP var message = i.HP.ToString(); if (i.Stunned) { message += "\n(Stunned)"; } if ((i as Enemy)?.Attacking ?? false) { message += "\n(Attacking)"; } AppSpriteBatch.DrawString(MonsterDetailsFont, message, new Vector2(drawX - 1 + tileWidth * 3 / 4, drawY - 1), Color.Black); AppSpriteBatch.DrawString(MonsterDetailsFont, message, new Vector2(drawX + tileWidth * 3 / 4, drawY), Color.Red); } var momentumTop = AppGraphicsDevice.Viewport.Height - drawTop; // Draw player momentum for (var i = 0; i < G.Player.SpentMomentum; ++i) { momentumTop -= SpentMomentumSprite.Height; AppSpriteBatch.Draw(SpentMomentumSprite, new Vector2(drawLeft - SpentMomentumSprite.Width, momentumTop), Color.White); } for (var i = 0; i < G.Player.Momentum; ++i) { momentumTop -= MomentumSprite.Height; AppSpriteBatch.Draw(MomentumSprite, new Vector2(drawLeft - MomentumSprite.Width, momentumTop), Color.White); } for (var i = 0; i < G.Player.HP; ++i) { AppSpriteBatch.Draw(HpSprite, new Vector2(drawLeft + tileWidth * G.CameraWidth, drawTop + i * HpSprite.Height), Color.White); } // Draw phase string phaseMessage = ""; switch (G.CurrentPhase) { case Game.Game.TurnPhases.Enemy: phaseMessage = "Defence turn"; break; case Game.Game.TurnPhases.Player: phaseMessage = "Attack turn"; break; } // Draw allowed moves bool addWait = false; for (var ix = 0; ix <= 2; ++ix) { for (var iy = 0; iy <= 2; ++iy) { int whatWillDo = 0; // 0: Nothing // 1: Walk // 2: Attack // 3: Wait // 4: Parry // 5: Dodge var action = (Actor.Action)(ix + iy * 3); var newLocation = G.Player.Location + new XY(ix - 1, iy - 1); if (G.CurrentPhase == Game.Game.TurnPhases.Player) { if (G.Player.CanWalk(newLocation)) { whatWillDo = 1; } if (G.Player.FightTargets.ContainsKey(action)) { whatWillDo = 2; } if (ix == 1 && iy == 1) { whatWillDo = 3; } } else { var defMoves = G.Player.DefenceAllowedMoves; if (ix == 1 && iy == 1) { if (defMoves.Contains(Actor.Action.Parry)) { whatWillDo = 4; addWait = true; } } else { if (defMoves.Contains(action)) { whatWillDo = 5; } } } var horizPosition = (ix + iy * 3 + 1 - ((ix + iy * 3) > 3 ? 1 : 0)); XY pos = null; switch (whatWillDo) { case 0: pos = new XY(0, 2); break; case 1: pos = new XY(horizPosition, 0); break; case 2: pos = new XY(horizPosition, 1); break; case 3: pos = new XY(0, 0); break; case 4: pos = new XY(0, 1); break; case 5: pos = new XY(horizPosition, 2); break; } if (pos != null) { AppSpriteBatch.Draw(MovementArrowsSprite, //Dest new Rectangle(actionDrawLocation.X + arrowWidth * ix, actionDrawLocation.Y + arrowHeight * iy, arrowWidth, arrowHeight), //Source new Rectangle(pos.X * arrowWidth, pos.Y * arrowHeight, arrowWidth, arrowHeight), Color.White); } } } if (addWait) { XY pos = new XY(0, 0); var ix = 2; var iy = 3; if (pos != null) { AppSpriteBatch.Draw(MovementArrowsSprite, //Dest new Rectangle(actionDrawLocation.X + arrowWidth * ix, actionDrawLocation.Y + arrowHeight * iy, arrowWidth, arrowHeight), //Source new Rectangle(pos.X * arrowWidth, pos.Y * arrowHeight, arrowWidth, arrowHeight), Color.White); } } AppSpriteBatch.DrawString(StateFont, phaseMessage, new Vector2(20, 60), Color.White); minimap.DrawMinimap(new XY(1000, 120)); AppSpriteBatch.End(); gui.Draw(GameTime); }