private Quaternion GetPieceQuaternion(PieceColorType colorType) { return(Quaternion.Euler( m_PieceObj.transform.localRotation.x, m_PieceObj.transform.localRotation.y, colorType == PieceColorType.Black ? BLACK_ROTATE : WHITE_ROTATE)); }
public void Reverse() { PieceColorType reverseColor = GetReverseColor(m_CurrentColor); m_CurrentColor = reverseColor; ReverseAnimation(reverseColor); }
public void Reset() { m_CurrentColor = PieceColorType.None; if (m_PieceObj != null) { Destroy(m_PieceObj); } }
private void ReverseAnimation(PieceColorType colorType) { Sequence seq = DOTween.Sequence(); seq.Append(m_PieceObj.transform.DOLocalMoveY(PUT_ANIM_MOVE_Y_AMOUNT, PUT_ANIM_TIME).SetRelative()); seq.Join(m_PieceObj.transform.DOLocalRotateQuaternion( GetPieceQuaternion(colorType), PUT_ANIM_TIME)); seq.Append(m_PieceObj.transform.DOLocalMoveY(-PUT_ANIM_MOVE_Y_AMOUNT, PUT_ANIM_TIME).SetRelative()); }
public void Put(PieceColorType color) { if (HasPiece) { //置くときは置けるか確認する // TODO 置けたかどうかのリザルトを返すようにする throw new Exception("置けないよ"); } piece = new Piece(color); }
public void Put(CellPos pos, PieceColorType color) { var cell = CellByPos(pos); if (HasPieceByPos(pos)) { return; } cell.Put(color); }
public void UpdateBoardUIInfo(PieceColorType nextColorType) { m_BoardUI.SetCurrentTurnText(nextColorType); var colorCountInfo = GetColorCountInfo(); m_BoardUI.SetBlackCountText(colorCountInfo.Black); m_BoardUI.SetWhiteCountText(colorCountInfo.White); if (colorCountInfo.None == 0) { Finish(); } }
private string GetResultColorText(PieceColorType winColor) { switch (winColor) { case PieceColorType.None: return("DRAW"); case PieceColorType.Black: return("WHITE WIN !"); case PieceColorType.White: return("BLACK WIN !"); default: return(""); } }
private List <BoardSquare> GetTargetColorSquares(BoardSquare[,] boardSquares, PieceColorType targetColor) { var targetColorSquares = new List <BoardSquare>(); for (int x = 0; x < Address.MAX_WIDTH; x++) { for (int y = 0; y < Address.MAX_WIDTH; y++) { var square = boardSquares[x, y]; if (square.CurrentColor == targetColor) { targetColorSquares.Add(square); } } } return(targetColorSquares); }
public bool CanPutPiece(BoardSquare[,] boardSquares, PieceColorType putPieceColor, Address pos) { var square = GetSquare(boardSquares, pos); if (!square.IsEmpty()) { return(false); } var reverseTargetSquareList = GetReverseTargetSquares(boardSquares, pos, putPieceColor); if (reverseTargetSquareList.Count == 0) { return(false); } return(true); }
public bool CanPutPieceSomeWhere(BoardSquare[,] boardSquares, PieceColorType putPieceColor) { // 盤上にある置こうとしてる色とは反対の色のマスを取得 var targetColorSquares = GetTargetColorSquares(boardSquares, BoardSquare.GetReverseColor(putPieceColor)); foreach (var square in targetColorSquares) { // 隣接するマスを取得(最大8マス) var adjacentSquareDic = GetAdjacentSquares(square.Address); foreach (var dic in adjacentSquareDic) { var adjacentSquare = GetSquare(boardSquares, dic.Value); if (CanPutPiece(boardSquares, putPieceColor, adjacentSquare.Address)) { return(true); } } } return(false); }
public void Reverse() { PieceColor = PieceColor == PieceColorType.White ? PieceColorType.Black : PieceColorType.White; }
public Piece(PieceColorType pieceColorType) { PieceColor = pieceColorType; }
public OthelloLogicBase(Board board, PieceColorType startTurn) { Board = board; Turn = startTurn; }
public static PieceColorType GetReverseColor(PieceColorType colorType) => (colorType == PieceColorType.White) ? PieceColorType.Black : PieceColorType.White;
public void SetCurrentTurnText(PieceColorType colorType) { m_CurrentTurnText.text = colorType.ToString(); m_CurrentTurnText.color = (colorType == PieceColorType.White) ? Color.white : Color.black; }
public void ShowResultDialog(PieceColorType winColor) { m_ResultColorText.text = GetResultColorText(winColor); m_ResultDialog.SetActive(true); }
private void CreateAndPutPiece(Address pos, PieceColorType pieceColorType) { var pieceObj = Instantiate(m_PieceObj, new Vector3(pos.X, 0.6f, -pos.Y), Quaternion.identity, m_PieceRoot); GetSquare(pos).PutPiece(pieceObj, pieceColorType); }
public DefaultOthelloLogic(Board board, PieceColorType startTurn) : base(board, startTurn) { }
private void FinishTurn(PieceColorType nextTurnColor) { m_CurrentTurnColor = nextTurnColor; BoardManager.I.UpdateBoardUIInfo(nextTurnColor); }
private void ChangeTurnColor() { m_CurrentTurnColor = (m_CurrentTurnColor == PieceColorType.Black) ? PieceColorType.White : PieceColorType.Black; }
private Dictionary <Direction, Address> GetTargetColorSquare(BoardSquare[,] boardSquares, Dictionary <Direction, Address> squareDic, PieceColorType pieceColorType) { var resultSquareDic = new Dictionary <Direction, Address>(); if (squareDic.Count == 0) { return(resultSquareDic); } return(squareDic.Where(square => GetSquare(boardSquares, square.Value).CurrentColor == pieceColorType).ToDictionary(s => s.Key, s => s.Value)); }
public void PutPiece(GameObject pieceObj, PieceColorType pieceColorType) { m_PieceObj = pieceObj; m_CurrentColor = pieceColorType; m_PieceObj.transform.localRotation = GetPieceQuaternion(pieceColorType); }
public List <BoardSquare> GetReverseTargetSquares(BoardSquare[,] boardSquares, Address putPos, PieceColorType currentColor) { var reverseTargetSquareList = new List <BoardSquare>(); // 隣接するマスを取得(最大8マス) var adjacentSquareDic = GetAdjacentSquares(putPos); // 隣接するマスから現在の色と反対色のマスを取得 var reverseColorSquareDic = GetTargetColorSquare(boardSquares, adjacentSquareDic, BoardSquare.GetReverseColor(currentColor)); if (reverseColorSquareDic.Count == 0) { return(reverseTargetSquareList); } foreach (var item in reverseColorSquareDic) { Address currentSearchPos = item.Value; var reservationSquareList = new List <BoardSquare>(); reservationSquareList.Add(GetSquare(boardSquares, currentSearchPos)); while (true) { Address searchPos = GetDirectionPos(item.Key, currentSearchPos); if (!searchPos.IsValid()) { break; } var square = GetSquare(boardSquares, searchPos); if (square.CurrentColor == currentColor) { reverseTargetSquareList.AddRange(reservationSquareList); break; } else if (square.CurrentColor == BoardSquare.GetReverseColor(currentColor)) { reservationSquareList.Add(square); } else if (square.IsEmpty()) { break; } currentSearchPos = searchPos; } } return(reverseTargetSquareList); }