コード例 #1
0
ファイル: Piece.cs プロジェクト: jclarkrichards/RubiksTacToe
    // When this piece is no longer being dragged around or tapped
    private void OnMouseUp()
    {
        if (followMouse)
        {
            Vector3 position = PlayField.S.GetClosestLocation(transform.position);
            followMouse = false;
            drag.ResetTiltValues();
            if (PlayField.S.LocationIsEmpty(position))
            {
                //print("Location is empty");
                if (OtherPiece())
                {
                    //print("flipping other piece");
                    Vector3 temp = position - previousPosition;
                    temp.z = 0.0f;
                    //print(temp.sqrMagnitude);
                    if (PlayField.S.LocationIsAdjacent(position, previousPosition))
                    {
                        //print("Location is adjacent");

                        // (position != previousPosition && temp.sqrMagnitude < 3.0f)
                        //
                        GameLogic.S.flippedPiece = true;
                        Flip();
                        SetPosition(position);
                    }
                    else
                    {
                        Vector3 p = previousPosition;
                        SetPosition(p);
                    }
                }

                if (OwnPiece())
                {
                    Vector3 magVec = position - transform.position;
                    magVec.z = 0.0f;
                    if (magVec.sqrMagnitude < 0.5f)
                    {
                        GameLogic.S.movedPieceToBoard = true;
                        SetPosition(position);
                        PlayField.S.ActivateButtonsByTurn();
                    }
                    else
                    {
                        Vector3 p = previousPosition;
                        p.z = transform.position.z;
                        SetPosition(p);
                    }
                }
            }
            else
            {
                Vector3 p = previousPosition;
                p.z = transform.position.z;
                SetPosition(p);
            }

            if (OwnPiece())
            {
                //print(Time.time - startTime);
                if (Time.time - startTime < 0.3f)
                {
                    Flip();
                }
            }
        }
    }
コード例 #2
0
 private void OnMouseUp()
 {
     followMouse = false;
     drag.ResetTiltValues();
 }