void CheckMarker() { bool deleted = false; int advCount = 0; foreach (var m in F.activeMarker.ToArray()) { if (m.GetComponent <Marker>().type == "red") { var cube = F.GetCubeAt(m.GetComponent <Marker>().column, m.GetComponent <Marker>().row); if (cube != null) { if (m.GetComponent <Marker>().isAdvantage) { advCount++; } F.RemoveCube(cube); if (cube.GetComponent <Cube>().typeString == "advantage") { m.GetComponent <Marker>().SetType("advantage"); } else if (!m.GetComponent <Marker>().isAdvantage) { F.EraseMarker(m); } deleted = true; } } } if (deleted) { deleting = true; if (advCount > 0) { foreach (var item in F.activeMarker.ToArray()) { if ((item.GetComponent <Marker>().type == "red" || item.GetComponent <Marker>().isAdvantage) && item.GetComponent <Marker>().type == "gold" ) { F.EraseMarker(item); } } } } }