public override NodeStates Evaluate()
    {
        bool anyChildRunning = false;

        //所有都为success为success
        foreach (var VARIABLE in m_nodes)
        {
            switch (VARIABLE.Evaluate())
            {
            case NodeStates.FAILURE:
                m_NodeState = NodeStates.FAILURE;
                return(m_NodeState);

            case NodeStates.SUCCESS:
                continue;

            case NodeStates.RUNNINT:
                anyChildRunning = true;
                continue;

            default:
                m_NodeState = NodeStates.SUCCESS;
                return(m_NodeState);
            }
        }

        m_NodeState = anyChildRunning ? NodeStates.RUNNINT : NodeStates.SUCCESS;
        return(m_NodeState);
    }
Ejemplo n.º 2
0
    public override NodeStates Evaluate()
    {
        //只要有一个Success即为success
        foreach (var VARIABLE in m_nodes)
        {
            switch (VARIABLE.Evaluate())
            {
            case NodeStates.FAILURE:
                continue;

            case NodeStates.SUCCESS:
                m_NodeState = NodeStates.SUCCESS;
                return(m_NodeState);

            case NodeStates.RUNNINT:
                m_NodeState = NodeStates.RUNNINT;
                return(m_NodeState);

            default:
                continue;
            }
        }
        m_NodeState = NodeStates.FAILURE;
        return(m_NodeState);
    }