예제 #1
0
 public void Clear(PlatformContext context, Vector2 world)
 {
     if (context.IsInBounds(world))
     {
         this.ClearImpl(context, world);
     }
 }
예제 #2
0
 public void Stamp(PlatformContext context, Vector2 world)
 {
     if (context.IsInBounds(world))
     {
         this.StampImpl(context, world);
     }
 }
예제 #3
0
        public override void DrawDebug(PlatformContext context, Vector2 world, Renderer renderer, FontTemplate font, Vector2 position)
        {
            var s = new StringBuilder();

            s.AppendLine($"Current tile : ");
            s.AppendLine($"{this.layer} ");
            font.DrawString(renderer.Screen, position, s.ToString(), Color.White);
            var size = font.Font.MeasureString(s.ToString());

            this.Current.Draw(renderer.Screen, new Vector2(size.X + position.X, position.Y), new Vector2(2f, 2f), Color.White, context.BlockStore);

            if (context.IsInBounds(world))
            {
                var tilePos     = context.WorldToTile(world);
                var tileTopLeft = context.TileToWorld(tilePos);
                this.Current.Draw(renderer.World, tileTopLeft, Vector2.One, Color.White, context.BlockStore);
                renderer.World.DrawRectangle(tileTopLeft, new Size2(context.BlockStore.TileSize, context.BlockStore.TileSize), Color.White);

                var tileText = new StringBuilder();
                var cell     = context.Map[tilePos];
                var flags    = context.GetFlags(tilePos);
                tileText.AppendLine($"   Position: {tilePos}");
                tileText.AppendLine($" Foreground: " + string.Join(",", cell.Foreground.Select(t => t.DebugString)));
                tileText.AppendLine($" Background: " + string.Join(",", cell.Background.Select(t => t.DebugString)));
                tileText.AppendLine($"      Block: " + (cell.Block == null ? "null" : cell.Block.DebugString));
                tileText.AppendLine($"      Flags: " + flags);
                font.DrawString(renderer.Screen, new Vector2(position.X, position.Y + 200), tileText.ToString(), Color.Wheat);
            }
        }
예제 #4
0
        public Entity ContextMenu(PlatformContext context, Vector2 world)
        {
            if (!context.IsInBounds(world))
            {
                return(null);
            }
            var contextMenu = new Panel(new Vector2(900, 1000));

            contextMenu.ClearChildren();
            this.ContextMenuImpl(contextMenu, context, world);
            return(contextMenu);
        }
예제 #5
0
        public override void DrawDebug(PlatformContext context, Vector2 world, Renderer renderer, FontTemplate font, Vector2 position)
        {
            if (context.IsInBounds(world))
            {
                var tilePos     = context.WorldToTile(world);
                var tileTopLeft = context.TileToWorld(tilePos);
                Light.DrawDebug(renderer, world, this.Current.Colour);
                renderer.World.DrawRectangle(tileTopLeft, new Size2(context.BlockStore.TileSize, context.BlockStore.TileSize), new Color(1f, 1f, 1f, 0.5f));

                var tileText = new StringBuilder();
                tileText.AppendLine($"   Position: {world} ({tilePos})");
                font.DrawString(renderer.Screen, new Vector2(position.X, position.Y + 200), tileText.ToString(), Color.Wheat);
            }
        }
예제 #6
0
        private static bool FloodFillValid(PlatformContext context, Point location, TilePlacement placement)
        {
            if (!context.IsInBounds(location))
            {
                return(false);
            }
            var cell = context.Map[location];

            switch (placement.Layer)
            {
            case TileStencil.Layer.Background:
                return(!cell.Background.Any());

            case TileStencil.Layer.Foreground:
                return(!cell.Foreground.Any());

            case TileStencil.Layer.Blocking:
                return(cell.Block == null);
            }
            return(true);
        }