Sorting an Array of Arrays for game Object

The purpose of the code is to check the spawn point of the unit being spawned, and if there is a game object there, to not spawn an object, but I have hit massive amounts of hurdles in what should have been a simple task. The new error here is that my multidimensional array is being temperamental

I have used Nested for-loops in an attempt to sort through a 2D array, but they keep giving me an error saying a nested loop initializer was expected, thing is when I switch out “[,]” for “”, I can no longer use the transform.position methods, so i need that “[,]” initializer, my code is included below, i will be most gratefully if you can repair this error and finally put an end to a code I’ve worked on for much to long

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using Random = UnityEngine.Random;

public class Mspawn : MonoBehaviour {
public Button button;
public BoardManager boardManger;

public Vector3 Coordinate;

void OnEnable(){
	
	if (Input.GetMouseButtonDown(0)) {
		button.onClick.AddListener (SpawnUnit);
	}
}

void Awake(){
	boardManger = GetComponent<BoardManager> ();
	
}
void SpawnUnit()
{
	Coordinate = randomSpawnPosition ();
	for (int i = 0; i < boardManger.PlayerUnits.Length; i++) 
	{
		
		if (boardManger.PlayerUnits*.CompareTag("PlayerSoldierMarksman"))*
  •   	{*
    
  •   		if (checkposition(Coordinate) == false)*
    
  •   		{*
    

_ Instantiate (boardManger.PlayerUnits*, new Vector3 (Coordinate.x,Coordinate.y,0f), Quaternion.identity);*_

* }*
* Debug.Log("Selected Spawn Position "+ Coordinate);*
* }*
* }*
* }*
* public bool checkposition(Vector3 SpawnedPosition)*
* {*
// This is the problem code, it returns a “Expected Nested array Initializer was expected” error
* GameObject[] AllMountains = GameObject.FindGameObjectsWithTag(“Mountain”);*
* GameObject[] AllPlayerHQ = GameObject.FindGameObjectsWithTag (“PlayerHQ”);*
* GameObject[] AllMarksman = GameObject.FindGameObjectsWithTag (“PlayerSoldierMarksman”);*
* GameObject[,] AllActive = {AllMarksman, AllMountains, AllPlayerHQ};*
* int maxRow = AllActive.GetLength(0);*
* int maxCol = AllActive.GetLength (1);*
* for (int i =0; i <= maxRow; i++)*
* {*
* for (int x = 0; x<= maxCol; x++)*
* {*
* if (AllActive[i,x].transform.position == SpawnedPosition)*
* {*
* Debug.Log(“Spawn Blocked”);*
* return true;*
* }*
* }*
* }*
* return false;*
* }*
* Vector3 randomSpawnPosition()*
* {*
* int x = Random.Range(0,2);*
* int y = Random.Range(0,2);*
* Vector3 Position = new Vector3 (x, y,0f);*
* return Position;*

* }*
}

Change your method to the following:

public bool checkposition(Vector3 SpawnedPosition)
    {
        List<List<GameObject>> allActive = new List<List<GameObject>>();
        allActive.Add(GameObject.FindGameObjectsWithTag("Mountain").ToList());
        allActive.Add(GameObject.FindGameObjectsWithTag("PlayerHQ").ToList());
        allActive.Add(GameObject.FindGameObjectsWithTag("PlayerSoldierMarksman").ToList());

        if (allActive.Any(activeItem => activeItem.Any(activeGameObject => activeGameObject.transform.position == SpawnedPosition)))
        {
            Debug.Log("Spawn Blocked");
            return true;
        }
        return false;
    }

Make sure to add using System.Linq;

I have found the error, instead of using [i,x] i switch it to [x] instead