Example #1
0
    void MouseDrag(ref GameObject obj)
    {
        //check if player's turn yet
        //moving an object
        if (obj == null)
        {
            return;
        }
        if (obj.tag == "Player" &&
            pawns.CanSelectPawn(obj) == false)
        {
            Debug.Log("Not your turn yet!"); //how many turns to wait?
            return;
        }
        if (obj.tag == "City")
        {
            return;
        }

        Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        point.z        = obj.transform.position.z;
        Cursor.visible = false;

        if (firstClicked)
        {
            firstClicked = false;

            {
                var card = obj.GetComponent <Card>();
                if (card)
                {
                    card.SetTopMost();
                }
            }

            //remember offset so card doesn't jump to cursor location
            offset = obj.transform.position - point;
        }

        obj.transform.position = point + offset;
    }