Esempio n. 1
0
        public static List <Hexagon> GetHexagonesByGridPoint(GridPoint gridPoint)
        {
            var hexfields = Instance.Hexagones;

            List <Hexagon> matchedHex = new List <Hexagon>();

            for (int rowIndex = 0; rowIndex < hexfields.Length; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < hexfields[rowIndex].GetLength(0); columnIndex++)
                {
                    var currentHexagon = hexfields[rowIndex][columnIndex];
                    for (int pointIndex = 0; pointIndex < currentHexagon.Points.Count; pointIndex++)
                    {
                        if (GetGridPointByHexagonPositionAndPoint(hexfields[rowIndex][columnIndex].Position, new HexagonPoint(pointIndex)).Equals(gridPoint))
                        {
                            matchedHex.Add(currentHexagon);
                        }
                    }
                }
            }
            return(matchedHex);
        }
Esempio n. 2
0
        public static List <HexagonPositionHexagonPoint> GetHexagonAndHexagonPointByGridPoint(GridPoint gridPoint)
        {
            List <HexagonPositionHexagonPoint> hexPositionHexagonPoint = new List <HexagonPositionHexagonPoint>();

            foreach (var hexagonEdge in GetHexagonEdgesByGridPoint(Instance.HexagonesList, gridPoint))
            {
                GridPoint _gridPoint;

                _gridPoint = GetGridPointByHexagonPositionAndPoint(hexagonEdge.HexagonPosition, hexagonEdge.HexagonEdge.PointA);
                if (_gridPoint.Equals(gridPoint))
                {
                    hexPositionHexagonPoint.Add(new LogicLayer.HexagonPositionHexagonPoint(hexagonEdge.HexagonPosition, hexagonEdge.HexagonEdge.PointA));
                }

                _gridPoint = GetGridPointByHexagonPositionAndPoint(hexagonEdge.HexagonPosition, hexagonEdge.HexagonEdge.PointB);
                if (_gridPoint.Equals(gridPoint))
                {
                    hexPositionHexagonPoint.Add(new LogicLayer.HexagonPositionHexagonPoint(hexagonEdge.HexagonPosition, hexagonEdge.HexagonEdge.PointB));
                }
            }
            return(hexPositionHexagonPoint);
        }
Esempio n. 3
0
 public static bool IsGridPointOnHexagonEdge(HexagonPosition hexagonPosition, HexagonEdge hexagonEdge, GridPoint gridPoint)
 {
     return(HexagonGrid.GetGridPointByHexagonPositionAndPoint(hexagonPosition, hexagonEdge.PointA).Equals(gridPoint) ||
            HexagonGrid.GetGridPointByHexagonPositionAndPoint(hexagonPosition, hexagonEdge.PointB).Equals(gridPoint));
 }
Esempio n. 4
0
        public static List <HexagonPositionHexagonEdge> GetHexagonEdgesByGridPoint(List <Hexagon> hexagones, GridPoint gridPoint)
        {
            List <HexagonPositionHexagonEdge> hexFieldEdge = new List <HexagonPositionHexagonEdge>();

            foreach (Hexagon currentHex in hexagones)
            {
                foreach (HexagonEdge currentEdge in currentHex.Edges)
                {
                    if (IsGridPointOnHexagonEdge(currentHex.Position, currentEdge, gridPoint))
                    {
                        hexFieldEdge.Add(new HexagonPositionHexagonEdge(currentHex.Position, currentEdge));
                    }
                }
            }
            return(hexFieldEdge.ToList());
        }
Esempio n. 5
0
 public bool Equals(GridPoint gridPoint)
 {
     return((this.ColumnIndex == gridPoint.ColumnIndex) && (this.RowIndex == gridPoint.RowIndex));
 }