Beispiel #1
0
		public override void Draw(Graphics2D g) {
			g.Translate(0, 16);
			g.Translate(-RoomControl.ViewControl.ViewPosition);

			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.Center + new Point2I(-8, -23), 0.3f);
				}
				else if (reward.HoldType == RewardHoldTypes.OneHand) {
					g.DrawAnimation(animationPlayer, GameControl.Player.Center + new Point2I(-12, -22), 0.3f);
				}
			}
			
			g.Translate(RoomControl.ViewControl.ViewPosition);
			g.Translate(0, -16);
		}
Beispiel #2
0
        // 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);
            }
        }
Beispiel #3
0
        //-----------------------------------------------------------------------------
        // 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);
            }
        }
Beispiel #4
0
        //-----------------------------------------------------------------------------
        // 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();
        }