//put piece ignoring rules other than the "no putting pieces in occupied zones" rule public bool ForcePut(OthelloZoneBehaviour z, bool turn) { if (!z.IsEmpty()) { return(false); } OthelloPieceBehaviour newPiece = new GameObject().AddComponent <OthelloPieceBehaviour>(); newPiece = newPiece.Put(z, turn); newPiece.gameObject.GetComponent <MeshRenderer>().enabled = true; foreach (OthelloZoneBehaviour a in boardReference.GetAdjacentZones(z)) { if (a.IsEmpty()) { possibleZones.Add(a); } } possibleZones.Remove(z); return(true); }
public bool PutPieceCheck(OthelloZoneBehaviour z, bool turn) { if (!z.IsEmpty()) { return(false); } for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (i == 0 && j == 0 && k == 0) { continue; } int zi = z.i, zj = z.j, zk = z.k; int dist = 0; OthelloPieceBehaviour currPiece; while ( ValidIndex(zi + i) && ValidIndex(zj + j) && ValidIndex(zk + k) ) { zi += i; zj += j; zk += k; dist++; currPiece = boardReference.GetZone(zi, zj, zk).GetPiece(); if (!currPiece) { break; } if (currPiece.GetColor == turn && dist > 1) { return(true); } } } } } return(false); }