Beispiel #1
0
    public void OnMouseUp()
    {
        if (GetNode().draggable.followUI)
        {
            return;            //do nothing if it hasnt been purchased yet
        }
        if (UIConnectorIn.currentHoveredConnector)
        {
            if (UIConnectorIn.currentHoveredConnector.GetNode().draggable.followUI)
            {
                //purchase this node
                if (!GameManager.instance.recipeManager.PurchaseNode(UIConnectorIn.currentHoveredConnector.GetNode()))
                {
                    //if we cant afford it player cant take it
                    return;
                }
                UIConnectorIn.currentHoveredConnector.GetNode().draggable.followUI = false;
            }
            endPoint            = UIConnectorIn.currentHoveredConnector;
            endPoint.startPoint = this;
        }
        else
        {
            line.enabled = false;
            line.SetPosition(0, transform.position);
            line.SetPosition(1, transform.position);
            line.SetPosition(2, transform.position);
            line.SetPosition(3, transform.position);
        }

        Debug.Log("drag end");
        currentDraggedConnector = null;
    }
Beispiel #2
0
 private void OnMouseEnter()
 {
     Debug.Log("entered");
     if (startPoint == null)
     {
         if (UIConnectorOut.currentDraggedConnector && UIConnectorOut.currentDraggedConnector.outputRecipe == inputRecipe)
         {
             currentHoveredConnector = this;
         }
     }
 }
 void recursiveDoop(Node doopedNode, Node originalNode)
 {
     for (int index = 0; index < originalNode.InConnections.Count; index++)
     {
         UIConnectorIn i = originalNode.InConnections[index];
         if (i.startPoint != null)
         {
             if (SelectedList.Contains(i.startPoint.GetNode()))
             {
                 Node newNode = i.startPoint.GetNode().duplicateNodeSuchThatThisNodeStillExistsButThereNowExistsAnotherIdenticalOneBesideItAlsoSetTheOutputToLinkToTheInConnectionSuppliedInTheFunctionParametersIfItIsNotNull(doopedNode.InConnections[index]);
                 SelectedList.Remove(i.startPoint.GetNode());
                 newSelectionList.Add(newNode);
                 recursiveDoop(newNode, i.startPoint.GetNode());
             }
         }
     }
 }
Beispiel #4
0
    public void OnMouseDown()
    {
        if (GetNode().draggable.followUI)
        {
            return;            //do nothing if it hasnt been purchased yet
        }
        if (endPoint)
        {
            endPoint.startPoint = null;
        }
        endPoint = null;

        Vector3 linePoint = transform.position;

        linePoint.z = -1;
        line.SetPosition(0, linePoint);
        linePoint.x = linePoint.x + lineBendDistance;
        line.SetPosition(1, linePoint);

        currentDraggedConnector = this;

        StartCoroutine(LineAfterOneFrame());
        Debug.Log("drag start");
    }
Beispiel #5
0
    public Node duplicateNodeSuchThatThisNodeStillExistsButThereNowExistsAnotherIdenticalOneBesideItAlsoSetTheOutputToLinkToTheInConnectionSuppliedInTheFunctionParametersIfItIsNotNull(UIConnectorIn connection)
    {
        Vector3 Offset = new Vector3(2.0f, -2.0f, 0.0f);
        Node    node   = Instantiate <Node> (this, this.transform.position + Offset, Quaternion.identity);

        node.GetComponentsInChildren <UIConnectorIn> (false, node.InConnections);

        foreach (UIConnectorIn i in node.InConnections)
        {
            if (i != null)
            {
                i.startPoint = null;
            }
        }

        if (!Recipe.IsFinalNode)
        {
            node.OutConnection.endPoint     = null;
            node.OutConnection.line.enabled = false;
        }

        if (connection != null)
        {
            node.OutConnection.endPoint     = connection;
            connection.startPoint           = node.OutConnection;
            node.OutConnection.line.enabled = true;
        }

        node.gameObject.name = Recipe.GetFullName() + "_" + Time.frameCount;
        Node.allNodes.Add(node);
        return(node);
    }
Beispiel #6
0
    private void OnMouseExit()
    {
        Debug.Log("exit");

        currentHoveredConnector = null;
    }