public override void Draw(Graphics2D g) { Zone zoneOld = roomOld.Room.Zone; Zone zoneNew = roomNew.Room.Zone; if (zoneOld == zoneNew) { // Draw the rooms normally. DrawRooms(g); } else { // Fade between zones. // Switch to the temp render target to draw the new zone. g.End(); g.SetRenderTarget(GameData.RenderTargetGameTemp); g.Begin(GameSettings.DRAW_MODE_DEFAULT); roomOld.Room.Zone = zoneNew; DrawRooms(g); roomOld.Room.Zone = zoneOld; // Switch to main render target to draw the old zone. g.End(); g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); roomNew.Room.Zone = zoneOld; DrawRooms(g); roomNew.Room.Zone = zoneNew; // Draw the temp render target (with the new zone) at an opacity. float opacity = (float) distance / (float) maxDistance; Color color = Color.White * opacity; g.DrawImage(GameData.RenderTargetGameTemp, Vector2F.Zero, Vector2F.Zero, Vector2F.One, 0.0, color); } }
public override void Draw(Graphics2D g) { if (drawHUD) { GameControl.HUD.Draw(g, true); g.Translate(0, 16); } g.DrawImage(backgroundSprite, Point2I.Zero); if (currentSlotGroup != null) DrawSlotCursor(g, currentSlotGroup.CurrentSlot); for (int i = 0; i < slotGroups.Count; i++) { slotGroups[i].Draw(g); } }
//----------------------------------------------------------------------------- // Overriden methods //----------------------------------------------------------------------------- protected override void Draw() { Graphics2D g = new Graphics2D(spriteBatch); //g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.Clear(Color.White); g.Translate(new Vector2F(-this.HorizontalScroll.Value, -this.VerticalScroll.Value)); g.Translate(-Tileset.SpriteSheet.Offset); g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero); Point2I tilePoint = SelectedTile * (Tileset.SpriteSheet.CellSize + Tileset.SpriteSheet.Spacing); g.ResetTranslation(); g.Translate(new Vector2F(-this.HorizontalScroll.Value, -this.VerticalScroll.Value)); g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.SpriteSheet.CellSize + 1), 1, Color.White); g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.SpriteSheet.CellSize - 1), 1, Color.Black); g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.SpriteSheet.CellSize + 3), 1, Color.Black); g.ResetTranslation(); g.End(); }
public override void Draw(Graphics2D g) { if (dungeon == null) return; // Draw the background. g.DrawImage(backgroundImage, Point2I.Zero); // TODO: Draw the dungeon name panel. // Draw the floors. Point2I floorBasePos = new Point2I(); if (floors.Count < 6) floorBasePos.Y = 72 + (8 * (floors.Count / 2)); else floorBasePos.Y = 88 + (4 * (floors.Count - 6)); for (int i = 0; i < floors.Count; i++) { DungeonMapFloor floor = floors[i]; if (discoveredFloors.Contains(floor)) { // Draw the floor's label box on the left side of the screen. Point2I floorPos = floorBasePos - new Point2I(0, i * 8); string floorName = floor.FloorNumberText; g.DrawString(GameData.FONT_SMALL, floorName, floorPos, new Color(248, 248, 216)); // drop shadow g.DrawString(GameData.FONT_SMALL, floorName, floorPos + new Point2I(0, -1), new Color(56, 32, 16)); g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_BOX_LEFT, GameData.VARIANT_LIGHT, floorPos + new Point2I(32, 0)); g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_BOX_RIGHT, GameData.VARIANT_LIGHT, floorPos + new Point2I(40, 0)); // Draw the icons around the name box. if (viewFloor == floor) g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_INDICATOR, GameData.VARIANT_LIGHT, floorPos + new Point2I(24, 0)); if (playerFloorNumber == floor.FloorNumber) g.DrawSprite(GameData.SPR_UI_MAP_PLAYER, GameData.VARIANT_LIGHT, floorPos + new Point2I(36, 0)); if (floor.IsBossFloor && dungeon.HasCompass) g.DrawSprite(GameData.SPR_UI_MAP_BOSS_FLOOR, GameData.VARIANT_LIGHT, floorPos + new Point2I(48, 0)); // Draw the floor's room display on the right side of the screen. int discoveredFloorIndex = discoveredFloors.IndexOf(floor); Point2I floorRoomDisplayPos = new Point2I(80, 40 - (80 * discoveredFloorIndex) + floorViewPosition); if (floorRoomDisplayPos.Y < GameSettings.SCREEN_HEIGHT && floorRoomDisplayPos.Y > -80) DrawFloor(g, floor, floorRoomDisplayPos); // Draw room display cursor. if (!isChangingFloors && viewFloor == floor && cursorTimer < 32) { Point2I drawPos = floorRoomDisplayPos + (playerRoomLocation * 8); g.DrawSprite(GameData.SPR_UI_MAP_CURSOR, GameData.VARIANT_LIGHT, drawPos); } } } // Draw floor view traversal arrows. if (!isChangingFloors) { if (viewFloorIndex > 0) g.DrawSprite(GameData.SPR_UI_MAP_ARROW_DOWN, GameData.VARIANT_LIGHT, 108, 108); if (viewFloorIndex < discoveredFloors.Count - 1) g.DrawSprite(GameData.SPR_UI_MAP_ARROW_UP, GameData.VARIANT_LIGHT, 108, 28); } // Draw the items panel. if (dungeon.HasMap) g.DrawSprite(GameData.SPR_REWARD_MAP, GameData.VARIANT_LIGHT, 8, 110); if (dungeon.HasCompass) g.DrawSprite(GameData.SPR_REWARD_COMPASS, GameData.VARIANT_LIGHT, 32, 110); if (dungeon.HasBossKey) g.DrawSprite(GameData.SPR_REWARD_BOSS_KEY, GameData.VARIANT_LIGHT, 8, 128); if (dungeon.NumSmallKeys > 0) { g.DrawSprite(GameData.SPR_REWARD_SMALL_KEY, GameData.VARIANT_LIGHT, 32, 128); g.DrawString(GameData.FONT_SMALL, "X" + dungeon.NumSmallKeys.ToString(), new Point2I(40, 136), new Color(144, 136, 16)); // drop shadow g.DrawString(GameData.FONT_SMALL, "X" + dungeon.NumSmallKeys.ToString(), new Point2I(40, 136 - 1), new Color(32, 24, 16)); } }
//----------------------------------------------------------------------------- // Overriden methods //----------------------------------------------------------------------------- protected override void Draw() { Graphics2D g = new Graphics2D(spriteBatch); //g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); Point2I selectedTileLocation = GetSelectedTileLocation(); // Draw the tileset. g.Clear(Color.White); g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value); if (Tileset.SpriteSheet == null) { // Draw each tile's sprite seperately. for (int y = 0; y < Tileset.Height; y++) { for (int x = 0; x < Tileset.Width; x++) { BaseTileData tileData = Tileset.GetTileData(x, y); if (tileData != null) { int spacing = 1; Vector2F drawPos = new Vector2F(x, y) * (Tileset.CellSize + spacing); SpriteAnimation spr = tileData.Sprite; int imageVariantID = tileData.Properties.GetInteger("image_variant", Zone.ImageVariantID); if (imageVariantID < 0) imageVariantID = Zone.ImageVariantID; if (spr.IsAnimation) { int substripIndex = tileData.Properties.GetInteger("substrip_index", 0); spr.Animation = spr.Animation.GetSubstrip(substripIndex); } g.DrawAnimation(tileData.Sprite, imageVariantID, 0.0f, drawPos, Color.White); } } } } else { // Draw the spritesheet's image. g.Translate(-Tileset.SpriteSheet.Offset); g.DrawImage(Tileset.SpriteSheet.Image.GetVariant(Zone.ImageVariantID), Point2I.Zero); g.ResetTranslation(); } // Draw the selection box. if (selectedTileLocation >= Point2I.Zero) { Point2I tilePoint = selectedTileLocation * (Tileset.CellSize + Tileset.Spacing); g.Translate(-this.HorizontalScroll.Value, -this.VerticalScroll.Value); g.DrawRectangle(new Rectangle2I(tilePoint, Tileset.CellSize + 1), 1, Color.White); g.DrawRectangle(new Rectangle2I(tilePoint + 1, Tileset.CellSize - 1), 1, Color.Black); g.DrawRectangle(new Rectangle2I(tilePoint - 1, Tileset.CellSize + 3), 1, Color.Black); g.ResetTranslation(); } g.End(); }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Called every step to draw the game. public void Draw(Graphics2D g) { g.UseIntegerPrecision = true; // Render the game-state stack to a buffer. g.SetRenderTarget(GameData.RenderTargetGame); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.Clear(Color.Black); gameStateStack.Draw(g); g.End(); // Draw the buffer to the screen scaled. g.SetRenderTarget(null); g.ResetTranslation(); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.DrawImage(GameData.RenderTargetGame, Vector2F.Zero, Vector2F.Zero, (Vector2F) gameScale, 0.0); g.End(); }