Exemplo n.º 1
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int w = rand.Next(19, 22), h = rand.Next(19, 22);

            int[,] t = new int[w, h];
            for (int x = 0; x < w; x++) //Perimeter
            {
                t[x, 0]     = 1;
                t[x, h - 1] = 1;
            }
            for (int y = 0; y < h; y++)
            {
                t[0, y]     = 1;
                t[w - 1, y] = 1;
            }

            int midPtH = h / 2 + rand.Next(-2, 3); //Mid hori wall
            int sepH   = rand.Next(2, 4);

            if (rand.Next() % 2 == 0)
            {
                for (int x = sepH; x < w; x++)
                {
                    t[x, midPtH] = 1;
                }
            }
            else
            {
                for (int x = 0; x < w - sepH; x++)
                {
                    t[x, midPtH] = 1;
                }
            }

            int begin, end;

            if (rand.Next() % 2 == 0)
            {
                begin = 0;
                end   = midPtH;
            }
            else
            {
                begin = midPtH;
                end   = h;
            }

            int midPtV = w / 2 + rand.Next(-2, 3); //Mid vert wall
            int sepW   = rand.Next(2, 4);

            if (rand.Next() % 2 == 0)
            {
                for (int y = begin + sepW; y < end; y++)
                {
                    t[midPtV, y] = 1;
                }
            }
            else
            {
                for (int y = begin; y < end - sepW; y++)
                {
                    t[midPtV, y] = 1;
                }
            }
            for (int x = 0; x < w; x++) //Flooring
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 0)
                    {
                        t[x, y] = 2;
                    }
                }
            }

            for (int x = 0; x < w; x++) //Corruption
            {
                for (int y = 0; y < h; y++)
                {
                    if (rand.Next() % 2 == 0)
                    {
                        t[x, y] = 0;
                    }
                }
            }

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

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

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < w; x++) //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.ObjType = dat.IdToObjectType[Wall];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        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  = dat.IdToTileType[Floor];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override 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
            IntPoint 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);

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < w; x++) //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = 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  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[WallA];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        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 = dat.IdToTileType[Floor];
                        world.Map[x + pos.X, y + pos.Y] = tile;
                        Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]);
                        wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
                        world.EnterWorld(wall);
                    }
                    else if (t[x, y] == 4)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[Cross];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        Container container = new Container(world.Manager, 0x0501, null, false);
                        Item[]    items     = chest.GetLoots(world.Manager, 3, 8).ToArray();
                        for (int i = 0; i < items.Length; 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(world.Manager, "Deathmage");
                        mage.Move(pos.X + x, pos.Y + y);
                        world.EnterWorld(mage);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[Size, Size];
            int[,] o = new int[Size, Size];

            for (int x = 0; x < 60; x++) //Flooring
            {
                for (int y = 0; y < 60; y++)
                {
                    if (Math.Abs(x - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.9 &&
                        Math.Abs(y - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.9)
                    {
                        double dist =
                            Math.Sqrt(((x - Size / 2) * (x - Size / 2) + (y - Size / 2) * (y - Size / 2)) / ((Size / 2.0) * (Size / 2.0)));
                        t[x, y] = rand.NextDouble() < (1 - dist) * (1 - dist) ? 2 : 1;
                    }
                }
            }

            for (int x = 0; x < Size; x++) //Corruption
            {
                for (int y = 0; y < Size; y++)
                {
                    if (rand.Next() % 50 == 0)
                    {
                        t[x, y] = 0;
                    }
                }
            }

            const int bas = 16; //Walls

            for (int x = 0; x < 23; x++)
            {
                if (x > 9 && x < 13)
                {
                    continue;
                }

                o[bas + x, bas]     = 2;
                o[bas + x, bas + 1] = 2;

                o[bas + x, bas + 21] = 2;
                o[bas + x, bas + 22] = 2;
            }
            for (int y = 0; y < 23; y++)
            {
                if (y > 9 && y < 13)
                {
                    continue;
                }

                o[bas, bas + y]     = 2;
                o[bas + 1, bas + y] = 2;

                o[bas + 21, bas + y] = 2;
                o[bas + 22, bas + y] = 2;
            }
            o[bas - 1, bas + 7]       = o[bas - 1, bas + 8] = o[bas - 1, bas + 9] =
                o[bas - 1, bas + 13]  = o[bas - 1, bas + 14] = o[bas - 1, bas + 15] = 1;
            o[bas + 23, bas + 7]      = o[bas + 23, bas + 8] = o[bas + 23, bas + 9] =
                o[bas + 23, bas + 13] = o[bas + 23, bas + 14] = o[bas + 23, bas + 15] = 1;
            o[bas + 7, bas - 1]       = o[bas + 8, bas - 1] = o[bas + 9, bas - 1] =
                o[bas + 13, bas - 1]  = o[bas + 14, bas - 1] = o[bas + 15, bas - 1] = 1;
            o[bas + 7, bas + 23]      = o[bas + 8, bas + 23] = o[bas + 9, bas + 23] =
                o[bas + 13, bas + 23] = o[bas + 14, bas + 23] = o[bas + 15, bas + 23] = 1;


            for (int y = 0; y < 4; y++) //Columns
            {
                for (int x = 0; x < 4; x++)
                {
                    o[bas + 5 + x * 4, bas + 5 + y * 4] = 3;
                }
            }

            for (int x = 0; x < Size; x++) //Plants
            {
                for (int y = 0; y < Size; y++)
                {
                    if (((x > 5 && x < bas) || (x < Size - 5 && x > Size - bas) ||
                         (y > 5 && y < bas) || (y < Size - 5 && y > Size - bas)) &&
                        o[x, y] == 0 && t[x, y] == 1)
                    {
                        double r = rand.NextDouble();
                        if (r > 0.6) //0.4
                        {
                            o[x, y] = 4;
                        }
                        else if (r > 0.35) //0.25
                        {
                            o[x, y] = 5;
                        }
                        else if (r > 0.33) //0.02
                        {
                            o[x, y] = 6;
                        }
                    }
                }
            }

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

            for (int i = 0; i < rotation; i++)
            {
                t = SetPieces.rotateCW(t);
                o = SetPieces.rotateCW(o);
            }

            Render(this, world, pos, t, o);

            //Boss & Chest
            Container container = new Container(world.Manager, 0x0501, null, false);

            Item[] items = chest.GetLoots(world.Manager, 3, 8).ToArray();
            for (int i = 0; i < items.Length; i++)
            {
                container.Inventory[i] = items[i];
            }
            container.Move(pos.X + bas + 11.5f, pos.Y + bas + 11.5f);
            world.EnterWorld(container);

            Entity snake = Entity.Resolve(world.Manager, 0x0dc2);

            snake.Move(pos.X + bas + 11.5f, pos.Y + bas + 11.5f);
            world.EnterWorld(snake);
        }
Exemplo n.º 4
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[33, 33];

            for (int x = 0; x < 33; x++) //Grassing
            {
                for (int y = 0; y < 33; y++)
                {
                    if (Math.Abs(x - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95 &&
                        Math.Abs(y - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95)
                    {
                        t[x, y] = 1;
                    }
                }
            }

            for (int x = 12; x < 21; x++) //Outer
            {
                for (int y = 4; y < 29; y++)
                {
                    t[x, y] = 2;
                }
            }
            t = SetPieces.rotateCW(t);
            for (int x = 12; x < 21; x++)
            {
                for (int y = 4; y < 29; y++)
                {
                    t[x, y] = 2;
                }
            }

            for (int x = 13; x < 20; x++) //Inner
            {
                for (int y = 5; y < 28; y++)
                {
                    t[x, y] = 4;
                }
            }
            t = SetPieces.rotateCW(t);
            for (int x = 13; x < 20; x++)
            {
                for (int y = 5; y < 28; y++)
                {
                    t[x, y] = 4;
                }
            }

            for (int i = 0; i < 4; i++) //Ext
            {
                for (int x = 13; x < 20; x++)
                {
                    for (int y = 5; y < 7; y++)
                    {
                        t[x, y] = 3;
                    }
                }
                t = SetPieces.rotateCW(t);
            }

            for (int i = 0; i < 4; i++) //Pillars
            {
                t[13, 7]  = rand.Next() % 3 == 0 ? 6 : 5;
                t[19, 7]  = rand.Next() % 3 == 0 ? 6 : 5;
                t[13, 10] = rand.Next() % 3 == 0 ? 6 : 5;
                t[19, 10] = rand.Next() % 3 == 0 ? 6 : 5;
                t         = SetPieces.rotateCW(t);
            }

            Noise noise = new Noise(Environment.TickCount); //Perlin noise

            for (int x = 0; x < 33; x++)
            {
                for (int y = 0; y < 33; y++)
                {
                    if (noise.GetNoise(x / 33f * 8, y / 33f * 8, .5f) < 0.2)
                    {
                        t[x, y] = 0;
                    }
                }
            }

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < 33; x++) //Rendering
            {
                for (int y = 0; y < 33; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Grass];
                        tile.ObjType = 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  = dat.IdToTileType[TileDark];
                        tile.ObjType = 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  = dat.IdToTileType[Tile];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 4)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Stone];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Stone];
                        tile.ObjType = dat.IdToObjectType[PillarA];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 6)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Stone];
                        tile.ObjType = dat.IdToObjectType[PillarB];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
            }

            Entity skull = Entity.Resolve(world.Manager, "Skull Shrine"); //Skulls!

            skull.Move(pos.X + Size / 2f, pos.Y + Size / 2f);
            world.EnterWorld(skull);
        }
Exemplo n.º 5
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[25, 26];

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

            for (int y = 1; y < 24; y++) //Perimeters
            {
                t[2, y] = t[22, y] = 2;
            }
            for (int x = 2; x < 23; x++)
            {
                t[x, 23] = 2;
            }
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    t[x + 1, y] = t[x + 21, y] = 2;
                }
            }
            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    if ((x == 0 && y == 0) ||
                        (x == 0 && y == 4) ||
                        (x == 4 && y == 0) ||
                        (x == 4 && y == 4))
                    {
                        continue;
                    }
                    t[x, y + 21] = t[x + 20, y + 21] = 2;
                }
            }

            for (int y = 0; y < 6; y++) //Pillars
            {
                t[9, 4 + 3 * y] = t[15, 4 + 3 * y] = 4;
            }

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

            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);

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < w; x++) //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = 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  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[WallA];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        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 = dat.IdToTileType[Floor];
                        world.Map[x + pos.X, y + pos.Y] = tile;
                        Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]);
                        wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
                        world.EnterWorld(wall);
                    }
                    else if (t[x, y] == 4)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[PillarA];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[PillarB];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                }
            }

            //Boss
            Entity lich = Entity.Resolve(world.Manager, "Lich");

            lich.Move(pos.X + Size / 2, pos.Y + Size / 2);
            world.EnterWorld(lich);
        }
Exemplo n.º 6
0
        public override void RenderSetPiece(World world, IntPoint pos)
        {
            int[,] t = new int[27, 27];

            int[,] q = (int[, ])quarter.Clone();

            for (int y = 0; y < 14; y++) //Top left
            {
                for (int x = 0; x < 14; x++)
                {
                    t[x, y] = q[x, y];
                }
            }

            q = SetPieces.reflectHori(q); //Top right
            for (int y = 0; y < 14; y++)
            {
                for (int x = 0; x < 14; x++)
                {
                    t[13 + x, y] = q[x, y];
                }
            }

            q = SetPieces.reflectVert(q); //Bottom right
            for (int y = 0; y < 14; y++)
            {
                for (int x = 0; x < 14; x++)
                {
                    t[13 + x, 13 + y] = q[x, y];
                }
            }

            q = SetPieces.reflectHori(q); //Bottom left
            for (int y = 0; y < 14; y++)
            {
                for (int x = 0; x < 14; x++)
                {
                    t[x, 13 + y] = q[x, y];
                }
            }

            for (int y = 1; y < 4; y++) //Opening
            {
                for (int x = 8; x < 19; x++)
                {
                    t[x, y] = 2;
                }
            }
            t[12, 0] = t[13, 0] = t[14, 0] = 2;


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

            for (int i = 0; i < r; i++)
            {
                t = SetPieces.rotateCW(t);
            }

            t[13 + 6, 13] = 3;

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < 27; x++) //Rendering
            {
                for (int y = 0; y < 27; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[Wall];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        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  = dat.IdToTileType[Floor];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }

                    else if (t[x, y] == 3)
                    {
                        Entity cyclops = Entity.Resolve(world.Manager, 0x0928);
                        cyclops.Move(pos.X + x, pos.Y + y);
                        world.EnterWorld(cyclops);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override 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 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;

            EmbeddedData dat = world.Manager.GameData;

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


            Entity demon = Entity.Resolve(world.Manager, "Red Demon");

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

            Container container = new Container(world.Manager, 0x0501, null, false);

            Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray();
            for (int i = 0; i < items.Length; i++)
            {
                container.Inventory[i] = items[i];
            }
            container.Move(pos.X + 20.5f, pos.Y + 20.5f);
            world.EnterWorld(container);
        }
Exemplo n.º 8
0
        public override 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);

            EmbeddedData dat = world.Manager.GameData;

            for (int x = 0; x < w; x++) //Rendering
            {
                for (int y = 0; y < h; y++)
                {
                    if (t[x, y] == 1)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = 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  = dat.IdToTileType[WaterA];
                        tile.ObjType = 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  = dat.IdToTileType[WaterB];
                        tile.ObjType = 0;
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }

                    else if (t[x, y] == 4)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId  = dat.IdToTileType[Floor];
                        tile.ObjType = dat.IdToObjectType[WallA];
                        if (tile.ObjId == 0)
                        {
                            tile.ObjId = world.GetNextEntityId();
                        }
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 5)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = dat.IdToTileType[Floor];
                        world.Map[x + pos.X, y + pos.Y] = tile;
                        Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]);
                        wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
                        world.EnterWorld(wall);
                    }

                    else if (t[x, y] == 6)
                    {
                        WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
                        tile.TileId = dat.IdToTileType[Bridge];
                        world.Map[x + pos.X, y + pos.Y] = tile;
                    }
                    else if (t[x, y] == 7)
                    {
                        Container container = new Container(world.Manager, 0x0501, null, false);
                        Item[]    items     = chest.GetLoots(world.Manager, 5, 8).ToArray();
                        for (int i = 0; i < items.Length; 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(world.Manager, "Cyclops God");
                        cyclops.Move(pos.X + x, pos.Y + y);
                        world.EnterWorld(cyclops);
                    }
                }
            }
        }