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);
            }
        }
예제 #2
0
 public override void Draw(Graphics2D g)
 {
     float opacity = timer / duration;
     if (type == FadeType.FadeIn)
         opacity = 1.0f - opacity;
     Color c = color * opacity;
     //c.A = (byte) (255.0f * opacity);
     g.FillRectangle(GameSettings.SCREEN_BOUNDS, c);
 }
        public override void Draw(Graphics2D g)
        {
            g.ResetTranslation();

            // Draw the room.
            if (isBeginningFade)
                OldRoomControl.Draw(g);
            else
                NewRoomControl.Draw(g);

            // Draw the fade.
            int t = timer;
            int delay = TRANSITION_SWITCH_FADE_DELAY / 2;
            if (!isBeginningFade)
                t = (TRANSITION_FADE_DURATION - delay) - t;
            float opacity = t / (float) (TRANSITION_FADE_DURATION - delay);
            opacity = GMath.Clamp(opacity, 0.0f, 1.0f);
            g.FillRectangle(GameSettings.SCREEN_BOUNDS, fadeColor * opacity);
        }
예제 #4
0
        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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        // Draw an entire room.
        private void DrawRoom(Graphics2D g, Room room)
        {
            Color belowFade = new Color(255, 255, 255, 150);
            Color aboveFade = new Color(255, 255, 255, 100);
            Color hide = Color.Transparent;
            Color normal = Color.White;

            // Draw white background.
            g.FillRectangle(new Rectangle2I(Point2I.Zero, room.Size * GameSettings.TILE_SIZE), Color.White);

            // Draw tile layers.
            for (int i = 0; i < room.LayerCount; i++) {
                // Determine color/transparency for layer based on layer visibility.
                Color color = normal;
                if (!editorControl.ShouldDrawEvents) {
                    if (editorControl.CurrentLayer > i) {
                        if (editorControl.BelowTileDrawMode == TileDrawModes.Hide)
                            color = hide;
                        else if (editorControl.BelowTileDrawMode == TileDrawModes.Fade)
                            color = belowFade;
                    }
                    else if (editorControl.CurrentLayer < i) {
                        if (editorControl.AboveTileDrawMode == TileDrawModes.Hide)
                            color = hide;
                        else if (editorControl.AboveTileDrawMode == TileDrawModes.Fade)
                            color = aboveFade;
                    }
                }

                // Draw the tile grid for this layer.
                for (int x = 0; x < room.Width; x++) {
                    for (int y = 0; y < room.Height; y++) {
                        Point2I position = new Point2I(x, y) * GameSettings.TILE_SIZE;
                        TileDataInstance tile = room.GetTile(x, y, i);

                        // Draw tile.
                        if (tile != null && tile.IsAtLocation(x, y))
                            DrawTile(g, tile, position, color);

                        // Draw grid square.
                        if (i == room.LayerCount - 1) {
                            if (editorControl.ShowGrid)
                                g.DrawRectangle(new Rectangle2I(position, new Point2I(GameSettings.TILE_SIZE + 1)), 1, new Color(0, 0, 0, 150));
                        }
                    }
                }
            }

            // Draw event tiles.
            if (editorControl.ShowEvents || editorControl.ShouldDrawEvents) {
                for (int i = 0; i < room.EventData.Count; i++)
                    DrawEventTile(g, room.EventData[i], room.EventData[i].Position, Color.White);
            }

            // Draw the spacing lines between rooms.
            if (editorControl.RoomSpacing > 0) {
                g.FillRectangle(new Rectangle2I(0, room.Height * GameSettings.TILE_SIZE, room.Width * GameSettings.TILE_SIZE, editorControl.RoomSpacing), Color.Black);
                g.FillRectangle(new Rectangle2I(room.Width * GameSettings.TILE_SIZE, 0, editorControl.RoomSpacing, room.Height * GameSettings.TILE_SIZE + editorControl.RoomSpacing), Color.Black);
            }
        }
        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));
        }
예제 #8
0
        /** <summary> Draws the debug menu. </summary> */
        private void DrawMenu(Graphics2D g, DebugMenuItem item, int pathIndex, Point2I position)
        {
            if (pathIndex >= currentPath.Count)
            return;

            int itemWidth  = 32;
            int itemHeight = 28;
            int offset = 32;
            int textOffset   = 0;
            int hotkeyOffset = 0;
            int hotkeyColumnWidth = 0;
            int textColumnWidth = 0;
            int rightPading = 24;
            //int padding = 20;
            int hotkeyColumnPadding = 20;
            if (pathIndex == 0) {
            offset = 6;
            rightPading = 8;
            hotkeyColumnPadding = 0;
            }

            // Measure the width to draw the menu at.
            for (int i = 0; i < item.Items.Count; ++i) {
            DebugMenuItem subItem = item.Items[i];

            Rectangle2I r1 = (Rectangle2I)debugMenuFont.MeasureStringBounds(subItem.Text, Align.Left);
            Rectangle2I r2 = (Rectangle2I)debugMenuFont.MeasureStringBounds(subItem.HotKey.Name, Align.Left);
            hotkeyOffset = GMath.Max(hotkeyOffset, r1.Width + offset + 10);
            itemWidth = GMath.Max(itemWidth, r1.Width + r2.Width + offset + rightPading);
            textColumnWidth   = GMath.Max(textColumnWidth, r1.Width);
            hotkeyColumnWidth = GMath.Max(hotkeyColumnWidth, r2.Width);
            }
            hotkeyOffset = offset + textColumnWidth + hotkeyColumnPadding;
            textOffset = offset;
            itemWidth = offset + textColumnWidth + hotkeyColumnPadding + hotkeyColumnWidth + rightPading;

            // Draw outline.
            Rectangle2I menuRect = new Rectangle2I(position.X, position.Y, itemWidth, itemHeight * item.Items.Count);
            if (pathIndex == 0) {
            menuRect.Width = itemWidth * item.Items.Count;
            menuRect.Height = itemHeight;
            }
            g.DrawRectangle(menuRect, 1.0f, colorOutline);

            // Draw background.
            menuRect.Inflate(-1, -1);
            g.FillRectangle(menuRect, colorBackground);

            // Draw item list.
            for (int i = 0; i < item.Items.Count; ++i) {
            Rectangle2I r = new Rectangle2I(position.X, position.Y, itemWidth, itemHeight);

            if (pathIndex == 0) {
                r.Inflate(0, -1);
                if (i == 0) {
                    r.X += 1;
                    r.Width -= 1;
                }
                if (i == item.Items.Count - 1)
                    r.Width -= 1;
            }
            else {
                r.Inflate(-1, 0);
                if (i == 0) {
                    r.Y += 1;
                    r.Height -= 1;
                }
                if (i == item.Items.Count - 1)
                    r.Height -= 1;
            }

            DebugMenuItem subItem = item.Items[i];

            // Draw highlight.
            if (currentPath[pathIndex] == i) {
                Rectangle2F sr = (Rectangle2I)r;
                sr.Inflate(-2, -2);
                if (controlMode == MenuControlMode.Keyboard || controlMode == MenuControlMode.GamePad || pathIndex < currentPath.Count - 1)
                    g.FillRectangle(sr, colorBackgroundHighlight);
            }
            Point2I ms = (Point2I)Mouse.GetPosition();
            if (r.Contains(ms)) {
                mouseHover = true;
                mouseHoverItem = subItem;
                Rectangle2F sr = (Rectangle2I)r;
                sr.Inflate(-2, -2);
                if (controlMode == MenuControlMode.Mouse)
                    g.FillRectangle(sr, colorBackgroundHighlight);
            }

            // Draw text label.
            string text   = subItem.Text;
            string hotkey = subItem.HotKey.Name;
            g.DrawRealString(debugMenuFont, text, new Point2I(r.Min.X + textOffset, (int)r.Center.Y), Align.Left | Align.Int, colorText);
            g.DrawRealString(debugMenuFont, hotkey, new Point2I(r.Min.X + hotkeyOffset, (int)r.Center.Y), Align.Left | Align.Int, colorHotkey);

            // Draw toggle check.
            if (subItem is ToggleMenuItem) {
                bool enabled = ((ToggleMenuItem)subItem).IsEnabled;
                SpriteEx spr = debugMenuSprites["checkbox_disabled"];
                if (enabled)
                    spr = debugMenuSprites["checkbox_enabled"];
                if (subItem is RadioButtonMenuItem) {
                    spr = debugMenuSprites["radiobutton_disabled"];
                    if (enabled)
                        spr = debugMenuSprites["radiobutton_enabled"];
                }
                g.DrawSpriteEx(spr, new Vector2F(r.Min.X + 6, r.Min.Y + 6), colorText);
            }

            // Draw submenu arrow.
            if (item != menu && subItem.Items.Count > 0) {
                g.DrawSpriteEx(debugMenuSprites["submenu_arrow"], new Vector2F(r.Max.X - 18, r.Min.Y + 6), colorArrow);
            }

            // Draw nested menu.
            if (currentPath[pathIndex] == i) {
                Point2I p = position;
                if (pathIndex == 0)
                    p.Y += itemHeight - 1;
                else
                    p.X += itemWidth - 1;

                DrawMenu(g, subItem, pathIndex + 1, p);
            }

            // Move current position.
            if (pathIndex == 0)
                position.X += itemWidth;
            else
                position.Y += itemHeight;
            }
        }
예제 #9
0
        // 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);
            }
        }
예제 #10
0
        private static void DrawTile(Graphics2D g, Tile tile)
        {
            if (TileDebugInfoMode == TileDrawInfo.CollisionBoxes) {
                if (tile.IsSolid && tile.CollisionModel != null) {
                    foreach (Rectangle2F box in tile.CollisionModel.Boxes) {
                        Rectangle2F r = Rectangle2F.Translate(box, tile.Position);
                        g.FillRectangle(r, Color.Red);
                        //g.DrawRectangle(r, 1, Color.Maroon);
                    }
                }
            }
            else if (TileDebugInfoMode == TileDrawInfo.GridArea) {
                Rectangle2F tileBounds = (Rectangle2F) tile.TileGridArea;
                tileBounds.Point *= GameSettings.TILE_SIZE;
                tileBounds.Size *= GameSettings.TILE_SIZE;
                Color c = Color.Yellow;
                if (tile.Layer == 1)
                    c = Color.Blue;
                else if (tile.Layer == 2)
                    c = Color.Red;
                g.FillRectangle(tileBounds, c);

                tileBounds = new Rectangle2F(tile.Position, tile.Size * GameSettings.TILE_SIZE);
                c = Color.Olive;
                if (tile.Layer == 1)
                    c = Color.Cyan;
                else if (tile.Layer == 2)
                    c = Color.Maroon;

                g.DrawLine(new Line2F(tileBounds.TopLeft, tileBounds.BottomRight - new Point2I(1, 1)), 1, c);
                g.DrawLine(new Line2F(tileBounds.TopRight - new Point2I(1, 0), tileBounds.BottomLeft - new Point2I(0, 1)), 1, c);
                g.DrawRectangle(tileBounds, 1, Color.Black);
            }
        }
예제 #11
0
        private static void DrawEntity(Graphics2D g, Entity entity)
        {
            if (EntityDebugInfoMode == EntityDrawInfo.CollisionBoxes) {
                g.FillRectangle(entity.Physics.SoftCollisionBox + entity.Position, new Color(0, 0, 255, 150));
                g.FillRectangle(entity.Physics.CollisionBox + entity.Position, new Color(255, 0, 0, 150));
                g.FillRectangle(new Rectangle2F(entity.Position, Vector2F.One), new Color(255, 255, 0));

                if (entity is Unit) {
                    Unit unit = (Unit) entity;
                    foreach (UnitTool tool in unit.EquippedTools) {
                        if (tool.IsPhysicsEnabled) {
                            g.FillRectangle(tool.PositionedCollisionBox, new Color(255, 0, 255, 150));
                        }
                    }
                }
            }
            else if (EntityDebugInfoMode == EntityDrawInfo.CollisionTests) {
                if (entity.Physics.IsEnabled && entity.Physics.CollideWithWorld || entity is Player) {
                    // Draw the hard collision box.
                    Rectangle2F collisionBox = entity.Physics.PositionedCollisionBox;
                    Color collisionBoxColor = Color.Yellow;
                    if (entity is Player && ((Player) entity).Movement.IsOnSideScrollLadder)
                        collisionBoxColor = new Color(255, 160, 0);
                    collisionBox.X = GMath.Round(collisionBox.X + 0.001f);
                    collisionBox.Y = GMath.Round(collisionBox.Y + 0.001f);
                    //collisionBox.Point = GMath.Round(collisionBox.Point);
                    g.FillRectangle(collisionBox, collisionBoxColor);

                    for (int i = 0; i < 4; i++) {
                        CollisionInfoNew collisionInfo = entity.Physics.ClipCollisionInfo[i];
                        int axis = Directions.ToAxis(i);

                        if (entity.Physics.CollisionInfo[i].IsColliding) {
                            Rectangle2F drawBox = collisionBox;
                            drawBox.ExtendEdge(i, 1);
                            drawBox.ExtendEdge(Directions.Reverse(i), -collisionBox.Size[axis]);
                            g.FillRectangle(drawBox, Color.Magenta);
                        }

                        if (collisionInfo.IsColliding && !collisionInfo.IsResolved) {
                            Rectangle2F drawBox = collisionBox;
                            float penetration = Math.Max(1.0f, GMath.Round(collisionInfo.PenetrationDistance));
                            if (i == Directions.Down || i == Directions.Right)
                                drawBox.Point[axis] += drawBox.Size[axis] - penetration;
                            drawBox.Size[axis] = penetration;

                            // Draw the strip of penetration.
                            Color penetrationColor = Color.Red;
                            if (entity.Physics.AllowEdgeClipping && collisionInfo.IsAllowedClipping)
                                penetrationColor = Color.Blue;
                            g.FillRectangle(drawBox, penetrationColor);

                        }
                        if (collisionInfo.IsColliding && collisionInfo.IsResolved) {
                            Rectangle2F drawBox2 = collisionBox;
                            drawBox2.ExtendEdge(i, 2);
                            drawBox2.ExtendEdge(Directions.Reverse(i), -collisionBox.Size[axis] - 1);
                            g.FillRectangle(drawBox2, Color.Maroon);
                        }
                    }
                }
                else if (entity.Physics.IsEnabled && entity.Physics.IsSolid) {
                    // Draw the hard collision box.
                    Rectangle2F collisionBox = entity.Physics.PositionedCollisionBox;
                    g.FillRectangle(collisionBox, Color.Olive);
                }
            }
        }