Esempio n. 1
0
 public void Move(Dungeon dung)
 {
     PlMove(dung, this);
 }
Esempio n. 2
0
        protected void Generation(Dungeon dung) // algorythm for the procedural generation
        {
            for (int i = 0; i < 50; i++)        // here is where the main dungeon "box" is made
            {
                for (int j = 0; j < 50; j++)
                {
                    if (i == 0 || i == 50 - 1)
                    {
                        _mapTiles[i, j] = SolidTiles.Wall;
                    }
                    else if (i != 0 && i != 50 - 1)
                    {
                        if (j != 0 && j != 50 - 1)
                        {
                            _mapTiles[i, j] = SolidTiles.Floor;
                        }
                        else
                        {
                            _mapTiles[i, j] = SolidTiles.Wall;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Error");
                    }
                    _mapcoordinates[i, j] = new XY();
                }
            }
            //x = _mapTiles.GetLength(0) / 2 - rand.Next(-5, 5);
            int[] horizontal  = new int[4]; // arrays for the
            int[] vertical    = new int[4]; // cut points
            int   arrayindex1 = 0;
            int   arrayindex2 = 0;

            horizontal[arrayindex1] = (_mapTiles.GetLength(0) / 2) - rand.Next(-2, 2); // creating first
            vertical[arrayindex2]   = (_mapTiles.GetLength(1) / 2) + rand.Next(-1, 1); // cut points

            for (int r = 0; r < 6; r++)                                                // now here is where room starts to show up
            {
                i = 1;
                if (isHorizontal) // checking if it should be the horizontal or vertical cut of the dungeon
                {
                    while (dung.CheckTile(horizontal[arrayindex1], i) != SolidTiles.Wall)
                    {
                        if (dung.GiveInteraction(horizontal[arrayindex1], i) != Interaction.ClosedDoor)
                        {
                            _mapTiles[horizontal[arrayindex1], i] = SolidTiles.Wall;
                            i++;
                        }
                    }
                    temp = rand.Next(5, i);
                    _mapTiles[horizontal[arrayindex1], temp] = SolidTiles.Floor;
                    _mapcoordinates[horizontal[arrayindex1], temp].AddInteraction(Interaction.ClosedDoor);
                    arrayindex1++;
                    horizontal[arrayindex1] = horizontal[arrayindex1 - 1] / 2;
                    isHorizontal            = false;
                }
                else if (!isHorizontal)
                {
                    while (dung.CheckTile(i, vertical[arrayindex2]) != SolidTiles.Wall)
                    {
                        if (dung.GiveInteraction(i, vertical[arrayindex2]) != Interaction.ClosedDoor)
                        {
                            _mapTiles[i, vertical[arrayindex2]] = SolidTiles.Wall;
                            i++;
                        }
                    }
                    temp = rand.Next(5, i);
                    _mapTiles[temp, vertical[arrayindex2]] = SolidTiles.Floor;
                    _mapcoordinates[temp, vertical[arrayindex2]].AddInteraction(Interaction.ClosedDoor);
                    arrayindex2++;
                    vertical[arrayindex2] = vertical[arrayindex2 - 1] / 2;
                    isHorizontal          = true;
                }
            }
            EnemyGen(dung.GetLevel());
            InteractionGen(dung.GetLevel());
            ItemGen();
        }
Esempio n. 3
0
 public void NextLvl(Dungeon dung, int x)
 {
     dung.SaveMap();
     dung.LoadMap(dung.GetLevel() + x);
 }