示例#1
0
    public InfoOverlay(LogicalMap2D logicalMap)
    {
        _logicalMap = logicalMap ?? throw new ArgumentNullException(nameof(logicalMap));
        // 1 tile padding all around so we don't have to worry about edge conditions in the shader
        _tiles             = new byte[Width * Height];
        _logicalMap.Dirty += (sender, args) =>
        {
            if (args.Type != IconChangeType.Trigger)
            {
                return;
            }

            int index    = _logicalMap.Index(args.X, args.Y);
            var zone     = _logicalMap.GetZone(index);
            var triggers = zone?.Trigger ?? 0;
            _tiles[Index(args.X, args.Y)] = BuildTile(triggers);
            BufferDirty = true;
        };
        On <BeginFrameEvent>(_ => _flags = 0);
        On <CursorModeEvent>(e
                             => _flags |= e.Mode switch
        {
            CursorMode.Examine => InfoOverlayFlags.VerbExamine,
            CursorMode.Manipulate => InfoOverlayFlags.VerbManipulate,
            CursorMode.Talk => InfoOverlayFlags.VerbTalk,
            CursorMode.Take => InfoOverlayFlags.VerbTake,
            _ => 0
        });
示例#2
0
 public MapAnnotationLayer(LogicalMap2D logicalMap, Vector2 tileSize)
 {
     _logicalMap        = logicalMap ?? throw new ArgumentNullException(nameof(logicalMap));
     _tileSize          = tileSize;
     _logicalMap.Dirty += (sender, args) => _dirty.Add((args.X, args.Y));
     // _drawLayer = DrawLayer.Diagnostic;
     On <RenderEvent>(e => Render());
 }
示例#3
0
 public IMapLayer CreateMapLayer(
     LogicalMap2D logicalMap,
     ITexture tileset,
     Func <int, TileData> getTileFunc,
     DrawLayer layer,
     IconChangeType iconChangeType)
 {
     return(new MapLayer(logicalMap, tileset, getTileFunc, layer, iconChangeType));
 }
示例#4
0
    public MapRenderable2D(LogicalMap2D logicalMap, ITexture tileset, IGameFactory factory)
    {
        if (tileset == null)
        {
            throw new ArgumentNullException(nameof(tileset));
        }
        if (factory == null)
        {
            throw new ArgumentNullException(nameof(factory));
        }
        _logicalMap = logicalMap ?? throw new ArgumentNullException(nameof(logicalMap));
        var subImage = tileset.Regions[0];

        TileSize = subImage.Size;

        _underlay = AttachChild(factory.CreateMapLayer(
                                    logicalMap,
                                    tileset,
                                    logicalMap.GetUnderlay,
                                    DrawLayer.Underlay,
                                    IconChangeType.Underlay));

        _overlay = AttachChild(factory.CreateMapLayer(logicalMap,
                                                      tileset,
                                                      logicalMap.GetOverlay,
                                                      DrawLayer.Overlay,
                                                      IconChangeType.Overlay));

        _info = AttachChild(new InfoOverlay(logicalMap));

        var tileSize = tileset.Regions[0].Size;

        _annotations = AttachChild(new MapAnnotationLayer(logicalMap, tileSize));

        On <ToggleUnderlayEvent>(e => _underlay.IsActive = !_underlay.IsActive);
        On <ToggleOverlayEvent>(e => _overlay.IsActive   = !_overlay.IsActive);
    }
示例#5
0
 public IMapLayer CreateMapLayer(LogicalMap2D logicalMap, ITexture tileset, Func <int, TileData> getTileFunc, DrawLayer layer,
                                 IconChangeType iconChangeType)
 {
     throw new NotImplementedException();
 }
示例#6
0
 public Collider2D(LogicalMap2D logicalMap, bool isLargeMap)
 {
     _logicalMap = logicalMap ?? throw new ArgumentNullException(nameof(logicalMap));
     _isLargeMap = isLargeMap;
 }