Exemple #1
0
 public static void SpawnEnemy(GenData data, GenRoom room, bool corner = false)
 {
     if (corner)
     {
         var spawn = room
                     .GetAllTiles()
                     .Where(t => data.IsCornerG(t.PositionG.x, t.PositionG.y, GenDetail.DetailType.Wall, GenDetail.DetailType.Decoration))
                     .ToList().GetRandom();
         GenDetail item = new GenDetail()
         {
             Char = 'b', Type = GenDetail.DetailType.Entity, Entity = GenDetail.EntityType.Enemy
         };
         room.AddDetail(spawn.PositionG.x, spawn.PositionG.y, item);
     }
     else
     {
         var spawn = room
                     .GetAllTiles()
                     .Where(t => data.IsInsideRoom(t.PositionG.x, t.PositionG.y, room))
                     .ToList()
                     .GetRandom();
         GenDetail item = new GenDetail()
         {
             Char = 'b', Type = GenDetail.DetailType.Entity, Entity = GenDetail.EntityType.Enemy
         };
         room.AddDetail(spawn.PositionG.x, spawn.PositionG.y, item);
     }
 }
Exemple #2
0
    public IEnumerator CornerCheck()
    {
        GenData dat = new GenData(20, 15);

        GenRoom r1 = GenRoom.Sized(8, 8);

        r1.FillFloor('.');
        r1.SpacePriority = 2;
        dat.PlaceRoom(0, 0, r1);

        GenRoom r2 = GenRoom.Sized(10, 7);

        r2.FillFloor('.');
        r2.SpacePriority = 1;
        dat.PlaceRoom(5, 4, r2);

        dat.FixOverlap();
        dat.EdgeWalls('#');

        TestDrawer.text = dat.Print(false);
        yield return(new WaitForSeconds(0.5f));

        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 15; y++)
            {
                if (dat.IsCornerG(x, y))
                {
                    GenRoom corner = GenRoom.Sized(1, 1);
                    corner.FillFloor('X');
                    dat.PlaceRoom(x, y, corner);

                    TestDrawer.text = dat.Print(false);
                    yield return(new WaitForSeconds(0.25f));
                }
            }
        }
    }
Exemple #3
0
    public IEnumerator RunGenerationTest()
    {
        GenUtil.PrintCount = 0;
        GenData sym = new GenData(20, 15);

        GenRoom Hallway = GenRoom.Sized(15, 5);

        Hallway.FillFloor('.');
        Hallway.SpacePriority = 2;
        sym.PlaceRoom(1, 1, Hallway);

        TestDrawer.text = sym.Print(false);
        yield return(new WaitForSeconds(1f));


        GenRoom OtherRooom = GenRoom.Sized(8, 10);

        OtherRooom.FillFloor('.');
        OtherRooom.SpacePriority = 3;
        sym.PlaceRoom(11, 3, OtherRooom);

        TestDrawer.text = sym.Print(false);
        yield return(new WaitForSeconds(1f));

        sym.EdgeWalls('#');

        TestDrawer.text = sym.Print(false);
        yield return(new WaitForSeconds(1f));

        OtherRooom.SpacePriority = 1;
        sym.FixOverlap();

        TestDrawer.text = sym.Print(false);
        yield return(new WaitForSeconds(1f));



        int wantX = 3;
        int wantY = 2;

        bool done = false;

        while (!done)
        {
            var got = Hallway.GetAtWorldspaceG(wantX, wantY);

            if (!sym.IsInsideRoom(wantX, wantY))
            {
                done = true;
            }
            else
            {
                GenTile tile = GenTile.GetEmpty();
                tile.Details.Add(new GenDetail()
                {
                    Type = GenDetail.DetailType.Decoration, Char = 'O'
                });
                GenTile[,] feature = new GenTile[, ]
                {
                    { tile }
                };

                int fposX = wantX;
                int fposY = wantY;

                GenTile[,] final = GenUtil.GetSymetry(feature, ref fposX, ref fposY, Hallway, GenUtil.Axis.Vertical);

                Hallway.SetTilesAtG(fposX, fposY, final);

                TestDrawer.text = sym.Print(false);
                yield return(new WaitForSeconds(0.5f));


                wantX += 2;
            }
        }

        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 15; y++)
            {
                if (sym.IsCornerG(x, y, GenDetail.DetailType.Wall, GenDetail.DetailType.Decoration))
                {
                    GenRoom corner = GenRoom.Sized(1, 1);
                    corner.FillFloor('X');
                    sym.PlaceRoom(x, y, corner);

                    TestDrawer.text = sym.Print(false);
                    yield return(new WaitForSeconds(0.25f));
                }
            }
        }



        /*
         * GenData data = new GenData(40, 20);
         *
         * GenRoom startRoom = GenRoom.Sized(5,8,true);
         * startRoom.SpacePriority = 0;
         *
         * GenRoom room2 = GenRoom.Sized(8, 8, true);
         * room2.FillFloor('a');
         *
         * GenRoom room3 = GenRoom.Sized(5, 5, true);
         * room3.FillFloor('b');
         * room3.SpacePriority = 2;
         *
         * GenRoom room4 = GenRoom.Sized(10, 10, true);
         * room4.FillFloor('c');
         *
         * data.PlaceRoom(1, 0, startRoom);
         * data.PlaceRoom(4, 1, room2);
         * data.PlaceRoom(25, 11, room3);
         * data.PlaceRoom(23, 3, room4);
         *
         * data.FixOverlap();
         * data.EdgeWalls('#');
         *
         * data.Print(false);
         */
    }