예제 #1
0
        public override void Rasterize()
        {
            var wall = new DungeonTile {
                TileType = LabTemplate.Space,
                Object = new DungeonObject {
                    ObjectType = LabTemplate.LabWall
                }
            };

            int w = Rasterizer.Width, h = Rasterizer.Height;
            var buf = Rasterizer.Bitmap;
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++) {
                    if (buf[x, y].TileType != LabTemplate.Space || buf[x, y].Object != null)
                        continue;

                    bool isWall = false;
                    if (x == 0 || y == 0 || x + 1 == w || y + 1 == h)
                        isWall = false;
                    else {
                        for (int dx = -1; dx <= 1 && !isWall; dx++)
                            for (int dy = -1; dy <= 1 && !isWall; dy++) {
                                if (buf[x + dx, y + dy].TileType != LabTemplate.Space) {
                                    isWall = true;
                                    break;
                                }
                            }
                    }
                    if (isWall)
                        buf[x, y] = wall;
                }
        }
예제 #2
0
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            var tile = new DungeonTile {
                TileType = PirateCaveTemplate.LightSand
            };

            var cX = Pos.X + radius + 0.5;
            var cY = Pos.Y + radius + 0.5;
            var bounds = Bounds;
            var r2 = radius * radius;
            var buf = rasterizer.Bitmap;

            double pR = rand.NextDouble() * (radius - 2), pA = rand.NextDouble() * 2 * Math.PI;
            int pX = (int)(cX + Math.Cos(pR) * pR);
            int pY = (int)(cY + Math.Sin(pR) * pR);

            for (int x = bounds.X; x < bounds.MaxX; x++)
                for (int y = bounds.Y; y < bounds.MaxY; y++) {
                    if ((x - cX) * (x - cX) + (y - cY) * (y - cY) <= r2) {
                        buf[x, y] = tile;
                        if (rand.NextDouble() > 0.95) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = PirateCaveTemplate.PalmTree
                            };
                        }
                    }
                    if (x == pX && y == pY) {
                        buf[x, y].Region = "Spawn";
                        buf[x, y].Object = new DungeonObject {
                            ObjectType = PirateCaveTemplate.CowardicePortal
                        };
                    }
                }
        }
        public override void Rasterize()
        {
            var tile = new DungeonTile {
                TileType = PirateCaveTemplate.ShallowWater
            };

            Rasterizer.Clear(tile);
        }
 protected void Default(Point srcPos, Point dstPos, DungeonTile tile)
 {
     if (srcPos.X == dstPos.X) {
         if (srcPos.Y > dstPos.Y)
             Utils.Swap(ref srcPos, ref dstPos);
         Rasterizer.FillRect(new Rect(srcPos.X, srcPos.Y, srcPos.X + Graph.Template.CorridorWidth, dstPos.Y), tile);
     }
     else if (srcPos.Y == dstPos.Y) {
         if (srcPos.X > dstPos.X)
             Utils.Swap(ref srcPos, ref dstPos);
         Rasterizer.FillRect(new Rect(srcPos.X, srcPos.Y, dstPos.X, srcPos.Y + Graph.Template.CorridorWidth), tile);
     }
 }
        private void RenderWalls()
        {
            var wallA = new DungeonTile
            {
                TileType = AbyssTemplate.Space,
                Object = new DungeonObject
                {
                    ObjectType = AbyssTemplate.RedWall
                }
            };
            var wallB = new DungeonTile
            {
                TileType = AbyssTemplate.Space,
                Object = new DungeonObject
                {
                    ObjectType = AbyssTemplate.RedTorchWall
                }
            };

            var buf = Rasterizer.Bitmap;
            var tmp = (DungeonTile[,])buf.Clone();
            int w = Rasterizer.Width, h = Rasterizer.Height;

            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++)
                {
                    if (buf[x, y].TileType != AbyssTemplate.Space)
                        continue;

                    bool notWall = true;
                    if (x == 0 || y == 0 || x + 1 == w || y + 1 == h)
                        notWall = true;
                    else
                    {
                        for (int dx = -1; dx <= 1 && notWall; dx++)
                            for (int dy = -1; dy <= 1 && notWall; dy++)
                            {
                                if (tmp[x + dx, y + dy].TileType != AbyssTemplate.Space)
                                {
                                    notWall = false;
                                    break;
                                }
                            }
                    }
                    if (!notWall)
                        buf[x, y] = Rand.NextDouble() < 0.9 ? wallA : wallB;
                }
        }
예제 #6
0
        public override void Rasterize()
        {
            var wall = new DungeonTile {
                TileType = PirateCaveTemplate.Composite,
                Object = new DungeonObject {
                    ObjectType = PirateCaveTemplate.CaveWall
                }
            };
            var water = new DungeonTile {
                TileType = PirateCaveTemplate.ShallowWater
            };
            var space = new DungeonTile {
                TileType = PirateCaveTemplate.Space
            };

            int w = Rasterizer.Width, h = Rasterizer.Height;
            var buf = Rasterizer.Bitmap;
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++) {
                    if (buf[x, y].TileType != PirateCaveTemplate.ShallowWater)
                        continue;

                    bool notWall = false;
                    if (x == 0 || y == 0 || x + 1 == w || y + 1 == h)
                        notWall = false;
                    else if (buf[x + 1, y].TileType == PirateCaveTemplate.BrownLines ||
                             buf[x - 1, y].TileType == PirateCaveTemplate.BrownLines ||
                             buf[x, y + 1].TileType == PirateCaveTemplate.BrownLines ||
                             buf[x, y - 1].TileType == PirateCaveTemplate.BrownLines) {
                        notWall = true;
                    }
                    if (!notWall)
                        buf[x, y] = wall;
                }

            var tmp = (DungeonTile[,])buf.Clone();
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++) {
                    if (buf[x, y].TileType != PirateCaveTemplate.Composite)
                        continue;

                    bool nearWater = false;
                    if (x == 0 || y == 0 || x + 1 == w || y + 1 == h)
                        nearWater = false;
                    else if (tmp[x + 1, y].TileType == PirateCaveTemplate.ShallowWater ||
                             tmp[x - 1, y].TileType == PirateCaveTemplate.ShallowWater ||
                             tmp[x, y + 1].TileType == PirateCaveTemplate.ShallowWater ||
                             tmp[x, y - 1].TileType == PirateCaveTemplate.ShallowWater) {
                        nearWater = true;
                    }
                    if (nearWater && Rand.NextDouble() > 0.4)
                        buf[x, y] = water;
                }

            tmp = (DungeonTile[,])buf.Clone();
            for (int x = 0; x < w; x++)
                for (int y = 0; y < h; y++) {
                    if (buf[x, y].TileType != PirateCaveTemplate.Composite)
                        continue;

                    bool allWall = false;
                    if (x == 0 || y == 0 || x + 1 == w || y + 1 == h)
                        allWall = true;
                    else {
                        allWall = true;
                        for (int dx = -1; dx <= 1 && allWall; dx++)
                            for (int dy = -1; dy <= 1 && allWall; dy++) {
                                if (tmp[x + dx, y + dy].TileType != PirateCaveTemplate.Composite) {
                                    allWall = false;
                                    break;
                                }
                            }
                    }
                    if (allWall)
                        buf[x, y] = space;
                }
        }
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            rasterizer.Copy(LabTemplate.MapTemplate, current.Bounds, Pos);

            if ((current.Flags & RoomFlags.Evil) == 0)
                LabTemplate.CreateEnemies(rasterizer, Bounds, rand);

            var flags = current.Flags & RoomFlags.ConnectionMask;
            DungeonTile? tile = null;
            switch (flags) {
                case RoomFlags.Conn_Floor:
                    tile = new DungeonTile {
                        TileType = LabTemplate.LabFloor
                    };
                    break;

                case RoomFlags.Conn_Destructible:
                    tile = new DungeonTile {
                        TileType = LabTemplate.LabFloor,
                        Object = destWall
                    };
                    break;
                default:
                    return;
            }

            foreach (var edge in Edges) {
                var direction = edge.Linkage.Direction;
                if (edge.RoomA != this)
                    direction = direction.Reverse();

                Point a, b;
                switch (direction) {
                    case Direction.South:
                        a = new Point(edge.Linkage.Offset, Pos.Y + Height - 1);
                        b = new Point(a.X + 3, a.Y);
                        break;

                    case Direction.North:
                        a = new Point(edge.Linkage.Offset, Pos.Y);
                        b = new Point(a.X + 3, a.Y);
                        break;

                    case Direction.East:
                        a = new Point(Pos.X + Width - 1, edge.Linkage.Offset);
                        b = new Point(a.X, a.Y + 3);
                        break;

                    case Direction.West:
                        a = new Point(Pos.X, edge.Linkage.Offset);
                        b = new Point(a.X, a.Y + 3);
                        break;

                    default:
                        throw new ArgumentException();
                }
                rasterizer.DrawLine(a, b, tile.Value);
            }

            LabTemplate.DrawSpiderWeb(rasterizer, Bounds, rand);
        }
예제 #8
0
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            var tile = new DungeonTile {
                TileType = PirateCaveTemplate.BrownLines
            };

            var cX = Pos.X + radius + 0.5;
            var cY = Pos.Y + radius + 0.5;
            var bounds = Bounds;
            var r2 = radius * radius;
            var buf = rasterizer.Bitmap;

            for (int x = bounds.X; x < bounds.MaxX; x++)
                for (int y = bounds.Y; y < bounds.MaxY; y++) {
                    if ((x - cX) * (x - cX) + (y - cY) * (y - cY) <= r2)
                        buf[x, y] = tile;
                }

            int numKing = 1;
            int numBoss = new Range(4, 7).Random(rand);
            int numMinion = new Range(4, 7).Random(rand);

            r2 = (radius - 2) * (radius - 2);
            while (numKing > 0 || numBoss > 0 || numMinion > 0) {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);

                if ((x - cX) * (x - cX) + (y - cY) * (y - cY) > r2)
                    continue;

                if (buf[x, y].Object != null || buf[x, y].TileType != PirateCaveTemplate.BrownLines)
                    continue;

                switch (rand.Next(3)) {
                    case 0:
                        if (numKing > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = PirateCaveTemplate.PirateKing
                            };
                            numKing--;
                        }
                        break;
                    case 1:
                        if (numBoss > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = PirateCaveTemplate.Boss[rand.Next(PirateCaveTemplate.Boss.Length)]
                            };
                            numBoss--;
                        }
                        break;
                    case 2:
                        if (numMinion > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = PirateCaveTemplate.Minion[rand.Next(PirateCaveTemplate.Minion.Length)]
                            };
                            numMinion--;
                        }
                        break;
                }
            }
        }