public void CheckMovePieces(EPieces ePieces, ESelectStartSide eSelectSide, Vector2Int slot, bool isCheckmate = false) { _allSlot = new List <Vector2Int>(); _slot = slot; _side = eSelectSide; switch (ePieces) { case EPieces.Pawn: PawnMove(); break; case EPieces.Rook: RookMove(); break; case EPieces.Knight: KnightMove(); break; case EPieces.Bishop: BishopMove(); break; case EPieces.Queen: QueenMove(); break; case EPieces.King: KingMove(); break; case EPieces.PawnHott: PawnHottMove(); break; case EPieces.Hott: HottMove(); break; default: break; } _allSlot = _allSlot.Distinct().OrderBy(item => item.x).ThenBy(item => item.y).ToList(); (isCheckmate ? (System.Action)Checkmate : CheckInteractBoard)(); }
public void CheckMovePieces(EPieces ePieces, ESelectStartColor eSelectSide, Vector2Int slot) { _allSlot = new List <Vector2Int>(); _slot = slot; _side = eSelectSide; switch (ePieces) { case EPieces.Pawn: PawnMove(); break; case EPieces.Rook: RookMove(); break; case EPieces.Knight: KnightMove(); break; case EPieces.Bishop: BishopMove(); break; case EPieces.Queen: QueenMove(); break; case EPieces.King: KingMove(); break; default: break; } CheckInteractBoard(); }
public void GetPieceTest() { const EPieces expected = EPieces.BlackKnight; var ps = new PieceSquare(expected, ESquare.none); var actual = ps.Piece; var expectedPiece = new Piece(expected); Assert.Equal(expectedPiece, actual); }
IEnumerator IEEatPiece(EPieces ePieces, ESelectStartSide eSelectSide, Vector2Int slot) { ClearTemp(); ClearNullList(); yield return(new WaitForFixedUpdate()); if (allPiecesFirstPlayers.Count(item => item) <= 0) { SideWin.CallBackSideWin?.Invoke(ESelectStartSide.SecondSide); } else if (allPiecesSecondPlayers.Count(item => item) <= 0) { SideWin.CallBackSideWin?.Invoke(ESelectStartSide.FirstSide); } else { if (isEatPiece) { oldSlot = BoardManage.instance.presentTargetBox.slot; yield return(new WaitForFixedUpdate()); yield return(StartCoroutine(BoardManage.instance.subBoardMovePieces.CheckChainingEat(ePieces, eSelectSide, slot))); } if (BoardManage.instance.presentTargetBox.isPawnEnchant && ePieces.Equals(EPieces.PawnHott)) { EnchantPawn.CallBackAutoEnchant?.Invoke(); } else if (BoardManage.instance.checkersManage.CheckHaveEatPiece()) { BoardManage.instance.checkersManage.OffBoxInteraction(BoardManage.instance.eTurnPlayer); } else { BoardManage.instance.presentPieces?.DefaulValue(); BoardManage.instance.SwichTurn(); } } }
public IEnumerator CheckChainingEat(EPieces ePieces, ESelectStartSide eSelectSide, Vector2Int slot) { BoardManage.instance.checkersManage.isEatPiece = false; _allSlot = new List <Vector2Int>(); _slot = slot; _side = eSelectSide; switch (ePieces) { case EPieces.PawnHott: PawnHottMove(true); break; case EPieces.Hott: HottMove(true); break; default: break; } if (BoardManage.instance.checkersManage.CheckHaveEatPiece()) { _allSlot = _allSlot.Distinct().OrderBy(item => item.x).ThenBy(item => item.y).ToList(); CheckInteractBoard(); } yield return(new WaitForFixedUpdate()); }
public void EatPiece(Vector2Int presentSlot, EPieces ePieces, ESelectStartSide eSelectSide, Vector2Int slot) { if (presentSlot.x > oldSlot.x) // Up { if (presentSlot.y > oldSlot.y) { if (tempEatUpRight && presentSlot.y > tempEatUpRight.transform.parent.GetComponent <BoxManage>().slot.y) { Debug.Log($"UR"); Destroy(tempEatUpRight.gameObject); isEatPiece = true; } else { Debug.Log($"OUR"); } } else { if (tempEatUpLeft && presentSlot.y < tempEatUpLeft.transform.parent.GetComponent <BoxManage>().slot.y) { Debug.Log($"UL"); Destroy(tempEatUpLeft.gameObject); isEatPiece = true; } else { Debug.Log($"OUL"); } } } else // Down { if (presentSlot.y > oldSlot.y) { if (tempEatDownRight && presentSlot.y > tempEatDownRight.transform.parent.GetComponent <BoxManage>().slot.y) { Debug.Log($"DR"); Destroy(tempEatDownRight.gameObject); isEatPiece = true; } else { Debug.Log($"ODR"); } } else { if (tempEatDownLeft && presentSlot.y < tempEatDownLeft.transform.parent.GetComponent <BoxManage>().slot.y) { Debug.Log($"DL"); Destroy(tempEatDownLeft.gameObject); isEatPiece = true; } else { Debug.Log($"ODL"); } } } StartCoroutine(IEEatPiece(ePieces, eSelectSide, slot)); }