Ejemplo n.º 1
0
        public List <Room> GenerateIo(List <Room> lr)
        {
            int maxIo = 4;

            for (int i = 0; i < lr.Count; i++)
            {
                var currentR          = lr[i];
                var currentnumberOfIo = this.randomManager.GetInt(maxIo - 1) + 1;
                var listOfCell        = Utilitaires.RectangleDelimitationCells(currentR.Setting);
                for (int j = 0; j < currentnumberOfIo; j++)
                {
                    var nextIo = listOfCell[this.randomManager.GetInt(listOfCell.Count)];
                    var cpt    = 10;
                    while (currentR.IOs.Any(x => Math.Abs((nextIo - x.Position).Length()) <= 1) || cpt == 0)
                    {
                        cpt--;
                        nextIo = listOfCell[this.randomManager.GetInt(listOfCell.Count)];
                    }

                    currentR.IOs.Add(new Exit()
                    {
                        Position = nextIo
                    });
                }
            }

            return(lr);
        }
Ejemplo n.º 2
0
 public void Utilitaires_WhenCallingRectangleDelimitationCells_CheckReturnsGoodValue(Rectangle input,
     List<Vector2> expected)
 {
     var result = Utilitaires.RectangleDelimitationCells(input);
     Assert.Equal(expected.Count, result.Count);
     foreach (var vectorExpected in expected)
     {
         Assert.Contains(vectorExpected, result);
     }
 }