示例#1
0
 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));
 }
示例#2
0
    public void Reverse()
    {
        PieceColorType reverseColor = GetReverseColor(m_CurrentColor);

        m_CurrentColor = reverseColor;
        ReverseAnimation(reverseColor);
    }
示例#3
0
 public void Reset()
 {
     m_CurrentColor = PieceColorType.None;
     if (m_PieceObj != null)
     {
         Destroy(m_PieceObj);
     }
 }
示例#4
0
    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());
    }
示例#5
0
 public void Put(PieceColorType color)
 {
     if (HasPiece)
     {
         //置くときは置けるか確認する
         // TODO 置けたかどうかのリザルトを返すようにする
         throw new Exception("置けないよ");
     }
     piece = new Piece(color);
 }
示例#6
0
        public void Put(CellPos pos, PieceColorType color)
        {
            var cell = CellByPos(pos);

            if (HasPieceByPos(pos))
            {
                return;
            }
            cell.Put(color);
        }
示例#7
0
    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();
        }
    }
示例#8
0
    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("");
        }
    }
示例#9
0
    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);
    }
示例#10
0
    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);
    }
示例#11
0
    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);
    }
示例#12
0
 public void Reverse()
 {
     PieceColor = PieceColor == PieceColorType.White ? PieceColorType.Black : PieceColorType.White;
 }
示例#13
0
 public Piece(PieceColorType pieceColorType)
 {
     PieceColor = pieceColorType;
 }
示例#14
0
 public OthelloLogicBase(Board board, PieceColorType startTurn)
 {
     Board = board;
     Turn  = startTurn;
 }
示例#15
0
 public static PieceColorType GetReverseColor(PieceColorType colorType) => (colorType == PieceColorType.White) ? PieceColorType.Black : PieceColorType.White;
示例#16
0
 public void SetCurrentTurnText(PieceColorType colorType)
 {
     m_CurrentTurnText.text  = colorType.ToString();
     m_CurrentTurnText.color = (colorType == PieceColorType.White) ? Color.white : Color.black;
 }
示例#17
0
 public void ShowResultDialog(PieceColorType winColor)
 {
     m_ResultColorText.text = GetResultColorText(winColor);
     m_ResultDialog.SetActive(true);
 }
示例#18
0
    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)
 {
 }
示例#20
0
 private void FinishTurn(PieceColorType nextTurnColor)
 {
     m_CurrentTurnColor = nextTurnColor;
     BoardManager.I.UpdateBoardUIInfo(nextTurnColor);
 }
示例#21
0
 private void ChangeTurnColor()
 {
     m_CurrentTurnColor = (m_CurrentTurnColor == PieceColorType.Black) ?
                          PieceColorType.White : PieceColorType.Black;
 }
示例#22
0
    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));
    }
示例#23
0
 public void PutPiece(GameObject pieceObj, PieceColorType pieceColorType)
 {
     m_PieceObj     = pieceObj;
     m_CurrentColor = pieceColorType;
     m_PieceObj.transform.localRotation = GetPieceQuaternion(pieceColorType);
 }
示例#24
0
    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);
    }