示例#1
0
 Tile GetTile(Tile[,] tiles, Rect tilesArraySize, Vector2Int targetPosition)
 {
     if (BaseExtensions.IsPointBelongsSite(targetPosition, tilesArraySize))
     {
         return(tiles[targetPosition.x, targetPosition.y]);
     }
     return(null);
 }
示例#2
0
        Tile GetTileByPosition(Vector2Int position)
        {
            if (!BaseExtensions.IsPointBelongsSite(position, new Rect(Vector2Int.zero, boardSize)))
            {
                return(null);
            }

            return(Tiles[position.x, position.y]);
        }
示例#3
0
        Tile FindNext(Tile tile, Tile[,] tiles)
        {
            if (tile.IsNullOrDefault())
            {
                return(null);
            }
            var searchDirection = Vector2Int.up;
            var targetPosition  = tile.position + searchDirection;

            if (!BaseExtensions.IsPointBelongsSite(targetPosition, new Rect(Vector2Int.zero, new Vector2Int(tiles.GetLength(0), tiles.GetLength(1)))))
            {
                return(null);
            }
            var targetTile = tiles[targetPosition.x, targetPosition.y];

            if (targetTile.tileData.IsNullOrDefault() || targetTile.GetTileTypeSafe() == TileType.NONE)
            {
                targetTile = FindNext(targetTile, tiles);
            }
            return(targetTile);
        }