/// <summary> /// RandomPosition returns a random position from our list gridPositions. /// </summary> /// <returns></returns> public Vector3 GetRandomBoardPosition() { int randomIndex = Random.Range(0, SpawnZoneBoardPositions.Count); Vector3 randomPosition = SpawnZoneBoardPositions[randomIndex]; //Remove the entry at randomIndex from the list so that it can't be re-used. SpawnZoneBoardPositions.RemoveAt(randomIndex); return(randomPosition); }
private void PopulateBoardPositions() { for (int row = 0; row < Rows; row++) { for (int col = 0; col < Cols; col++) { if (IsInSpawnZone(row, col)) { SpawnZoneBoardPositions.Add(new Vector3(col, row)); } else if (IsInSafeZone(row, col)) { SafeZoneBoardPositions.Add(new Vector3(col, row)); } else if (IsInOuterWall(row, col)) { OuterWallZoneBoardPositions.Add(new Vector3(col, row)); } } } }