public override void Draw(Graphics2D g) { Point2I panNew = -(Directions.ToPoint(direction) * distance); Point2I panOld = Directions.ToPoint(direction) * GameSettings.VIEW_SIZE; g.Translate(panNew); menuOld.Draw(g); g.ResetTranslation(); g.Translate(panNew); g.Translate(panOld); menuNew.Draw(g); g.ResetTranslation(); GameControl.HUD.Draw(g, true); }
public override void Draw(Graphics2D g) { g.Translate(0, 16); if (reward.HoldType == RewardHoldTypes.Raise && useChest) { g.DrawAnimation(animationPlayer, chestPosition + new Point2I(0, -8 - (timer + 2) / 4), 0.3f); } else if (timer >= (useChest ? RaiseDuration : NonChestDuration)) { if (reward.HoldType == RewardHoldTypes.TwoHands) { g.DrawAnimation(animationPlayer, GameControl.Player.Position + new Point2I(-8, -31), 0.3f); } else if (reward.HoldType == RewardHoldTypes.OneHand) { g.DrawAnimation(animationPlayer, GameControl.Player.Position + new Point2I(-12, -30), 0.3f); } } g.Translate(0, -16); }
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); } }
public override void Draw(Graphics2D g) { g.ResetTranslation(); if (timer < TRANSITION_SPLIT_BEGIN_DELAY) { OldRoomControl.Draw(g); } else { NewRoomControl.Draw(g); g.ResetTranslation(); g.Translate(0, 16); g.FillRectangle(new Rectangle2F(0, 0, sideWidths[0], GameSettings.VIEW_HEIGHT), splitColor); g.FillRectangle(new Rectangle2F(GameSettings.VIEW_WIDTH - sideWidths[1], 0, sideWidths[1], GameSettings.VIEW_HEIGHT), splitColor); } }
//----------------------------------------------------------------------------- // 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(); }
// Draw an entire level. public void DrawLevel(Graphics2D g) { g.Clear(new Color(175, 175, 180)); // Gray background. // Draw the level if it is open. if (editorControl.IsLevelOpen) { // Draw the rooms. for (int x = 0; x < Level.Width; x++) { for (int y = 0; y < Level.Height; y++) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); g.Translate((Vector2F)(new Point2I(x, y) * ((Level.RoomSize * GameSettings.TILE_SIZE) + editorControl.RoomSpacing))); DrawRoom(g, Level.GetRoomAt(x, y)); g.ResetTranslation(); } } // Draw the highlight box. if (editorControl.HighlightMouseTile && cursorTileLocation >= Point2I.Zero) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); Rectangle2I box = new Rectangle2I(GetLevelTileCoordDrawPosition(cursorTileLocation), new Point2I(16, 16)); g.DrawRectangle(box.Inflated(1, 1), 1, Color.White); g.ResetTranslation(); } // Draw selection grid. if (selectionGridLevel == Level && !selectionGridArea.IsEmpty) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); if (selectionGrid != null) { for (int i = 0; i < selectionGrid.LayerCount; i++) { for (int y = 0; y < selectionGrid.Height; y++) { for (int x = 0; x < selectionGrid.Width; x++) { Point2I position = GetLevelTileCoordDrawPosition(selectionGridArea.Point + new Point2I(x, y)); TileDataInstance tile = selectionGrid.GetTileIfAtLocation(x, y, i); // Draw tile. if (tile != null) DrawTile(g, tile, position, Color.White); } } } // Draw event tiles. if (editorControl.ShowEvents || editorControl.ShouldDrawEvents) { for (int i = 0; i < selectionGrid.EventTiles.Count; i++) { Point2I position = GetLevelTileCoordDrawPosition(selectionGridArea.Point) + selectionGrid.EventTiles[i].Position; DrawEventTile(g, selectionGrid.EventTiles[i], position, Color.White); } } } // Draw the selection box. if (!selectionBox.IsEmpty) { Point2I start = GetLevelPixelDrawPosition(selectionBox.TopLeft); Point2I end = GetLevelPixelDrawPosition(selectionBox.BottomRight); Rectangle2I box = new Rectangle2I(start, end - start); g.DrawRectangle(box, 1, Color.White); g.DrawRectangle(box.Inflated(1, 1), 1, Color.Black); g.DrawRectangle(box.Inflated(-1, -1), 1, Color.Black); } g.ResetTranslation(); } // Draw selected tiles. foreach (BaseTileDataInstance tile in selectedTiles) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); Rectangle2I bounds = tile.GetBounds(); bounds.Point += GetRoomDrawPosition(tile.Room); g.DrawRectangle(bounds, 1, Color.White); g.DrawRectangle(bounds.Inflated(1, 1), 1, Color.Black); g.DrawRectangle(bounds.Inflated(-1, -1), 1, Color.Black); g.ResetTranslation(); } // Draw player sprite for 'Test At Position' Point2I roomSize = (Level.RoomSize * GameSettings.TILE_SIZE) + editorControl.RoomSpacing; Point2I tilePoint = highlightedRoom * roomSize + highlightedTile * GameSettings.TILE_SIZE; if (editorControl.PlayerPlaceMode && highlightedTile >= Point2I.Zero) { g.DrawSprite(GameData.SPR_PLAYER_FORWARD, (Vector2F) tilePoint + new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); } } }
// Draw an entire level. public void DrawLevel(Graphics2D g) { g.Clear(new Color(175, 175, 180)); // Draw the level if it is open. if (editorControl.IsLevelOpen) { // Draw the rooms. for (int x = 0; x < Level.Width; x++) { for (int y = 0; y < Level.Height; y++) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); g.Translate((Vector2F)(new Point2I(x, y) * ((Level.RoomSize * GameSettings.TILE_SIZE) + editorControl.RoomSpacing))); DrawRoom(g, Level.GetRoomAt(x, y)); g.ResetTranslation(); } } // Draw the highlight box. if (editorControl.HighlightMouseTile && cursorTileLocation >= Point2I.Zero) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); Rectangle2I box = new Rectangle2I(GetLevelTileCoordDrawPosition(cursorTileLocation), new Point2I(16, 16)); g.DrawRectangle(box.Inflated(1, 1), 1, Color.White); g.ResetTranslation(); } // Draw the selection box. if (!selectionBox.IsEmpty) { g.Translate(new Vector2F(-HorizontalScroll.Value, -VerticalScroll.Value)); Point2I start = GetLevelTileCoordDrawPosition(selectionBox.TopLeft); Point2I end = GetLevelTileCoordDrawPosition(selectionBox.BottomRight); Rectangle2I box = new Rectangle2I(start, end - start); g.DrawRectangle(box, 1, Color.White); g.DrawRectangle(box.Inflated(1, 1), 1, Color.Black); g.DrawRectangle(box.Inflated(-1, -1), 1, Color.Black); g.ResetTranslation(); } // Draw player sprite for 'Test At Position' Point2I roomSize = (Level.RoomSize * GameSettings.TILE_SIZE) + editorControl.RoomSpacing; Point2I tilePoint = highlightedRoom * roomSize + highlightedTile * GameSettings.TILE_SIZE; if (editorControl.PlayerPlaceMode && highlightedTile >= Point2I.Zero) { g.DrawSprite(GameData.SPR_PLAYER_FORWARD, tilePoint); } } }
//----------------------------------------------------------------------------- // 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(); }
public override void Draw(Graphics2D g) { // Draw the room. g.Translate(0, 16); g.Translate(-viewControl.Position); // Draw tiles. for (int i = 0; i < room.LayerCount; i++) { for (int x = 0; x < room.Width; x++) { for (int y = 0; y < room.Height; y++) { Tile t = tiles[x, y, i]; if (t != null) t.Draw(g); } } } // Draw entities. g.End(); g.Begin(GameSettings.DRAW_MODE_BACK_TO_FRONT); for (int i = 0; i < entities.Count; ++i) { entities[i].Draw(g); } // Draw event tiles. g.End(); g.Begin(GameSettings.DRAW_MODE_DEFAULT); for (int i = 0; i < eventTiles.Count; ++i) { eventTiles[i].Draw(g); } // Draw HUD. g.End(); g.Begin(GameSettings.DRAW_MODE_DEFAULT); g.ResetTranslation(); GameControl.HUD.Draw(g, false); GameControl.DrawRoomState(g); }
//----------------------------------------------------------------------------- // Internal drawing //----------------------------------------------------------------------------- private void DrawRooms(Graphics2D g) { Point2I panNew = -(Directions.ToPoint(direction) * distance); Point2I panOld = Directions.ToPoint(direction) * GameSettings.VIEW_SIZE; // Draw the old room. g.ResetTranslation(); g.Translate(panNew); roomOld.Draw(g); // Draw the new room. g.Translate(panNew + panOld); roomNew.Draw(g); }