Exemple #1
0
        private Point HorizantalPivotAdder(Point headOfMainWay, int layer, List <Point> mainWayPoints)
        {
            int   lenght      = GetRndHorizontal(headOfMainWay, true);
            Point lastElement = mainWayPoints.Last <Point>();

            headOfMainWay = AddHorizantalPoint(lastElement, mainWayPoints, lenght);
            Pivot pivot = new Pivot(layer, headOfMainWay);

            pivot.direction = Direction.East;
            pivots.Add(pivot);
            return(headOfMainWay);
        }
Exemple #2
0
        private void AddNewWayWithDirection(Point point, List <Direction> directions, List <Point> falsePoints, int layer)
        {
            foreach (var item in directions)
            {
                Pivot pivot = null;
                switch (item)
                {
                case Direction.North:
                    int lenght = GetRndVertical(point, true, false);
                    if (lenght > 0 && lenght < mapLenght.Y)
                    {
                        Point tempPoint = AddVerticalPoint(point, falsePoints, lenght, true);
                        pivot = new Pivot(Direction.North, layer, tempPoint);
                    }
                    break;

                case Direction.South:
                    lenght = GetRndVertical(point, false, false);
                    if (lenght > 0 && lenght < mapLenght.Y)
                    {
                        Point tempPoint = AddVerticalPoint(point, falsePoints, lenght, false);
                        pivot = new Pivot(Direction.South, layer, tempPoint);
                    }
                    break;

                case Direction.East:
                    lenght = GetRndHorizontal(point, false);
                    if (lenght > 0 && lenght < mapLenght.Y)
                    {
                        Point tempPoint = AddHorizantalPoint(point, falsePoints, lenght);
                        pivot = new Pivot(Direction.East, layer, tempPoint);
                    }
                    break;

                case Direction.West:
                    break;

                default:
                    break;
                }
                if (pivot != null)
                {
                    pivots.Add(pivot);
                }
            }
        }
Exemple #3
0
        private List <Pivot> GetLastLayerPivots()
        {
            Pivot        lastPivot    = pivots.Last <Pivot>();
            int          lastestLayer = lastPivot.layerNo;
            List <Pivot> newPivots    = new List <Pivot>();

            for (int i = pivots.Count - 1; i > 0; i--)
            {
                if (pivots[i].layerNo == lastestLayer)
                {
                    newPivots.Add(pivots[i]);
                }
                else
                {
                    return(newPivots);
                }
            }
            return(newPivots);
        }
Exemple #4
0
        private Point VerticalPivotAdder(Point headOfMainWay, int layer, List <Point> mainWayPoints)
        {
            bool goUp = random.Next(2) == 1 ? true : false;  // get random boolean value

            int   lenght      = GetRndVertical(headOfMainWay, goUp, true);
            Point lastElement = mainWayPoints.Last <Point>();

            headOfMainWay = AddVerticalPoint(lastElement, mainWayPoints, lenght, goUp);
            Pivot pivot = new Pivot(layer, headOfMainWay);

            if (goUp)
            {
                pivot.direction = Direction.North;
            }
            else
            {
                pivot.direction = Direction.South;
            }
            pivots.Add(pivot);
            return(headOfMainWay);
        }