public bool RotateCCW(Field field, out SearchNode sn) { bool ok = false; Mino tmp = mino.Clone(); int size = tmp.GetSize(); int newRotationId = (tmp.GetRotationId() + 3) % 4; string k = "z"; if (size == 3) { if (field.IsValid(tmp, newRotationId, tmp.GetPosition()))//如果可以直接转进去 { tmp.CCWRotate(); ok = true; } else//如果不能就做踢墙检定 { Vector2Int o = Game.WallKickOffset(field, tmp, tmp.GetRotationId(), newRotationId, tmp.GetPosition()); if (o != new Vector2Int(0, 0)) { tmp.CCWRotate(); tmp.Move(o); k = "Z"; ok = true; } else { ok = false; } } } else if (size == 5) { Vector2Int o = Game.WallKickOffset_I(field, tmp, tmp.GetRotationId(), newRotationId, tmp.GetPosition(), out bool iSpin); if (o != new Vector2Int(0, 0)) { tmp.CCWRotate(); tmp.Move(o); if (iSpin) { k = "Z"; } ok = true; } else { ok = false; } } sn = new SearchNode(tmp, op + k); return(ok); }
public int CCWRotate()//逆时针旋转 { int size = activeMino.GetSize(); int newRotationId = (activeMino.GetRotationId() + 3) % 4; if (size == 3) { if (field.IsValid(activeMino, newRotationId, activeMino.GetPosition()))//如果可以直接转进去 { operation += "z"; activeMino.CCWRotate(); return(0); } else//如果不能就做踢墙检定 { Vector2Int o = WallKickOffset(activeMino, activeMino.GetRotationId(), newRotationId, activeMino.GetPosition()); if (o != new Vector2Int(0, 0)) { activeMino.CCWRotate(); activeMino.Move(o); operation += "Z"; return(0); } } } else if (size == 5) { bool iSpin = true; Vector2Int o = WallKickOffset_I(field, activeMino, activeMino.GetRotationId(), newRotationId, activeMino.GetPosition(), out iSpin); if (o != new Vector2Int(0, 0)) { activeMino.CCWRotate(); activeMino.Move(o); if (iSpin) { operation += "Z"; } else { operation += "z"; } return(0); } } return(-1); }