コード例 #1
0
        public static List <T> TileRandomFill <T>(this T[,] tileArray, System.Random seed, TileAxis originAxis, Action <T> OnEachFill, Predicate <T> availableAxis, int fillCount) where T : class, ITileAxis
        {
            List <T> targetList = new List <T>();
            T        targetAdd  = tileArray.Get(originAxis);

            OnEachFill(targetAdd);
            targetList.Add(targetAdd);
            for (int i = 0; i < fillCount; i++)
            {
                T temp = targetList[i];
                m_EdgeDirections.TraversalRandomBreak((enum_TileDirection randomDirection) => {
                    TileAxis axis = temp.m_Axis.DirectionAxis(randomDirection);
                    if (axis.InRange(tileArray))
                    {
                        targetAdd = tileArray.Get(axis);
                        if (availableAxis(targetAdd))
                        {
                            OnEachFill(targetAdd);
                            targetList.Add(targetAdd);
                            return(true);
                        }
                    }
                    return(false);
                }, seed);
            }
            return(targetList);
        }
コード例 #2
0
 public static bool ArrayNearbyContains <T>(this T[,] tileArray, TileAxis origin, Predicate <T> predicate) where T : class, ITileAxis
 {
     TileAxis[] nearbyTiles = origin.nearbyFourTiles;
     for (int i = 0; i < nearbyTiles.Length; i++)
     {
         if (origin.InRange(tileArray) && !predicate(tileArray.Get(nearbyTiles[i])))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
 public static T Get <T>(this T[,] tileArray, TileAxis axis) where T : class => axis.InRange(tileArray) ? tileArray[axis.X, axis.Y] : null;