Advertisement
Learning000001

Untitled

Oct 19th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using TheChess;
  3. using TheChess.Mechanism;
  4. using UnityEngine;
  5.  
  6. public class AIGUI : ChessGameAIGUI
  7. {
  8. public static Action<ChessPiece.ChessPieceType,string,bool> OnPeaceMoved;
  9.  
  10. protected override void OnPieceFinishMoving(ChessMove _move, ChessPieceObject _selectedTarget, bool _isMoveContinueGame)
  11. {
  12. base.OnPieceFinishMoving(_move, _selectedTarget, _isMoveContinueGame);
  13. ReportMove(_move,_selectedTarget);
  14. }
  15.  
  16. protected override void OnPieceFinishAttacking(ChessMove _move, ChessPieceObject _selectedTarget, ChessPieceObject _capturedTarget, bool _isMoveContinueGame)
  17. {
  18. base.OnPieceFinishAttacking(_move, _selectedTarget, _capturedTarget, _isMoveContinueGame);
  19. ReportMove(_move,_selectedTarget);
  20. }
  21.  
  22. private void ReportMove(ChessMove _move, ChessPieceObject _selectedTarget)
  23. {
  24. string _moveDescription = _move.End.Description;
  25. bool _isWhite = _selectedTarget.Piece.Color.IsWhite;
  26. OnPeaceMoved?.Invoke(_selectedTarget.Piece.PieceType,_moveDescription,_isWhite);
  27. }
  28.  
  29. protected override ChessMove.ChessMoveType OpponentExecuteMoveLogic(ChessMove _move, ChessPiece.ChessPieceType _promotionType)
  30. {
  31. var _moveType = Game.ExecuteWithoutClearingUndoHistories(_move, _promotionType);
  32. return _moveType;
  33. }
  34.  
  35. protected override void AIMakeMove(ChessMove _move, ChessPiece.ChessPieceType _promotionType)
  36. {
  37. InstantMove(_move, _promotionType, false);
  38. ChangeTileColor(_move, Color.cyan);
  39. }
  40.  
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement