예제 #1
0
        public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile {
                TileType = AbyssTemplate.RedSmallChecks
            });

            var buf    = rasterizer.Bitmap;
            var bounds = Bounds;

            bool portalPlaced = false;

            while (!portalPlaced)
            {
                int x = rand.Next(bounds.X + 2, bounds.MaxX - 4);
                int y = rand.Next(bounds.Y + 2, bounds.MaxY - 4);
                if (buf[x, y].Object != null)
                {
                    continue;
                }

                buf[x, y].Region = "Spawn";
                buf[x, y].Object = new DungeonObject {
                    ObjectType = AbyssTemplate.CowardicePortal
                };
                portalPos    = new Point(x, y);
                portalPlaced = true;
            }
        }
예제 #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
                        };
                    }
                }
        }
예제 #3
0
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            var buf = rasterizer.Bitmap;
            var bounds = Bounds;

            rasterizer.Copy(AbyssTemplate.MapTemplate, new Rect(10, 10, 52, 52), Pos, tile => tile.TileType.Name == "Space");

            int numCorrupt = new Range(2, 10).Random(rand);
            while (numCorrupt > 0) {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);

                if (buf[x, y].Object == null)
                    continue;
                if (buf[x, y].Object.ObjectType != AbyssTemplate.PartialRedFloor)
                    continue;

                buf[x, y].Object = null;
                numCorrupt--;
            }

            int numImp = new Range(1, 2).Random(rand);
            int numDemon = new Range(1, 3).Random(rand);
            int numBrute = new Range(1, 3).Random(rand);

            while (numImp > 0 || numDemon > 0 || numBrute > 0) {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);

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

                switch (rand.Next(3)) {
                    case 0:
                        if (numImp > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssImp
                            };
                            numImp--;
                        }
                        break;
                    case 1:
                        if (numDemon > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssDemon[rand.Next(AbyssTemplate.AbyssDemon.Length)]
                            };
                            numDemon--;
                        }
                        break;
                    case 2:
                        if (numBrute > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssBrute[rand.Next(AbyssTemplate.AbyssBrute.Length)]
                            };
                            numBrute--;
                        }
                        break;
                }
            }
        }
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile
            {
                TileType = AbyssTemplate.RedSmallChecks
            });

            var buf = rasterizer.Bitmap;
            var bounds = Bounds;

            bool portalPlaced = false;
            while (!portalPlaced)
            {
                int x = rand.Next(bounds.X + 2, bounds.MaxX - 4);
                int y = rand.Next(bounds.Y + 2, bounds.MaxY - 4);
                if (buf[x, y].Object != null)
                    continue;

                buf[x, y].Region = "Spawn";
                buf[x, y].Object = new DungeonObject
                {
                    ObjectType = AbyssTemplate.CowardicePortal
                };
                portalPos = new Point(x, y);
                portalPlaced = true;
            }
        }
        public static void Copy <TPixel>(this BitmapRasterizer <TPixel> self, TPixel[,] src, Rect srcRect, Point dst,
                                         Func <TPixel, bool> transprent = null)
            where TPixel : struct
        {
            int w   = srcRect.MaxX - srcRect.X;
            int h   = srcRect.MaxY - srcRect.Y;
            var buf = self.Bitmap;

            if (transprent == null)
            {
                transprent = pix => false;
            }

            for (int x = 0; x < w; x++)
            {
                for (int y = 0; y < h; y++)
                {
                    var pix = src[x + srcRect.X, y + srcRect.Y];
                    if (transprent(pix))
                    {
                        continue;
                    }
                    buf[x + dst.X, y + dst.Y] = src[x + srcRect.X, y + srcRect.Y];
                }
            }
        }
 public Rasterizer(int seed, DungeonGraph graph)
 {
     rand       = new Random(seed);
     this.graph = graph;
     rasterizer = new BitmapRasterizer <DungeonTile>(graph.Width, graph.Height);
     Step       = RasterizationStep.Initialize;
 }
 public Rasterizer(int seed, DungeonGraph graph)
 {
     rand = new Random(seed);
     this.graph = graph;
     rasterizer = new BitmapRasterizer<DungeonTile>(graph.Width, graph.Height);
     Step = RasterizationStep.Initialize;
 }
예제 #8
0
        public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile
            {
                TileType = PirateCaveTemplate.BrownLines
            });

            int numBoss   = new Range(0, 1).Random(rand);
            int numMinion = new Range(3, 5).Random(rand);
            int numPet    = new Range(0, 2).Random(rand);

            var buf    = rasterizer.Bitmap;
            var bounds = Bounds;

            while (numBoss > 0 || numMinion > 0 || numPet > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].Object != null)
                {
                    continue;
                }

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

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

                case 2:
                    if (numPet > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = PirateCaveTemplate.Pet[rand.Next(PirateCaveTemplate.Pet.Length)]
                        };
                        numPet--;
                    }
                    break;
                }
            }
        }
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile
            {
                TileType = PirateCaveTemplate.BrownLines
            });

            int numBoss = new Range(0, 1).Random(rand);
            int numMinion = new Range(3, 5).Random(rand);
            int numPet = new Range(0, 2).Random(rand);

            var buf = rasterizer.Bitmap;
            var bounds = Bounds;
            while (numBoss > 0 || numMinion > 0 || numPet > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].Object != null)
                    continue;

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

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

                    case 2:
                        if (numPet > 0)
                        {
                            buf[x, y].Object = new DungeonObject
                            {
                                ObjectType = PirateCaveTemplate.Pet[rand.Next(PirateCaveTemplate.Pet.Length)]
                            };
                            numPet--;
                        }
                        break;
                }
            }
        }
예제 #10
0
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile {
                TileType = AbyssTemplate.RedSmallChecks
            });

            int numImp = new Range(0, 2).Random(rand);
            int numDemon = new Range(2, 4).Random(rand);
            int numBrute = new Range(1, 4).Random(rand);
            int numSkull = new Range(1, 3).Random(rand);

            var buf = rasterizer.Bitmap;
            var bounds = Bounds;
            while (numImp > 0 || numDemon > 0 || numBrute > 0 || numSkull > 0) {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].Object != null)
                    continue;

                switch (rand.Next(4)) {
                    case 0:
                        if (numImp > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssImp
                            };
                            numImp--;
                        }
                        break;
                    case 1:
                        if (numDemon > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssDemon[rand.Next(AbyssTemplate.AbyssDemon.Length)]
                            };
                            numDemon--;
                        }
                        break;
                    case 2:
                        if (numBrute > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssBrute[rand.Next(AbyssTemplate.AbyssBrute.Length)]
                            };
                            numBrute--;
                        }
                        break;
                    case 3:
                        if (numSkull > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = AbyssTemplate.AbyssBones
                            };
                            numSkull--;
                        }
                        break;
                }
            }
        }
        public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
        {
            rasterizer.Copy(AbyssTemplate.MapTemplate, new Rect(70, 10, 85, 31), Pos, tile => tile.TileType.Name == "Space");

            var bounds = Bounds;
            var buf = rasterizer.Bitmap;
            for (int x = bounds.X; x < bounds.MaxX; x++)
                for (int y = bounds.Y; y < bounds.MaxY; y++) {
                    if (buf[x, y].TileType != AbyssTemplate.Space)
                        buf[x, y].Region = "Treasure";
                }
        }
예제 #12
0
        public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
        {
            rasterizer.Copy(AbyssTemplate.MapTemplate, new Rect(70, 10, 85, 31), Pos, tile => tile.TileType.Name == "Space");

            var bounds = Bounds;
            var buf    = rasterizer.Bitmap;

            for (int x = bounds.X; x < bounds.MaxX; x++)
            {
                for (int y = bounds.Y; y < bounds.MaxY; y++)
                {
                    if (buf[x, y].TileType != AbyssTemplate.Space)
                    {
                        buf[x, y].Region = "Treasure";
                    }
                }
            }
        }
예제 #13
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;
            var    pX = (int)(cX + Math.Cos(pR) * pR);
            var    pY = (int)(cY + Math.Sin(pR) * pR);

            for (var x = bounds.X; x < bounds.MaxX; x++)
            {
                for (var 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)
                    {
                        continue;
                    }
                    buf[x, y].Region = "Spawn";
                    buf[x, y].Object = new DungeonObject
                    {
                        ObjectType = PirateCaveTemplate.CowardicePortal
                    };
                }
            }
        }
예제 #14
0
        internal static void CreateEnemies(BitmapRasterizer <DungeonTile> rasterizer, Rect bounds, Random rand)
        {
            int numBig   = new Range(0, 3).Random(rand);
            int numSmall = new Range(4, 10).Random(rand);

            var buf = rasterizer.Bitmap;

            while (numBig > 0 || numSmall > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].TileType == Space || buf[x, y].Object != null)
                {
                    continue;
                }

                switch (rand.Next(2))
                {
                case 0:
                    if (numBig > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = Big[rand.Next(Big.Length)]
                        };
                        numBig--;
                    }
                    break;

                case 1:
                    if (numSmall > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = Small[rand.Next(Small.Length)]
                        };
                        numSmall--;
                    }
                    break;
                }
            }
        }
예제 #15
0
        internal static void DrawSpiderWeb(BitmapRasterizer <DungeonTile> rasterizer, Rect bounds, Random rand)
        {
            int w = rasterizer.Width, h = rasterizer.Height;
            var buf = rasterizer.Bitmap;

            for (int x = bounds.X; x < bounds.MaxX; x++)
            {
                for (int y = bounds.Y; y < bounds.MaxY; y++)
                {
                    if (buf[x, y].TileType == Space || buf[x, y].Object != null)
                    {
                        continue;
                    }

                    if (rand.NextDouble() > 0.99)
                    {
                        buf[x, y].Object = web;
                    }
                }
            }
        }
        internal static void CreateEnemies(BitmapRasterizer<DungeonTile> rasterizer, Rect bounds, Random rand)
        {
            int numBig = new Range(0, 3).Random(rand);
            int numSmall = new Range(4, 10).Random(rand);

            var buf = rasterizer.Bitmap;
            while (numBig > 0 || numSmall > 0) {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].TileType == Space || buf[x, y].Object != null)
                    continue;

                switch (rand.Next(2)) {
                    case 0:
                        if (numBig > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = Big[rand.Next(Big.Length)]
                            };
                            numBig--;
                        }
                        break;
                    case 1:
                        if (numSmall > 0) {
                            buf[x, y].Object = new DungeonObject {
                                ObjectType = Small[rand.Next(Small.Length)]
                            };
                            numSmall--;
                        }
                        break;
                }
            }
        }
예제 #17
0
 public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
 {
     rasterizer.Copy(LabTemplate.MapTemplate, template, Pos);
     LabTemplate.DrawSpiderWeb(rasterizer, Bounds, rand);
 }
예제 #18
0
        public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
        {
            rasterizer.FillRect(Bounds, new DungeonTile
            {
                TileType = AbyssTemplate.RedSmallChecks
            });


            int numImp   = new Range(0, 2).Random(rand);
            int numDemon = new Range(2, 4).Random(rand);
            int numBrute = new Range(1, 4).Random(rand);
            int numSkull = new Range(1, 3).Random(rand);

            var buf    = rasterizer.Bitmap;
            var bounds = Bounds;

            while (numImp > 0 || numDemon > 0 || numBrute > 0 || numSkull > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);
                if (buf[x, y].Object != null)
                {
                    continue;
                }

                switch (rand.Next(4))
                {
                case 0:
                    if (numImp > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = AbyssTemplate.AbyssImp
                        };
                        numImp--;
                    }
                    break;

                case 1:
                    if (numDemon > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = AbyssTemplate.AbyssDemon[rand.Next(AbyssTemplate.AbyssDemon.Length)]
                        };
                        numDemon--;
                    }
                    break;

                case 2:
                    if (numBrute > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = AbyssTemplate.AbyssBrute[rand.Next(AbyssTemplate.AbyssBrute.Length)]
                        };
                        numBrute--;
                    }
                    break;

                case 3:
                    if (numSkull > 0)
                    {
                        buf[x, y].Object = new DungeonObject
                        {
                            ObjectType = AbyssTemplate.AbyssBones
                        };
                        numSkull--;
                    }
                    break;
                }
            }
        }
예제 #19
0
 internal void Init(BitmapRasterizer <DungeonTile> rasterizer, DungeonGraph graph, Random rand)
 {
     Rasterizer = rasterizer;
     Graph      = graph;
     Rand       = rand;
 }
예제 #20
0
 public abstract void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand);
예제 #21
0
        public override void Rasterize(BitmapRasterizer <DungeonTile> rasterizer, Random rand)
        {
            var buf    = rasterizer.Bitmap;
            var bounds = Bounds;

            rasterizer.Copy(AbyssTemplate.MapTemplate, new Rect(10, 10, 52, 52), Pos, tile => tile.TileType.Name == "Space");

            int numCorrupt = new Range(2, 10).Random(rand);

            while (numCorrupt > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);

                if (buf[x, y].Object == null)
                {
                    continue;
                }
                if (buf[x, y].Object.ObjectType != AbyssTemplate.PartialRedFloor)
                {
                    continue;
                }

                buf[x, y].Object = null;
                numCorrupt--;
            }

            int numImp   = new Range(1, 2).Random(rand);
            int numDemon = new Range(1, 3).Random(rand);
            int numBrute = new Range(1, 3).Random(rand);

            while (numImp > 0 || numDemon > 0 || numBrute > 0)
            {
                int x = rand.Next(bounds.X, bounds.MaxX);
                int y = rand.Next(bounds.Y, bounds.MaxY);

                if (buf[x, y].Object != null || buf[x, y].TileType == AbyssTemplate.Space)
                {
                    continue;
                }

                switch (rand.Next(3))
                {
                case 0:
                    if (numImp > 0)
                    {
                        buf[x, y].Object = new DungeonObject {
                            ObjectType = AbyssTemplate.AbyssImp
                        };
                        numImp--;
                    }
                    break;

                case 1:
                    if (numDemon > 0)
                    {
                        buf[x, y].Object = new DungeonObject {
                            ObjectType = AbyssTemplate.AbyssDemon[rand.Next(AbyssTemplate.AbyssDemon.Length)]
                        };
                        numDemon--;
                    }
                    break;

                case 2:
                    if (numBrute > 0)
                    {
                        buf[x, y].Object = new DungeonObject {
                            ObjectType = AbyssTemplate.AbyssBrute[rand.Next(AbyssTemplate.AbyssBrute.Length)]
                        };
                        numBrute--;
                    }
                    break;
                }
            }
        }
 internal void Init(BitmapRasterizer<DungeonTile> rasterizer, DungeonGraph graph, Random rand)
 {
     Rasterizer = rasterizer;
     Graph = graph;
     Rand = rand;
 }
예제 #23
0
        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);
        }
예제 #24
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;
                }
            }
        }
        internal static void DrawSpiderWeb(BitmapRasterizer<DungeonTile> rasterizer, Rect bounds, Random rand)
        {
            int w = rasterizer.Width, h = rasterizer.Height;
            var buf = rasterizer.Bitmap;

            for (int x = bounds.X; x < bounds.MaxX; x++)
                for (int y = bounds.Y; y < bounds.MaxY; y++) {
                    if (buf[x, y].TileType == Space || buf[x, y].Object != null)
                        continue;

                    if (rand.NextDouble() > 0.99)
                        buf[x, y].Object = web;
                }
        }
예제 #26
0
        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);
        }
예제 #27
0
 public override void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand)
 {
     rasterizer.Copy(LabTemplate.MapTemplate, template, Pos);
     LabTemplate.DrawSpiderWeb(rasterizer, Bounds, rand);
 }
예제 #28
0
파일: BossRoom.cs 프로젝트: maximan20/CJ
        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;
                }
            }
        }
예제 #29
0
 public abstract void Rasterize(BitmapRasterizer<DungeonTile> rasterizer, Random rand);