Example #1
0
 public void Preview(Surface surface, SGraphics g)
 {
     g.DrawImage(Brush.Bitmap,
             surface.TileSet.TileSize * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X,
             surface.TileSet.TileSize * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y,
             Brush.Bitmap.Width * surface.Zoom,
             Brush.Bitmap.Height * surface.Zoom);
 }
Example #2
0
 public void Preview(Surface surface, SGraphics g)
 {
     g.DrawImage(Brush.Bitmap,
                 surface.TileSet.TileSize * surface.GetBrushLocation().X *surface.Zoom + surface.GetOffset().X,
                 surface.TileSet.TileSize * surface.GetBrushLocation().Y *surface.Zoom + surface.GetOffset().Y,
                 Brush.Bitmap.Width * surface.Zoom,
                 Brush.Bitmap.Height * surface.Zoom);
 }
Example #3
0
 public void Preview(Surface surface, SGraphics g)
 {
     g.DrawImage(brushTemplate.Bitmap,
                 surface.TileSetRenderer.TileSize * surface.GetBrushLocation().X *surface.Zoom + surface.GetOffset().X,
                 surface.TileSetRenderer.TileSize * surface.GetBrushLocation().Y *surface.Zoom + surface.GetOffset().Y,
                 brushTemplate.Bitmap.Width * surface.Zoom,
                 brushTemplate.Bitmap.Height * surface.Zoom);
 }
Example #4
0
 public void Preview(Surface surface, SGraphics g)
 {
     g.DrawImage(brushTemplate.Bitmap,
             surface.TileSetRenderer.TileSize * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X,
             surface.TileSetRenderer.TileSize * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y,
             brushTemplate.Bitmap.Width * surface.Zoom,
             brushTemplate.Bitmap.Height * surface.Zoom);
 }
Example #5
0
		public void Apply(Surface surface)
		{
			if (surface.Map.Actors.Value.Any(a => a.Value.Location() == surface.GetBrushLocation()))
				return;

			var owner = surface.NewActorOwner;
			var id = NextActorName(surface);
			surface.Map.Actors.Value[id] = new ActorReference(actorTemplate.Info.Name.ToLowerInvariant())
			{
				new LocationInit(surface.GetBrushLocation()),
				new OwnerInit(owner)
			};
		}
Example #6
0
		public void Apply(Surface surface)
		{
			var type = (byte)resourceTemplate.Info.ResourceType;
			var index = (byte)random.Next(resourceTemplate.Info.MaxDensity);
			surface.Map.MapResources.Value[surface.GetBrushLocation()] = new ResourceTile(type, index);

			var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
				surface.GetBrushLocation().Y / Surface.ChunkSize);

			if (surface.Chunks.ContainsKey(ch))
			{
				surface.Chunks[ch].Dispose();
				surface.Chunks.Remove(ch);
			}
		}
Example #7
0
        public void Apply(Surface surface)
        {
            // change the bits in the map
            var template = surface.TileSet.Templates[brushTemplate.N];
            var tile = surface.TileSetRenderer.Data(brushTemplate.N);
            var pos = surface.GetBrushLocation();

            if (surface.GetModifiers() == Keys.Shift)
            {
                FloodFillWithBrush(surface, pos);
                return;
            }

            for (var u = 0; u < template.Size.X; u++)
                for (var v = 0; v < template.Size.Y; v++)
                {
                    var cell = pos + new CVec(u, v);
                    if (surface.Map.Contains(cell))
                    {
                        var z = u + v * template.Size.X;
                        if (tile != null && tile[z].Length > 0)
                        {
                            var index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z;
                            surface.Map.MapTiles.Value[cell] = new TerrainTile(brushTemplate.N, index);
                        }

                        var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
                        if (surface.Chunks.ContainsKey(ch))
                        {
                            surface.Chunks[ch].Dispose();
                            surface.Chunks.Remove(ch);
                        }
                    }
                }
        }
Example #8
0
        public void Apply(Surface surface)
        {
            if (surface.Map.Actors.Value.Any(a => a.Value.Location() == surface.GetBrushLocation()))
            {
                return;
            }

            var owner = surface.NewActorOwner;
            var id    = NextActorName(surface);

            surface.Map.Actors.Value[id] = new ActorReference(Actor.Info.Name.ToLowerInvariant())
            {
                new LocationInit(surface.GetBrushLocation()),
                new OwnerInit(owner)
            };
        }
Example #9
0
        public void Preview(Surface surface, SGraphics g)
        {
            /* todo: include the player
                * in the brush so we can color new buildings too */

            surface.DrawActor(g, surface.GetBrushLocation(), Actor, null);
        }
Example #10
0
        public void Apply(Surface surface)
        {
            var type  = (byte)resourceTemplate.Info.ResourceType;
            var index = (byte)random.Next(resourceTemplate.Info.MaxDensity);

            surface.Map.MapResources.Value[surface.GetBrushLocation()] = new ResourceTile(type, index);

            var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
                              surface.GetBrushLocation().Y / Surface.ChunkSize);

            if (surface.Chunks.ContainsKey(ch))
            {
                surface.Chunks[ch].Dispose();
                surface.Chunks.Remove(ch);
            }
        }
Example #11
0
        public void Apply(Surface surface)
        {
            surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
                = new TileReference <byte, byte>
                {
                Type  = (byte)resourceTemplate.Info.ResourceType,
                Index = (byte)random.Next(resourceTemplate.Info.MaxDensity)
                };

            var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
                              surface.GetBrushLocation().Y / Surface.ChunkSize);

            if (surface.Chunks.ContainsKey(ch))
            {
                surface.Chunks[ch].Dispose();
                surface.Chunks.Remove(ch);
            }
        }
Example #12
0
        public void Apply(Surface surface)
        {
            surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
                = new TileReference <byte, byte>
                {
                type  = (byte)Resource.Info.ResourceType,
                index = (byte)random.Next(Resource.Info.SpriteNames.Length)
                };

            var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
                              (surface.GetBrushLocation().Y) / Surface.ChunkSize);

            if (surface.Chunks.ContainsKey(ch))
            {
                surface.Chunks[ch].Dispose();
                surface.Chunks.Remove(ch);
            }
        }
Example #13
0
        public void Apply(Surface surface)
        {
            surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
                = new TileReference<byte, byte>
                {
                    type = (byte)Resource.Info.ResourceType,
                    index = (byte)random.Next(Resource.Info.SpriteNames.Length)
                };

            var ch = new int2((surface.GetBrushLocation().X) / Surface.ChunkSize,
                (surface.GetBrushLocation().Y) / Surface.ChunkSize);

            if (surface.Chunks.ContainsKey(ch))
            {
                surface.Chunks[ch].Dispose();
                surface.Chunks.Remove(ch);
            }
        }
Example #14
0
        public void Apply(Surface surface)
        {
            surface.Map.MapResources.Value[surface.GetBrushLocation().X, surface.GetBrushLocation().Y]
                = new TileReference<byte, byte>
                {
                    Type = (byte)resourceTemplate.Info.ResourceType,
                    Index = (byte)random.Next(resourceTemplate.Info.MaxDensity)
                };

            var ch = new int2(surface.GetBrushLocation().X / Surface.ChunkSize,
                surface.GetBrushLocation().Y / Surface.ChunkSize);

            if (surface.Chunks.ContainsKey(ch))
            {
                surface.Chunks[ch].Dispose();
                surface.Chunks.Remove(ch);
            }
        }
Example #15
0
        public void Apply(Surface surface)
        {
            // change the bits in the map
            var template = surface.TileSet.Templates[brushTemplate.N];
            var tile     = surface.TileSetRenderer.Data(brushTemplate.N);
            var pos      = surface.GetBrushLocation();

            if (surface.GetModifiers() == Keys.Shift)
            {
                FloodFillWithBrush(surface, pos);
                return;
            }

            for (var u = 0; u < template.Size.X; u++)
            {
                for (var v = 0; v < template.Size.Y; v++)
                {
                    if (surface.Map.IsInMap(new CVec(u, v) + pos))
                    {
                        var z = u + v * template.Size.X;
                        if (tile[z].Length > 0)
                        {
                            surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
                                new TileReference <ushort, byte>
                            {
                                Type  = brushTemplate.N,
                                Index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z,
                            }
                        }
                        ;

                        var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
                        if (surface.Chunks.ContainsKey(ch))
                        {
                            surface.Chunks[ch].Dispose();
                            surface.Chunks.Remove(ch);
                        }
                    }
                }
            }
        }
Example #16
0
        public void Apply(Surface surface)
        {
            // change the bits in the map
            var template = surface.TileSet.Templates[brushTemplate.N];
            var tile     = surface.TileSetRenderer.Data(brushTemplate.N);
            var pos      = surface.GetBrushLocation();

            if (surface.GetModifiers() == Keys.Shift)
            {
                FloodFillWithBrush(surface, pos);
                return;
            }

            for (var u = 0; u < template.Size.X; u++)
            {
                for (var v = 0; v < template.Size.Y; v++)
                {
                    var cell = pos + new CVec(u, v);
                    if (surface.Map.Contains(cell))
                    {
                        var z = u + v * template.Size.X;
                        if (tile != null && tile[z].Length > 0)
                        {
                            var index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z;
                            surface.Map.MapTiles.Value[cell] = new TerrainTile(brushTemplate.N, index);
                        }

                        var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
                        if (surface.Chunks.ContainsKey(ch))
                        {
                            surface.Chunks[ch].Dispose();
                            surface.Chunks.Remove(ch);
                        }
                    }
                }
            }
        }
Example #17
0
        public void Apply(Surface surface)
        {
            // change the bits in the map
            var template = surface.TileSet.Templates[brushTemplate.N];
            var tile = surface.TileSetRenderer.Data(brushTemplate.N);
            var pos = surface.GetBrushLocation();

            if (surface.GetModifiers() == Keys.Shift)
            {
                FloodFillWithBrush(surface, pos);
                return;
            }

            for (var u = 0; u < template.Size.X; u++)
                for (var v = 0; v < template.Size.Y; v++)
                {
                    if (surface.Map.IsInMap(new CVec(u, v) + pos))
                    {
                        var z = u + v * template.Size.X;
                        if (tile[z].Length > 0)
                            surface.Map.MapTiles.Value[u + pos.X, v + pos.Y] =
                                new TileReference<ushort, byte>
                                {
                                    Type = brushTemplate.N,
                                    Index = template.PickAny ? (byte)((u + pos.X) % 4 + ((v + pos.Y) % 4) * 4) : (byte)z,
                                };

                        var ch = new int2((pos.X + u) / Surface.ChunkSize, (pos.Y + v) / Surface.ChunkSize);
                        if (surface.Chunks.ContainsKey(ch))
                        {
                            surface.Chunks[ch].Dispose();
                            surface.Chunks.Remove(ch);
                        }
                    }
                }
        }
Example #18
0
		public void Preview(Surface surface, SGraphics g)
		{
			surface.DrawActor(g, surface.GetBrushLocation(), actorTemplate,
				surface.GetPaletteForPlayer(surface.NewActorOwner));
		}
Example #19
0
 public void Preview(Surface surface, SGraphics g)
 {
     surface.DrawImage(g, Resource.Bitmap, surface.GetBrushLocation(), false, null);
 }
Example #20
0
 public void Preview(Surface surface, SGraphics g)
 {
     surface.DrawActor(g, surface.GetBrushLocation(), Actor,
                       surface.GetPaletteForPlayer(surface.NewActorOwner));
 }
Example #21
0
		public void Preview(Surface surface, SGraphics g)
		{
			surface.DrawImage(g, resourceTemplate.Bitmap, surface.GetBrushLocation(), false, null);
		}