// Place(): place a base on a cell void Place(BasePiece piece, Cell targetCell) { // no need to clear when placing piece on board for the first time if (piece.GetCurrentCell()) { piece.GetCurrentCell().ClearCurrentPiece(); } piece.ClearCurrentCell(); piece.transform.position = targetCell.transform.position; piece.SetCurrentCell(targetCell); targetCell.SetCurrentPiece(piece); }
// Kill(): void Kill(BasePiece piece) { Debug.Log("PieceManager::Kill() " + piece); // clean up cell reference if (piece.GetCurrentCell()) { piece.GetCurrentCell().ClearCurrentPiece(); } // clean up base piece reference piece.ClearCurrentCell(); // Don't destory them, because we can reuse them for the next game -> deactivate instead // Destroy(piece.gameObject); piece.gameObject.SetActive(false); // game is over when king is killed if (piece is King) { GameManager.Instance.GameOver(); } }