mirror of
https://github.com/Earth-Genesis-Games/Ajedrez_Purgatorio.git
synced 2026-09-11 09:47:35 +00:00
fix: comprehensive chess gameplay fixes
- BoardManager: always PlacePieces() in Start() (traditional chess first, campaign can override via SetupBoard) - Piece.ShowMoves: filter by legal moves only (MoveValidator.IsMoveLegal) - SquareClick: null checks + GameState.Playing guard - DialogueSystem: WaitForSecondsRealtime for typewriter (survives timeScale=0) - GameManager: add IsMoveLegal public method for Piece.ShowMoves - GameManager: en passant fires OnPieceCaptured BEFORE Destroy - GameHUD: delegate pause to PauseMenuController (no direct timeScale)
This commit is contained in:
@@ -57,11 +57,9 @@ public GameObject kingPrefab; // Prefab del Rey usado como "jefe" en el purgator
|
||||
GenerateBoard();
|
||||
GenerateIndicators();
|
||||
|
||||
// Skip standard piece placement if CampaignManager will call SetupBoard
|
||||
if (CampaignManager.Instance == null || !CampaignManager.Instance.IsCampaignActive)
|
||||
{
|
||||
PlacePieces();
|
||||
}
|
||||
// Always place standard pieces for traditional chess.
|
||||
// CampaignManager.SetupBoard() can override later if needed.
|
||||
PlacePieces();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -177,7 +177,7 @@ public class DialogueSystem : MonoBehaviour
|
||||
|
||||
if (i < fullText.Length)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
yield return new WaitForSecondsRealtime(delay);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,8 +207,17 @@ public class GameManager : MonoBehaviour
|
||||
if (enPassantCaptured != null)
|
||||
{
|
||||
isEnPassant = true;
|
||||
Destroy(enPassantCaptured.gameObject);
|
||||
|
||||
// En Passant: gestionar captura especial (event BEFORE destroy)
|
||||
if (enPassantCaptured.isWhite && enPassantCaptured.identity != null)
|
||||
{
|
||||
if (PurgatoryManager.Instance != null)
|
||||
PurgatoryManager.Instance.OnPieceCaptured(enPassantCaptured.identity);
|
||||
}
|
||||
OnPieceCaptured?.Invoke(enPassantCaptured);
|
||||
|
||||
_board[newPos.x, captureY] = null;
|
||||
Destroy(enPassantCaptured.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,20 +243,6 @@ public class GameManager : MonoBehaviour
|
||||
Destroy(captured.gameObject);
|
||||
}
|
||||
|
||||
// En Passant: gestionar captura especial
|
||||
if (isEnPassant && enPassantCaptured != null && enPassantCaptured.isWhite && enPassantCaptured.identity != null)
|
||||
{
|
||||
if (PurgatoryManager.Instance != null)
|
||||
{
|
||||
PurgatoryManager.Instance.OnPieceCaptured(enPassantCaptured.identity);
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnPassant && enPassantCaptured != null)
|
||||
{
|
||||
OnPieceCaptured?.Invoke(enPassantCaptured);
|
||||
}
|
||||
|
||||
// Mover pieza
|
||||
_board[oldPos.x, oldPos.y] = null;
|
||||
_board[newPos.x, newPos.y] = piece;
|
||||
@@ -443,6 +438,16 @@ private GameObject GetPrefabForPromotion(PieceType type, bool isWhite)
|
||||
return _checkDetector.IsInCheck(_board, forWhite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica si un movimiento es legal (in bounds, pseudo-legal, y no deja al rey en jaque).
|
||||
/// Usado por ShowMoves para filtrar indicadores.
|
||||
/// </summary>
|
||||
public bool IsMoveLegal(Piece piece, Vector2Int targetPos)
|
||||
{
|
||||
if (piece == null) return false;
|
||||
return _moveValidator.IsMoveLegal(_board, piece, targetPos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica si un jugador está en jaque mate.
|
||||
/// </summary>
|
||||
|
||||
@@ -70,11 +70,16 @@ public class Piece : MonoBehaviour
|
||||
if (GameManager.Instance == null || BoardManager.Instance == null)
|
||||
return;
|
||||
|
||||
var moves = GetAvailableMoves(GameManager.Instance.board);
|
||||
BoardManager.Instance.HideAllIndicators();
|
||||
foreach (var move in moves)
|
||||
|
||||
// Get legal moves (filtered: won't leave king in check)
|
||||
var allMoves = GetAvailableMoves(GameManager.Instance.board);
|
||||
foreach (var move in allMoves)
|
||||
{
|
||||
BoardManager.Instance.ShowIndicator(move);
|
||||
if (GameManager.Instance.IsMoveLegal(this, move))
|
||||
{
|
||||
BoardManager.Instance.ShowIndicator(move);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ public class SquareClick : MonoBehaviour
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (GameManager.Instance == null) return;
|
||||
|
||||
// Don't process clicks during dialogue, purgatory, or game over
|
||||
if (GameStateManager.Instance != null && GameStateManager.Instance.CurrentState != GameState.Playing)
|
||||
return;
|
||||
|
||||
Piece piece = GameManager.Instance.board[position.x, position.y];
|
||||
|
||||
if (piece != null && piece.isWhite == GameManager.Instance.whiteTurn)
|
||||
|
||||
@@ -228,10 +228,11 @@ namespace AjedrezPurgatorio.UI
|
||||
if (_enableDebugLogging)
|
||||
Debug.Log("[GameHUD] Pause button clicked.");
|
||||
|
||||
// Pause the game
|
||||
Time.timeScale = 0f;
|
||||
|
||||
// Find and show pause menu
|
||||
// Don't double-pause
|
||||
PauseMenuController existing = FindObjectOfType<PauseMenuController>();
|
||||
if (existing != null && existing.gameObject.activeInHierarchy) return;
|
||||
|
||||
// Find and show pause menu (it manages timeScale)
|
||||
PauseMenuController pauseMenu = FindObjectOfType<PauseMenuController>();
|
||||
if (pauseMenu != null)
|
||||
{
|
||||
|
||||
+4358
-3
File diff suppressed because it is too large
Load Diff
+8800
-4445
File diff suppressed because it is too large
Load Diff
+9134
-4779
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user