protected void manageCoverUnderPiece() { Cell localCell = TransformVectorToCell(transform.position); if (localCell != cellNow) { if (coverUnderPiece != null) { Destroy(coverUnderPiece); coverUnderPiece = null; } cellNow = localCell; if ((cellNow == null) || (cellNow.Equals(cell))) { return; } if (AllowedMoves.Contains(cellNow)) { coverUnderPiece = Instantiate(possibleMoveObject); } else { coverUnderPiece = Instantiate(wrongMoveObject); } coverUnderPiece.transform.position = startBoardPoint + new Vector3(localCell.Vertical, localCell.Horizontal, 0) * deltaCell + new Vector3(5, 5, 0.1f); } }
void OnMouseUp() { if (!isDragged) { return; } if (coverUnderPiece != null) { Destroy(coverUnderPiece); coverUnderPiece = null; } isDragged = false; Cell moveCell = TransformVectorToCell(transform.position); if ((moveCell == null) || (!AllowedMoves.Contains(moveCell))) { Move(cell); return; } NotifyMove(cell, moveCell); }
/// <summary> /// Checks if the requested <see cref="move"/> is legally able to be learned. /// </summary> /// <param name="move">Move to check if can be learned</param> /// <returns>True if can learn the move</returns> public bool CanLearn(int move) => AllowedMoves.Contains(move);