Beispiel #1
0
        public void RenderSetPiece(World world, IntPoint pos)
        {
            for (var x = 0; x < Size; x++)
            {
                for (var y = 0; y < Size; y++)
                {
                    var dx = x - (Size / 2.0);
                    var dy = y - (Size / 2.0);
                    var r  = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2;
                    if (r <= 10)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                }
            }

            var lord = Entity.Resolve(0x675);

            lord.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(lord);

            var container = new Container(0x0501, null, false);
            var count     = rand.Next(5, 8);
            var items     = new List <Item>();

            while (items.Count < count)
            {
                var item = chest.GetRandomLoot(rand);
                if (item != null)
                {
                    items.Add(item);
                }
            }
            for (var i = 0; i < items.Count; i++)
            {
                container.Inventory[i] = items[i];
            }
            container.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(container);
        }
        public void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] p = new int[Size, Size];
            const double SCALE = 5.5;

            for (int x = 0; x < Size; x++)      //Lava
            {
                double t  = (double)x / Size * Math.PI;
                double x_ = t / Math.Sqrt(2) - Math.Sin(t) / (SCALE * Math.Sqrt(2));
                double y1 = t / Math.Sqrt(2) - 2 * Math.Sin(t) / (SCALE * Math.Sqrt(2));
                double y2 = t / Math.Sqrt(2) + Math.Sin(t) / (SCALE * Math.Sqrt(2));
                y1 /= Math.PI / Math.Sqrt(2);
                y2 /= Math.PI / Math.Sqrt(2);

                int y1_ = (int)Math.Ceiling(y1 * Size);
                int y2_ = (int)Math.Floor(y2 * Size);
                for (int i = y1_; i < y2_; i++)
                {
                    p[x, i] = 1;
                }
            }

            for (int x = 0; x < Size; x++)      //Floor
            {
                for (int y = 0; y < Size; y++)
                {
                    if (p[x, y] == 1 && rand.Next() % 5 == 0)
                    {
                        p[x, y] = 2;
                    }
                }
            }

            int r = rand.Next(0, 4);            //Rotation

            for (int i = 0; i < r; i++)
            {
                p = SetPieces.rotateCW(p);
            }
            p[20, 20] = 2;

            for (int x = 0; x < Size; x++)      //Rendering
            {
                for (int y = 0; y < Size; y++)
                {
                    if (p[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Lava; tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (p[x, y] == 2)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Lava; tile.ObjType = Floor;
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                }
            }

            Entity demon = Entity.Resolve(0x668);

            demon.Move(pos.X + 20.5f, pos.Y + 20.5f);
            world.EnterWorld(demon);

            Container   container = new Container(0x0501, null, false);
            int         count     = rand.Next(5, 8);
            List <Item> items     = new List <Item>();

            while (items.Count < count)
            {
                Item item = chest.GetRandomLoot(rand);
                if (item != null)
                {
                    items.Add(item);
                }
            }
            for (int i = 0; i < items.Count; i++)
            {
                container.Inventory[i] = items[i];
            }
            container.Move(pos.X + 20.5f, pos.Y + 20.5f);
            world.EnterWorld(container);
        }
Beispiel #3
0
        public void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[31, 40];

            for (int x = 0; x < 13; x++)    //Moats
            {
                for (int y = 0; y < 13; y++)
                {
                    if ((x == 0 && (y < 3 || y > 9)) ||
                        (y == 0 && (x < 3 || x > 9)) ||
                        (x == 12 && (y < 3 || y > 9)) ||
                        (y == 12 && (x < 3 || x > 9)))
                    {
                        continue;
                    }
                    t[x + 0, y + 0]  = t[x + 18, y + 0] = 2;
                    t[x + 0, y + 27] = t[x + 18, y + 27] = 2;
                }
            }
            for (int x = 3; x < 28; x++)
            {
                for (int y = 3; y < 37; y++)
                {
                    if (x < 6 || x > 24 || y < 6 || y > 33)
                    {
                        t[x, y] = 2;
                    }
                }
            }

            for (int x = 7; x < 24; x++)    //Floor
            {
                for (int y = 7; y < 33; y++)
                {
                    t[x, y] = rand.Next() % 3 == 0 ? 0 : 1;
                }
            }

            for (int x = 0; x < 7; x++)    //Perimeter
            {
                for (int y = 0; y < 7; y++)
                {
                    if ((x == 0 && y != 3) ||
                        (y == 0 && x != 3) ||
                        (x == 6 && y != 3) ||
                        (y == 6 && x != 3))
                    {
                        continue;
                    }
                    t[x + 3, y + 3]  = t[x + 21, y + 3] = 4;
                    t[x + 3, y + 30] = t[x + 21, y + 30] = 4;
                }
            }
            for (int x = 6; x < 25; x++)
            {
                t[x, 6] = t[x, 33] = 4;
            }
            for (int y = 6; y < 34; y++)
            {
                t[6, y] = t[24, y] = 4;
            }

            for (int x = 13; x < 18; x++)    //Bridge
            {
                for (int y = 3; y < 7; y++)
                {
                    t[x, y] = 6;
                }
            }

            for (int x = 0; x < 31; x++)    //Corruption
            {
                for (int y = 0; y < 40; y++)
                {
                    if (t[x, y] == 1 || t[x, y] == 0)
                    {
                        continue;
                    }
                    double p = rand.NextDouble();
                    if (t[x, y] == 6)
                    {
                        if (p < 0.4)
                        {
                            t[x, y] = 0;
                        }
                        continue;
                    }

                    if (p < 0.1)
                    {
                        t[x, y] = 1;
                    }
                    else if (p < 0.4)
                    {
                        t[x, y]++;
                    }
                }
            }

            //Boss & Chest
            t[15, 27] = 7;
            t[15, 20] = 8;

            int r = rand.Next(0, 4);

            for (int i = 0; i < r; i++)     //Rotation
            {
                t = SetPieces.rotateCW(t);
            }
            int w = t.GetLength(0), h = t.GetLength(1);

            for (int x = 0; x < w; x++)     //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 2)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = WaterA;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 3)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = WaterB;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 3;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 4)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = WallA;
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Floor;
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                        Entity wall = Entity.Resolve(WallB);
                        wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
                        world.EnterWorld(wall);
                    }
                    else if (t[x, y] == 6)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Bridge;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 7)
                    {
                        Container   container = new Container(0x0501, null, false);
                        int         count     = rand.Next(5, 8);
                        List <Item> items     = new List <Item>();
                        while (items.Count < count)
                        {
                            Item item = chest.GetRandomLoot(rand);
                            if (item != null)
                            {
                                items.Add(item);
                            }
                        }
                        for (int i = 0; i < items.Count; i++)
                        {
                            container.Inventory[i] = items[i];
                        }
                        container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f);
                        world.EnterWorld(container);
                    }
                    else if (t[x, y] == 8)
                    {
                        Entity cyclops = Entity.Resolve(0x67d);
                        cyclops.Move(pos.X + x, pos.Y + y);
                        world.EnterWorld(cyclops);
                    }
                }
            }
        }
Beispiel #4
0
        public void RenderSetPiece(World world, IntPoint pos)
        {
            int outerRadius  = 13;
            int waterRadius  = 10;
            int islandRadius = 3;
            var border       = new List <IntPoint>();

            var t = new int[Size, Size];

            for (int y = 0; y < Size; y++) //Outer
            {
                for (int x = 0; x < Size; x++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r  = Math.Sqrt(dx * dx + dy * dy);
                    if (r <= outerRadius)
                    {
                        t[x, y] = 1;
                    }
                }
            }

            for (int y = 0; y < Size; y++) //Water
            {
                for (int x = 0; x < Size; x++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r  = Math.Sqrt(dx * dx + dy * dy);
                    if (r <= waterRadius)
                    {
                        t[x, y] = 2;
                        if (waterRadius - r < 1)
                        {
                            border.Add(new IntPoint(x, y));
                        }
                    }
                }
            }

            for (int y = 0; y < Size; y++) //Island
            {
                for (int x = 0; x < Size; x++)
                {
                    double dx = x - (Size / 2.0);
                    double dy = y - (Size / 2.0);
                    double r  = Math.Sqrt(dx * dx + dy * dy);
                    if (r <= islandRadius)
                    {
                        t[x, y] = 1;
                        if (islandRadius - r < 1)
                        {
                            border.Add(new IntPoint(x, y));
                        }
                    }
                }
            }

            var trees = new HashSet <IntPoint>();

            while (trees.Count < border.Count * 0.5)
            {
                trees.Add(border[rand.Next(0, border.Count)]);
            }

            foreach (IntPoint i in trees)
            {
                t[i.X, i.Y] = 3;
            }

            for (int x = 0; x < Size; x++)
            {
                for (int y = 0; y < Size; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 2)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Water;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 3)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = Tree;
                        tile.Name    = "size:" + (rand.Next() % 2 == 0 ? 120 : 140);
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                }
            }

            Entity giant = Entity.Resolve(0x678);

            giant.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(giant);

            var container = new Container(0x0501, null, false);
            int count     = rand.Next(5, 8);
            var items     = new List <Item>();

            while (items.Count < count)
            {
                Item item = chest.GetRandomLoot(rand);
                if (item != null)
                {
                    items.Add(item);
                }
            }
            for (int i = 0; i < items.Count; i++)
            {
                container.Inventory[i] = items[i];
            }
            container.Move(pos.X + 15.5f, pos.Y + 15.5f);
            world.EnterWorld(container);
        }
Beispiel #5
0
        public void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[23, 35];

            for (int x = 0; x < 23; x++)    //Floor
            {
                for (int y = 0; y < 35; y++)
                {
                    t[x, y] = rand.Next() % 3 == 0 ? 0 : 1;
                }
            }

            for (int y = 0; y < 35; y++)    //Perimeters
            {
                t[0, y] = t[22, y] = 2;
            }
            for (int x = 0; x < 23; x++)
            {
                t[x, 0] = t[x, 34] = 2;
            }

            List <IntPoint> pts = new List <IntPoint>();

            for (int y = 0; y < 11; y++)    //Crosses
            {
                for (int x = 0; x < 7; x++)
                {
                    if (rand.Next() % 3 > 0)
                    {
                        t[2 + 3 * x, 2 + 3 * y] = 4;
                    }
                    else
                    {
                        pts.Add(new IntPoint(2 + 3 * x, 2 + 3 * y));
                    }
                }
            }

            for (int x = 0; x < 23; x++)    //Corruption
            {
                for (int y = 0; y < 35; y++)
                {
                    if (t[x, y] == 1 || t[x, y] == 0 || t[x, y] == 4)
                    {
                        continue;
                    }
                    double p = rand.NextDouble();
                    if (p < 0.1)
                    {
                        t[x, y] = 1;
                    }
                    else if (p < 0.4)
                    {
                        t[x, y]++;
                    }
                }
            }


            //Boss & Chest
            var pt = pts[rand.Next(0, pts.Count)];

            t[pt.X, pt.Y]     = 5;
            t[pt.X + 1, pt.Y] = 6;

            int r = rand.Next(0, 4);

            for (int i = 0; i < r; i++)     //Rotation
            {
                t = SetPieces.rotateCW(t);
            }
            int w = t.GetLength(0), h = t.GetLength(1);

            for (int x = 0; x < w; x++)     //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = 0;
                        world.Obstacles[x + pos.X, y + pos.Y] = 0;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 2)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = WallA;
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 3)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = Floor;
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                        Entity wall = Entity.Resolve(WallB);
                        wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
                        world.EnterWorld(wall);
                    }
                    else if (t[x, y] == 4)
                    {
                        var tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = Floor;
                        tile.ObjType = Cross;
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Obstacles[x + pos.X, y + pos.Y] = 2;
                        world.Map[x + pos.X, y + pos.Y]       = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        Container   container = new Container(0x0501, null, false);
                        int         count     = rand.Next(3, 8);
                        List <Item> items     = new List <Item>();
                        while (items.Count < count)
                        {
                            Item item = chest.GetRandomLoot(rand);
                            if (item != null)
                            {
                                items.Add(item);
                            }
                        }
                        for (int i = 0; i < items.Count; i++)
                        {
                            container.Inventory[i] = items[i];
                        }
                        container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f);
                        world.EnterWorld(container);
                    }
                    else if (t[x, y] == 6)
                    {
                        Entity mage = Entity.Resolve(0x0925);
                        mage.Move(pos.X + x, pos.Y + y);
                        world.EnterWorld(mage);
                    }
                }
            }


            //Boss & Chest
        }