public Vector3 GetPlayerStartPosition(bool playingFromLeft)
        {
            int offset = _gridWidth / 4;
            PlayingFieldTile startTile = _tileGrid[playingFromLeft ? offset : _gridWidth - (offset + 1)][_gridDepth / 2];

            startTile.ObstructedBy = TileBlockers.PlayerStartPoint;

            return(startTile.Position);
        }
        private void Awake()
        {
            _tileList = new List <PlayingFieldTile>();

            Vector3 frontLeft = new Vector3(_tilePrefab.transform.localScale.x * (_gridWidth - 1), 0.0f, _tilePrefab.transform.localScale.z * (_gridDepth - 1)) * -0.5f;
            Vector3 step      = new Vector3(_tilePrefab.transform.localScale.x, 0.0f, _tilePrefab.transform.localScale.z);

            _tileGrid = new PlayingFieldTile[_gridWidth][];
            for (int x = 0; x < _gridWidth; x++)
            {
                _tileGrid[x] = new PlayingFieldTile[_gridDepth];
                for (int z = 0; z < _gridDepth; z++)
                {
                    GameObject tile = Instantiate(_tilePrefab);
                    tile.name = $"GroundTile {x}:{z}";

                    tile.transform.position = new Vector3(frontLeft.x + (step.x * x), 0.0f, frontLeft.z + (step.z * z));
                    tile.transform.parent   = transform;

                    _tileGrid[x][z]       = tile.GetComponent <PlayingFieldTile>();
                    _tileGrid[x][z].GridX = x;
                    _tileGrid[x][z].GridZ = z;
                    if ((x < 2) || (z == 0) || (x >= _gridWidth - 2) || (z == _gridDepth - 1))
                    {
                        _tileGrid[x][z].SetAsPathTile(Tile_Path_Colors[(x + z) % Tile_Path_Colors.Length]);
                    }
                    else
                    {
                        _tileGrid[x][z].SetHealthyColour(Tile_Healthy_Colors[(x + z) % Tile_Healthy_Colors.Length]);
                    }

                    _tileList.Add(_tileGrid[x][z]);
                }

                CreateWall(new Vector3(frontLeft.x + (step.x * x), 0.0f, frontLeft.z + (step.z * _gridDepth)), "North wall", x);
            }

            for (int z = 0; z < _gridDepth + 1; z++)
            {
                CreateWall(new Vector3(frontLeft.x + (step.x * -1), 0.0f, frontLeft.z + (step.z * z)), "West wall", z);
                CreateWall(new Vector3(frontLeft.x + (step.x * _gridWidth), 0.0f, frontLeft.z + (step.z * z)), "East wall", z);
            }

            CreateBarrier(_barrierPrefab, _tileGrid[0][0].Position + new Vector3(-1.0f, 0.0f, -1.5f), _tileGrid[0][_gridDepth - 1].Position + new Vector3(-1.0f, 0.0f, 1.5f));
            CreateBarrier(_barrierPrefab, _tileGrid[_gridWidth - 1][0].Position + new Vector3(1.0f, 0.0f, -1.5f), _tileGrid[_gridWidth - 1][_gridDepth - 1].Position + new Vector3(1.0f, 0.0f, 1.5f));
            CreateBarrier(_barrierPrefab, _tileGrid[0][0].Position + new Vector3(-0.5f, 0.0f, -1.0f), _tileGrid[_gridWidth - 1][0].Position + new Vector3(0.5f, 0.0f, -1.0f));
            CreateBarrier(_barrierPrefab, _tileGrid[0][_gridDepth - 1].Position + new Vector3(-0.5f, 0.0f, 1.0f), _tileGrid[_gridWidth - 1][_gridDepth - 1].Position + new Vector3(0.5f, 0.0f, 1.0f));
        }
        public PlayingFieldTile GetRandomClearPatch()
        {
            PlayingFieldTile center  = GetRandomTile(true);
            bool             isClear = true;

            if (center != null)
            {
                for (int x = center.GridX - 2; x < center.GridX + 3; x++)
                {
                    for (int z = center.GridZ - 2; z < center.GridZ + 3; z++)
                    {
                        if ((x >= 0) && (z >= 0) && (x < _gridWidth) && (z < _gridDepth))
                        {
                            isClear &= _tileGrid[x][z].ObstructedBy != TileBlockers.Plant;
                        }
                    }
                }
            }

            return(isClear ? center : null);
        }