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 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); }
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 //----------------------------------------------------------------------------- // 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); } }
// Draw an event tile. private void DrawEventTile(Graphics2D g, EventTileDataInstance eventTile, Point2I position, Color drawColor) { SpriteAnimation spr = eventTile.CurrentSprite; int imageVariantID = eventTile.Properties.GetInteger("image_variant"); if (imageVariantID < 0) imageVariantID = eventTile.Room.Zone.ImageVariantID; // Select different sprites for certain events. if (eventTile.Type == typeof(NPCEvent)) { eventTile.SubStripIndex = eventTile.Properties.GetInteger("direction", 0); } else if (eventTile.Type == typeof(WarpEvent)) { string warpTypeStr = eventTile.Properties.GetString("warp_type", "tunnel"); WarpType warpType = (WarpType) Enum.Parse(typeof(WarpType), warpTypeStr, true); if (warpType == WarpType.Entrance) spr = GameData.SPR_EVENT_TILE_WARP_ENTRANCE; else if (warpType == WarpType.Tunnel) spr = GameData.SPR_EVENT_TILE_WARP_TUNNEL; else if (warpType == WarpType.Stairs) spr = GameData.SPR_EVENT_TILE_WARP_STAIRS; } // Draw the sprite. if (!spr.IsNull) { g.DrawAnimation(spr, imageVariantID, editorControl.Ticks, position, drawColor); } else { Rectangle2I r = new Rectangle2I(position, eventTile.Size * GameSettings.TILE_SIZE); g.FillRectangle(r, Color.Blue); } }
public override void Draw(Graphics2D g) { // TEMPORARY: Change tool drawing to something else if (toolAnimation.Animation != null) g.DrawAnimation(toolAnimation, position - new Vector2F(8, 16 + ZPosition), 0.6f); base.Draw(g); state.DrawOver(g); }
//----------------------------------------------------------------------------- // Drawing //----------------------------------------------------------------------------- // Draw a tile. private void DrawTile(Graphics2D g, TileDataInstance tile, Color color) { Point2I position = tile.Location * GameSettings.TILE_SIZE; // Draw tile sprite/animation. if (!tile.CurrentSprite.IsNull) g.DrawAnimation(tile.CurrentSprite, tile.Room.Zone.ImageVariantID, editorControl.Ticks, position, color); // 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, color); } }
//----------------------------------------------------------------------------- // 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 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); } }