//----------------------------------------------------------------------------- // Slots //----------------------------------------------------------------------------- public virtual void DrawSlotCursor(Graphics2D g, Slot slot) { Sprite tR = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(9, 0)); Sprite bR = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(9, 1)); Sprite tL = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(10, 0)); Sprite bL = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(10, 1)); g.DrawSprite(tR, slot.Position + new Point2I(-8, 0)); g.DrawSprite(bR, slot.Position + new Point2I(-8, 8)); g.DrawSprite(tL, slot.Position + new Point2I(slot.Width, 0)); g.DrawSprite(bL, slot.Position + new Point2I(slot.Width, 8)); }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Draws the HUD. public void Draw(Graphics2D g, bool light) { int lightDark = (light ? GameData.VARIANT_LIGHT : GameData.VARIANT_DARK); Rectangle2I r = new Rectangle2I(0, 0, GameSettings.SCREEN_WIDTH, 16); g.DrawSprite(GameData.SPR_HUD_BACKGROUND, lightDark, r); DrawItems(g, lightDark); DrawRupees(g, lightDark); DrawHearts(g, lightDark); }
// Draw all the queued drawing instructions to a graphics object. public void DrawAll(Graphics2D g) { // Draw all instructions from the lowest layer to the highest layer. for (int i = 0; i < layerHeads.Length; i++) { DrawingInstruction instruction = layerHeads[i]; while (instruction != null) { g.DrawSprite(instruction.sprite, instruction.imageVariant, instruction.position.X, instruction.position.Y); instruction = instruction.next; } } }
public override void DrawOver(Graphics2D g) { Vector2F pos = player.Position + objectDrawOffset + carryObject.Graphics.DrawOffset; pos.Y -= player.ZPosition; // Handle head bobbing when the player is moving horizontally. if (!isPickingUp && (player.Direction == Directions.Left || player.Direction == Directions.Right) && player.Graphics.AnimationPlayer.PlaybackTime >= 6) { pos.Y += 1; } // Draw the object. if (carryObject.Graphics.AnimationPlayer.SubStrip != null) { g.DrawAnimation(carryObject.Graphics.AnimationPlayer.SubStrip, carryObject.Graphics.ImageVariant, carryObject.Graphics.AnimationPlayer.PlaybackTime, pos, 0.0f); } else if (carryObject.Graphics.Sprite != null) g.DrawSprite(carryObject.Graphics.Sprite, carryObject.Graphics.ImageVariant, pos, 0.0f); }
//----------------------------------------------------------------------------- // Virtual //----------------------------------------------------------------------------- // Draws the item inside the inventory. public virtual void DrawSlot(Graphics2D g, Point2I position, int lightOrDark) { g.DrawSprite(sprite, lightOrDark, position); }
// Draws the item inside the inventory. protected override void DrawSprite(Graphics2D g, Point2I position, int lightOrDark) { Sprite spr = sprite[level]; if (inventory.IsWeaponEquipped(this) && spriteEquipped != null) spr = spriteEquipped[level]; g.DrawSprite(spr, lightOrDark, position); }
// Draws the item inside the inventory. public override void DrawSlot(Graphics2D g, Point2I position, int lightOrDark) { DrawSprite(g, position, lightOrDark); DrawAmmo(g, position, lightOrDark); g.DrawSprite(ammo[currentAmmo].Sprite, lightOrDark, position + new Point2I(8, 0)); }
// Draws the equipped usable items. private void DrawItems(Graphics2D g, int lightDark) { if (Inventory.IsTwoHandedEquipped) { // B bracket side g.DrawSprite(GameData.SPR_HUD_BRACKET_LEFT_B, lightDark, new Point2I(8, 0)); // A bracket side g.DrawSprite(GameData.SPR_HUD_BRACKET_RIGHT_A, lightDark, new Point2I(56, 0)); Inventory.EquippedWeapons[0].DrawSlot(g, new Point2I(16, 0), lightDark); } else if (!gameControl.IsAdvancedGame) { // B bracket g.DrawSprite(GameData.SPR_HUD_BRACKET_LEFT_B, lightDark, new Point2I(0, 0)); g.DrawSprite(GameData.SPR_HUD_BRACKET_RIGHT, lightDark, new Point2I(32, 0)); // A bracket g.DrawSprite(GameData.SPR_HUD_BRACKET_LEFT_A, lightDark, new Point2I(40, 0)); g.DrawSprite(GameData.SPR_HUD_BRACKET_RIGHT, lightDark, new Point2I(72, 0)); if (Inventory.EquippedWeapons[1] != null) Inventory.EquippedWeapons[1].DrawSlot(g, new Point2I(8, 0), lightDark); if (Inventory.EquippedWeapons[0] != null) Inventory.EquippedWeapons[0].DrawSlot(g, new Point2I(48, 0), lightDark); } else { // B bracket side g.DrawSprite(GameData.SPR_HUD_BRACKET_LEFT_B, lightDark, new Point2I(0, 0)); // Both bracket side g.DrawSprite(GameData.SPR_HUD_BRACKET_LEFT_RIGHT, lightDark, new Point2I(32, 0)); // A bracket side g.DrawSprite(GameData.SPR_HUD_BRACKET_RIGHT_A, lightDark, new Point2I(64, 0)); if (Inventory.EquippedWeapons[1] != null) Inventory.EquippedWeapons[1].DrawSlot(g, new Point2I(8, 0), lightDark); if (Inventory.EquippedWeapons[0] != null) Inventory.EquippedWeapons[0].DrawSlot(g, new Point2I(40, 0), lightDark); } }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- protected virtual void DrawSprite(Graphics2D g, Point2I position, int lightOrDark) { g.DrawSprite(sprite[level], lightOrDark, position); }
public virtual void Draw(Graphics2D g) { SpriteAnimation sprite = (!customSprite.IsNull ? customSprite : CurrentSprite); if (isMoving && !spriteAsObject.IsNull) sprite = spriteAsObject; if (sprite.IsAnimation) { // Draw as an animation. g.DrawAnimation(sprite.Animation, Zone.ImageVariantID, RoomControl.GameControl.RoomTicks, Position); } else if (sprite.IsSprite) { // Draw as a sprite. g.DrawSprite(sprite.Sprite, Zone.ImageVariantID, Position); } }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Draw a tile. private void DrawTile(Graphics2D g, TileDataInstance tile, Point2I position, Color drawColor) { Sprite sprite = null; Animation animation = null; float playbackTime = editorControl.Ticks; int substripIndex = tile.Properties.GetInteger("substrip_index", 0); //----------------------------------------------------------------------------- // Platform. if (tile.Type == typeof(TilePlatform)) { if (!tile.CurrentSprite.IsNull) { // Draw the tile once per point within its size. for (int y = 0; y < tile.Size.Y; y++) { for (int x = 0; x < tile.Size.X; x++) { Point2I drawPos = position + (new Point2I(x, y) * GameSettings.TILE_SIZE); g.DrawAnimation(tile.CurrentSprite, tile.Room.Zone.ImageVariantID, editorControl.Ticks, position, drawColor); } } } return; } //----------------------------------------------------------------------------- // Color Jump Pad. else if (tile.Type == typeof(TileColorJumpPad)) { PuzzleColor tileColor = (PuzzleColor) tile.Properties.GetInteger("color", 0); if (tileColor == PuzzleColor.Red) sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_RED; else if (tileColor == PuzzleColor.Yellow) sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_YELLOW; else if (tileColor == PuzzleColor.Blue) sprite = GameData.SPR_TILE_COLOR_JUMP_PAD_BLUE; } //----------------------------------------------------------------------------- // Color Cube else if (tile.Type == typeof(TileColorCube)) { int orientationIndex = tile.Properties.GetInteger("orientation", 0); sprite = GameData.SPR_COLOR_CUBE_ORIENTATIONS[orientationIndex]; } //----------------------------------------------------------------------------- // Crossing Gate. else if (tile.Type == typeof(TileCrossingGate)) { if (tile.Properties.GetBoolean("raised", false)) animation = GameData.ANIM_TILE_CROSSING_GATE_LOWER; else animation = GameData.ANIM_TILE_CROSSING_GATE_RAISE; substripIndex = (tile.Properties.GetBoolean("face_left", false) ? 1 : 0); playbackTime = 0.0f; } //----------------------------------------------------------------------------- // Lantern. else if (tile.Type == typeof(TileLantern)) { if (tile.Properties.GetBoolean("lit", true)) animation = GameData.ANIM_TILE_LANTERN; else sprite = GameData.SPR_TILE_LANTERN_UNLIT; } //----------------------------------------------------------------------------- // Chest. else if (tile.Type == typeof(TileChest)) { bool isLooted = tile.Properties.GetBoolean("looted", false); sprite = tile.SpriteList[isLooted ? 1 : 0].Sprite; } //----------------------------------------------------------------------------- // Color Lantern. /*else if (tile.Type == typeof(TileColorLantern)) { PuzzleColor color = (PuzzleColor) tile.Properties.GetInteger("color", -1); if (color == PuzzleColor.Red) animation = GameData.ANIM_EFFECT_COLOR_FLAME_RED; else if (color == PuzzleColor.Yellow) animation = GameData.ANIM_EFFECT_COLOR_FLAME_YELLOW; else if (color == PuzzleColor.Blue) animation = GameData.ANIM_EFFECT_COLOR_FLAME_BLUE; }*/ //----------------------------------------------------------------------------- if (animation == null && sprite == null && tile.CurrentSprite.IsAnimation) animation = tile.CurrentSprite.Animation; if (animation == null && sprite == null && tile.CurrentSprite.IsSprite) sprite = tile.CurrentSprite.Sprite; // Draw the custom sprite/animation if (animation != null) { g.DrawAnimation(animation.GetSubstrip(substripIndex), tile.Room.Zone.ImageVariantID, playbackTime, position, drawColor); } else if (sprite != null) { g.DrawSprite(sprite, tile.Room.Zone.ImageVariantID, position, drawColor); } /*else if (!tile.CurrentSprite.IsNull) { g.DrawAnimation(tile.CurrentSprite, tile.Room.Zone.ImageVariantID, editorControl.Ticks, position, drawColor); }*/ // Draw rewards. if (editorControl.ShowRewards && tile.Properties.Exists("reward") && editorControl.RewardManager.HasReward(tile.Properties.GetString("reward"))) { Animation anim = editorControl.RewardManager.GetReward(tile.Properties.GetString("reward")).Animation; g.DrawAnimation(anim, editorControl.Ticks, position, drawColor); } }
// Draws the ruppes and dungeon keys. private void DrawRupees(Graphics2D g, int lightDark) { Color black = (lightDark == GameData.VARIANT_LIGHT ? new Color(16, 16, 16) : Color.Black); bool inDungeon = false; int advancedOffset = (gameControl.IsAdvancedGame ? 8 : 0); int numKeys = 0; if (inDungeon) { g.DrawSprite(GameData.SPR_HUD_KEY, lightDark, new Point2I(80 - advancedOffset, 0)); g.DrawSprite(GameData.SPR_HUD_X, lightDark, new Point2I(88 - advancedOffset, 0)); g.DrawString(GameData.FONT_SMALL, numKeys.ToString(), new Point2I(96 - advancedOffset, 0), black); } else { g.DrawSprite(GameData.SPR_HUD_RUPEE, lightDark, new Point2I(80 - advancedOffset, 0)); } g.DrawString(GameData.FONT_SMALL, dynamicRupees.ToString("000"), new Point2I(80 - advancedOffset, 8), black); }
// Draws the item inside the inventory. protected override void DrawSprite(Graphics2D g, Point2I position, int lightOrDark) { Sprite spr = sprite[level]; if (spriteEquipped != null) spr = spriteEquipped[level]; g.DrawSprite(isEquipped ? spr : sprite[level], lightOrDark, position); }
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)); } }
//----------------------------------------------------------------------------- // Map Drawing //----------------------------------------------------------------------------- private void DrawRoom(Graphics2D g, DungeonMapRoom room, Point2I position) { if (room == null) return; // Determine the sprite to draw for the room. Sprite sprite = null; if (room.IsDiscovered) sprite = room.Sprite; else if (dungeon.HasMap) sprite = GameData.SPR_UI_MAP_UNDISCOVERED_ROOM; // Determine extra sprite to draw for the room (treasure, boss, or player). Sprite extraSprite = null; if (playerRoomLocation == room.Location && playerFloorNumber == room.Floor.FloorNumber && (cursorTimer >= 32 || isChangingFloors || room.Floor != viewFloor)) { extraSprite = GameData.SPR_UI_MAP_PLAYER; } else if (dungeon.HasCompass) { if (room.IsBossRoom) extraSprite = GameData.SPR_UI_MAP_BOSS_ROOM; else if (room.HasTreasure) extraSprite = GameData.SPR_UI_MAP_TREASURE_ROOM; } // Draw the two sprites. if (sprite != null) g.DrawSprite(sprite, GameData.VARIANT_LIGHT, position); if (extraSprite != null) g.DrawSprite(extraSprite, GameData.VARIANT_LIGHT, position); }
private void DrawFloor(Graphics2D g, DungeonMapFloor floor, Point2I position) { // Draw the floor background rectangle. g.DrawSprite(GameData.SPR_UI_MAP_FLOOR_BACKGROUND, GameData.VARIANT_LIGHT, new Rectangle2I(position, new Point2I(64, 64))); // Draw the rooms. for (int x = 0; x < floor.Width; x++) { for (int y = 0; y < floor.Height; y++) { Point2I drawPos = position + (new Point2I(x, y) * 8); DrawRoom(g, floor.Rooms[x, y], drawPos); } } }
public override void Draw(Graphics2D g) { Point2I pos = new Point2I(8, 24); if (GameControl.Player.Y < ((GameSettings.VIEW_HEIGHT) / 2 + 8)) pos.Y = 96; // TODO: Apply Player position based on view g.FillRectangle(new Rectangle2I(pos, new Point2I(144, 8 + 16 * linesPerWindow)), Color.Black); // Draw the finished writting lines. for (int i = 0; i < windowLine; i++) { if (state == TextReaderState.PushingLine && timer >= 2) g.DrawLetterString(GameData.FONT_LARGE, wrappedString.Lines[currentLine - windowLine + i], pos + new Point2I(8, 6 + 16 * i + 8), TextColor); else g.DrawLetterString(GameData.FONT_LARGE, wrappedString.Lines[currentLine - windowLine + i], pos + new Point2I(8, 6 + 16 * i), TextColor); } // Draw the currently writting line. g.DrawLetterString(GameData.FONT_LARGE, wrappedString.Lines[currentLine].Substring(0, currentChar), pos + new Point2I(8, 6 + 16 * windowLine), TextColor); // Draw the next line arrow. if ((state == TextReaderState.PressToContinue || state == TextReaderState.PressToEndParagraph) && arrowTimer >= 16) g.DrawSprite(GameData.SPR_HUD_TEXT_NEXT_ARROW, pos + new Point2I(136, 16 * linesPerWindow)); }
// 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)); } } }
public void Draw(Graphics2D g) { // Depth ranges: if (!isVisible || (isFlickering && !flickerIsVisible)) return; // Front [0.0 - 0.3][0.3 - 0.6][0.6 - 0.9][0.9 ][0.9 - 1.0] Back // [??? ][Entities ][??? ][Shadows][??? ] float shadowDepth = 0.9f; float ripplesDepth = 0.29f; float grassDepth = 0.28f; // Draw the shadow. if (isShadowVisible && entity.ZPosition > 1 && entity.GameControl.RoomTicks % 2 == 0) { g.DrawSprite(GameData.SPR_SHADOW, Entity.Position + shadowDrawOffset, shadowDepth); } // Draw the sprite/animation. float depth = 0.6f - 0.3f * (entity.Origin.Y / (float) (entity.RoomControl.Room.Height * GameSettings.TILE_SIZE)); Vector2F drawPosition = Entity.Position - new Vector2F(0, Entity.ZPosition); if (animationPlayer.SubStrip != null) g.DrawAnimation(animationPlayer.SubStrip, imageVariant, animationPlayer.PlaybackTime, drawPosition + drawOffset, depth); else if (sprite != null) g.DrawSprite(sprite, imageVariant, drawPosition + drawOffset, depth); // Draw the ripples effect. if (isRipplesEffectVisible && entity.Physics.IsEnabled && entity.Physics.IsInPuddle) g.DrawAnimation(GameData.ANIM_EFFECT_RIPPLES, entity.GameControl.RoomTicks, entity.Origin + ripplesDrawOffset, ripplesDepth); // Draw the grass effect. if (isGrassEffectVisible && entity.Physics.IsEnabled &&entity.Physics.IsInGrass) g.DrawAnimation(GameData.ANIM_EFFECT_GRASS, grassAnimationTicks, entity.Origin + grassDrawOffset, grassDepth); if (drawCollisionBoxes) { g.FillRectangle(entity.Physics.SoftCollisionBox + entity.Position, new Color(0, 0, 255, 150), depth - 0.0001f); g.FillRectangle(entity.Physics.CollisionBox + entity.Position, new Color(255, 0, 0, 150), depth - 0.0002f); g.FillRectangle(new Rectangle2F(entity.Origin, Vector2F.One), Color.White, depth - 0.0003f); } }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- public void DrawSlot(Graphics2D g, Point2I position, int lightOrDark) { if (sprite != null) g.DrawSprite(sprite, position); }
// Draw an event tile. private void DrawEventTile(Graphics2D g, EventTileDataInstance eventTile, Color color) { Sprite spr = eventTile.Sprite; // Select different sprites for certain events. if (eventTile.Type == typeof(WarpEvent)) { string warpType = eventTile.Properties.GetString("warp_type"); if (warpType == "tunnel") spr = GameData.SPR_EVENT_TILE_WARP_TUNNEL; else if (warpType == "stairs") spr = GameData.SPR_EVENT_TILE_WARP_STAIRS; else if (warpType == "entrance") spr = GameData.SPR_EVENT_TILE_WARP_ENTRANCE; } // Draw the sprite. if (spr != null) { g.DrawSprite(spr, eventTile.Room.Zone.ImageVariantID, eventTile.Position); } else { Rectangle2I r = new Rectangle2I(eventTile.Position, eventTile.Size * GameSettings.TILE_SIZE); g.FillRectangle(r, Color.Blue); } }
protected virtual void DrawLevel(Graphics2D g, Point2I position, int lightOrDark) { Color color = (lightOrDark == GameData.VARIANT_LIGHT ? new Color(16, 16, 16) : Color.Black); g.DrawSprite(GameData.SPR_HUD_LEVEL, lightOrDark, position + new Point2I(8, 8)); g.DrawString(GameData.FONT_SMALL, (level + 1).ToString(), position + new Point2I(16, 8), color); }
// 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); } } }
// Draws the player's life. private void DrawHearts(Graphics2D g, int lightDark) { for (int i = 0; i < gameControl.Player.MaxHealth / 4; i++) { int fullness = GMath.Clamp(dynamicHealth - i * 4, 0, 4); if (!gameControl.IsAdvancedGame) g.DrawSprite(GameData.SPR_HUD_HEARTS[fullness], lightDark, new Point2I(104 + (i % 7) * 8, (i / 7) * 8)); else g.DrawSprite(GameData.SPR_HUD_HEARTS[fullness], lightDark, new Point2I(96 + (i % 8) * 8, (i / 8) * 8)); } }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- public void DrawHeartPieces(Graphics2D g) { for (int i = 0; i < 4; i++) { if (i < GameControl.Inventory.PiecesOfHeart) g.DrawSprite(GameData.SPR_HUD_HEART_PIECES_FULL[i], new Point2I(112, 8)); else g.DrawSprite(GameData.SPR_HUD_HEART_PIECES_EMPTY[i], new Point2I(112, 8)); } g.DrawString(GameData.FONT_SMALL, GameControl.Inventory.PiecesOfHeart.ToString() + "/4", new Point2I(120, 40), new Color(16, 16, 16)); }
// Draws the ruppes and dungeon keys. private void DrawRupees(Graphics2D g, int lightDark) { Color black = (lightDark == GameData.VARIANT_LIGHT ? new Color(16, 16, 16) : Color.Black); int advancedOffset = (gameControl.IsAdvancedGame ? 8 : 0); Dungeon dungeon = gameControl.RoomControl.Dungeon; if (dungeon != null) { // Display the small key count. g.DrawSprite(GameData.SPR_HUD_KEY, lightDark, new Point2I(80 - advancedOffset, 0)); g.DrawSprite(GameData.SPR_HUD_X, lightDark, new Point2I(88 - advancedOffset, 0)); g.DrawString(GameData.FONT_SMALL, dungeon.NumSmallKeys.ToString(), new Point2I(96 - advancedOffset, 0), black); } else { // Display rupee icon. g.DrawSprite(GameData.SPR_HUD_RUPEE, lightDark, new Point2I(80 - advancedOffset, 0)); } g.DrawString(GameData.FONT_SMALL, dynamicRupees.ToString("000"), new Point2I(80 - advancedOffset, 8), black); }
public override void Draw(Graphics2D g) { base.Draw(g); if (inSubMenu) { Point2I maxSize = new Point2I(ammoSlotGroup.NumSlots * 24 + 8, 32); Point2I menuPos = new Point2I((160 - (ammoSlotGroup.NumSlots * 24 + 8)) / 2 + (maxSize.X - ammoMenuSize.X) / 2, DrawAmmoMenuAtTop ? 16 : 56); Sprite ammoMenuSprite = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(1, 4)); g.DrawSprite(ammoMenuSprite, new Rectangle2I(menuPos, ammoMenuSize)); if (IsAmmoMenuFullyOpen) { ammoSlotGroup.Draw(g); } if (currentSlotGroup != null) { DrawSlotCursor(g, currentSlotGroup.CurrentSlot); } } }
public override void DrawSlotCursor(Graphics2D g, Slot slot) { if (!inSubMenu) { base.DrawSlotCursor(g, slot); } else if (IsAmmoMenuFullyOpen) { Sprite arrowSprite = new Sprite(GameData.SHEET_MENU_SMALL_LIGHT, new Point2I(5, 5)); g.DrawSprite(arrowSprite, slot.Position + new Point2I(4, 20)); } }
//----------------------------------------------------------------------------- // Virtual //----------------------------------------------------------------------------- // Draws the item inside the inventory. public override void DrawSlot(Graphics2D g, Point2I position, int lightOrDark) { g.DrawSprite(sprite, position + new Point2I(4, 0)); g.DrawString(GameData.FONT_SMALL, Amount.ToString("00"), position + new Point2I(0, 12), new Color(248, 248, 248)); }