示例#1
0
    public NodeScript FindFirstNodeWithOnlyLeaves(string op)
    {
        //NodeScript ns = null;
        NodeScript returnNodeScript = null;
        Boolean    found            = false;
        Boolean    isAnOp           = false;
        Boolean    areBothLeaves    = false;

        for (int i = 0; i < nodeObjects.Count; i++)
        {
            Debug.Log(i);
            NodeScript nsTemp = null;
            nsTemp        = nodeObjects[i].GetComponent <NodeScript>();
            isAnOp        = nsTemp.CheckIfOperation();
            areBothLeaves = nsTemp.CheckIfBothLeaves(op);

            Debug.Log(nodeObjects.Count + ":" + i + ": " + op + "|" + nsTemp.GetOperation() + " isAnOp: " + isAnOp + " | areBothLeaves: " + areBothLeaves);
            if (isAnOp && areBothLeaves)
            {
                if (nsTemp.GetOperation().Equals(op))
                {
                    //should return ns above
                    Debug.Log("Found: " + op);
                    found            = true;
                    i                = nodeObjects.Count;
                    returnNodeScript = nsTemp;
                    break;
                }
            }
            //nullifies ns on each pass
            //ns = null;
        }
        Debug.Log("FindFirstNodeWithOnlyLeaves found: " + found);
        return(returnNodeScript);
    }
示例#2
0
    public NodeScript FindFirstNodeWithOnlyLeaves()
    {
        NodeScript ns = null;

        for (int i = 0; i < nodeObjects.Count; i++)
        {
            ns = nodeObjects[i].GetComponent <NodeScript>();
            if (ns.CheckIfOperation() && ns.CheckIfBothLeaves(""))
            {
                //should return ns above
                //doesn't need to get the actual operation
                break;
            }
            //nullifies ns on each pass
            ns = null;
        }
        return(ns);
    }