Exemplo n.º 1
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);
    }
Exemplo n.º 2
0
    public void generateNode(RecipeScriptableObject pRecipe)
    {
        foreach (UIConnectorIn i in InConnections)
        {
            Destroy(i);
        }
        InConnections.Clear();

        int ingredients_count = Mathf.Max(pRecipe.ingredients.Count - 1, 0);

        Background.size = new Vector2(Background.size.x, background_base_height + (ingredients_count * 0.5f));
        BoxCollider2D col = GetComponent <BoxCollider2D> ();

        col.size   = new Vector2(col.size.x, col_base_height + (ingredients_count * 0.5f));
        col.offset = new Vector2(0, -(ingredients_count * 0.25f));

        for (int i = 0; i < pRecipe.ingredients.Count; i++)
        {
            RecipeScriptableObject ingredient = pRecipe.ingredients[i];
            GameObject             go         = Instantiate(InPrefab, (inPivot.position + new Vector3(0, -0.5f * i, -0.1f)), Quaternion.identity);
            InConnections.Add(go.GetComponent <UIConnectorIn> ());
            go.transform.SetParent(inPivot, true);
            go.GetComponent <UIConnectorIn> ().Text.text  = ingredient.name;
            go.GetComponent <UIConnectorIn>().inputRecipe = pRecipe.ingredients[i];
        }

        TitleText.text = pRecipe.GetFullName();
        if (pRecipe.IsFinalNode)
        {
            Destroy(OutConnection.gameObject);
        }
        else
        {
            OutConnection.Text.text    = pRecipe.name;
            OutConnection.outputRecipe = pRecipe;
        }
        this.gameObject.name = pRecipe.GetFullName() + "_" + (Time.frameCount % 9999999);
        Recipe = pRecipe;
    }