Beispiel #1
0
        public static Vector3 GetGuiPositionForHexVector(this HexVector hexVector, HexVector addedVector, Vector3 gridPosition)
        {
            var hexBase           = hexVector.Add(addedVector);
            var guiScreenPosition = Camera.main.WorldToScreenPoint(
                new Vector3(hexBase.GetPositionX(), hexBase.GetPositionY(), 0) + gridPosition);

            guiScreenPosition.y = Screen.height - guiScreenPosition.y;

            return(guiScreenPosition);
        }
Beispiel #2
0
        public static IEnumerable <Vector3> GetNeighbourLinePoints(this HexVector hex, IEnumerable <HexVector> neighboursNotInRegion)
        {
            var result   = new List <Vector3>();
            var vertices = GetVertices();

            var notInRegion = neighboursNotInRegion.NotNull();

            if (notInRegion.Contains(hex.Add(HexVector.UP)))
            {
                result.Add(vertices[0]);
                result.Add(vertices[1]);
            }
            if (notInRegion.Contains(hex.Add(HexVector.UP_RIGHT)))
            {
                result.Add(vertices[1]);
                result.Add(vertices[2]);
            }
            if (notInRegion.Contains(hex.Add(HexVector.DOWN_RIGHT)))
            {
                result.Add(vertices[2]);
                result.Add(vertices[3]);
            }
            if (notInRegion.Contains(hex.Add(HexVector.DOWN)))
            {
                result.Add(vertices[3]);
                result.Add(vertices[4]);
            }
            if (notInRegion.Contains(hex.Add(HexVector.DOWN_LEFT)))
            {
                result.Add(vertices[4]);
                result.Add(vertices[5]);
            }
            if (notInRegion.Contains(hex.Add(HexVector.UP_LEFT)))
            {
                result.Add(vertices[5]);
                result.Add(vertices[0]);
            }

            return(result.Select(v => v + new Vector3(hex.GetPositionX(), hex.GetPositionY(), 0)));
        }