コード例 #1
0
        public static enum_TileDirection AngleNextEdge(this enum_TileDirection direction, bool clockWise)
        {
            if (!direction.IsAngle())
            {
                Debug.LogError("Invalid Directions Here!");
                return(enum_TileDirection.Invalid);
            }
            switch (direction)
            {
            default:
                Debug.LogError("Invalid Convertions Here!");
                return(enum_TileDirection.Invalid);

            case enum_TileDirection.TopRight:
                return(clockWise ? enum_TileDirection.Right : enum_TileDirection.Top);

            case enum_TileDirection.BottomRight:
                return(clockWise ? enum_TileDirection.Bottom : enum_TileDirection.Right);

            case enum_TileDirection.BottomLeft:
                return(clockWise ? enum_TileDirection.Left : enum_TileDirection.Bottom);

            case enum_TileDirection.TopLeft:
                return(clockWise ? enum_TileDirection.Top : enum_TileDirection.Left);
            }
        }
コード例 #2
0
        public static enum_TileDirection Inverse(this enum_TileDirection direction)
        {
            switch (direction)
            {
            default:
                Debug.LogError("Error Direction Here");
                return(enum_TileDirection.Invalid);

            case enum_TileDirection.Top:
                return(enum_TileDirection.Bottom);

            case enum_TileDirection.Bottom:
                return(enum_TileDirection.Top);

            case enum_TileDirection.Right:
                return(enum_TileDirection.Left);

            case enum_TileDirection.Left:
                return(enum_TileDirection.Right);

            case enum_TileDirection.TopRight:
                return(enum_TileDirection.BottomLeft);

            case enum_TileDirection.BottomLeft:
                return(enum_TileDirection.TopRight);

            case enum_TileDirection.TopLeft:
                return(enum_TileDirection.BottomRight);

            case enum_TileDirection.BottomRight:
                return(enum_TileDirection.TopLeft);
            }
        }
コード例 #3
0
 public static enum_TileDirection Next(this enum_TileDirection direction)
 {
     direction++;
     if (direction > enum_TileDirection.Left)
     {
         direction = enum_TileDirection.Top;
     }
     else if (direction > enum_TileDirection.TopLeft)
     {
         direction = enum_TileDirection.TopRight;
     }
     return(direction);
 }
コード例 #4
0
        public static T TileEdgeRandom <T>(this T[,] tileArray, System.Random randomSeed = null, Predicate <T> predicate = null, List <enum_TileDirection> edgeOutcluded = null, int predicateTryCount = -1) where T : class, ITileAxis        //Target Edges Random Tile
        {
            if (edgeOutcluded != null && edgeOutcluded.Count > 3)
            {
                Debug.LogError("Can't Outclude All Edges!");
            }

            if (predicateTryCount == -1)
            {
                predicateTryCount = int.MaxValue;
            }

            List <enum_TileDirection> edgesRandom = new List <enum_TileDirection>(m_EdgeDirections)
            {
            };

            if (edgeOutcluded != null)
            {
                edgesRandom.RemoveAll(p => edgeOutcluded.Contains(p));
            }

            int axisX = -1, axisY = -1;
            int tileWidth = tileArray.GetLength(0), tileHeight = tileArray.GetLength(1);
            T   targetTile = null;

            for (int i = 0; i < predicateTryCount; i++)
            {
                enum_TileDirection randomDirection = edgesRandom.RandomItem(randomSeed);
                switch (randomDirection)
                {
                case enum_TileDirection.Bottom:
                    axisX = randomSeed.Next(tileWidth - 1) + 1;
                    axisY = 0;
                    break;

                case enum_TileDirection.Top:
                    axisX = randomSeed.Next(tileWidth - 1);
                    axisY = tileHeight - 1;
                    break;

                case enum_TileDirection.Left:
                    axisX = 0;
                    axisY = randomSeed.Next(tileHeight - 1);
                    break;

                case enum_TileDirection.Right:
                    axisX = tileWidth - 1;
                    axisY = randomSeed.Next(tileHeight - 1) + 1;
                    break;
                }
                targetTile = tileArray[axisX, axisY];
                if (predicate == null || predicate(targetTile))
                {
                    if (edgeOutcluded != null)
                    {
                        edgeOutcluded.Add(randomDirection);
                    }
                    break;
                }
            }
            return(targetTile);
        }
コード例 #5
0
 public static TileAxis DirectionAxis(this TileAxis sourceAxis, enum_TileDirection direction) => sourceAxis + m_DirectionAxies[direction];
コード例 #6
0
 public static bool IsAngle(this enum_TileDirection direction) => m_AngleDirections.Contains(direction);
コード例 #7
0
 public static bool IsEdge(this enum_TileDirection direction) => m_EdgeDirections.Contains(direction);
コード例 #8
0
 public static Quaternion ToRotation(this enum_TileDirection direction) => Quaternion.Euler(0, (int)direction * 90, 0);
コード例 #9
0
 public static TileAxis GetDirectionedSize(TileAxis size, enum_TileDirection direction) => (int)direction % 2 == 0 ? size : size.Inverse();