Beispiel #1
0
    private bool AddParameter(List <BehaviorParameter> parameterList, BehaviorParameter parameter, bool repeatAdd = false)
    {
        bool result = true;

        if (string.IsNullOrEmpty(parameter.parameterName))
        {
            string meg = string.Format("条件参数不能为空", parameter.parameterName);
            TreeNodeWindow.window.ShowNotification(meg);
            result = false;
        }

        for (int i = 0; i < parameterList.Count; ++i)
        {
            BehaviorParameter tempParameter = parameterList[i];
            if (!repeatAdd && tempParameter.parameterName.CompareTo(parameter.parameterName) == 0)
            {
                string meg = string.Format("条件参数:{0} 已存在", parameter.parameterName);
                TreeNodeWindow.window.ShowNotification(meg);
                result = false;
                break;
            }
        }

        if (result)
        {
            BehaviorParameter newParameter = parameter.Clone();
            parameterList.Add(newParameter);
        }

        return(result);
    }
    private void NodeChangeParameter(int nodeId, string oldParameter, string newParameter)
    {
        NodeValue nodeValue = GetNode(nodeId);

        if (null == nodeValue)
        {
            return;
        }

        BehaviorParameter parameter = null;

        for (int i = 0; i < _globalParameter.parameterList.Count; ++i)
        {
            BehaviorParameter temp = _globalParameter.parameterList[i];
            if (temp.parameterName.CompareTo(newParameter) == 0)
            {
                parameter = temp;
            }
        }

        if (null == parameter)
        {
            return;
        }

        for (int i = 0; i < nodeValue.parameterList.Count; ++i)
        {
            BehaviorParameter temp = nodeValue.parameterList[i];
            if (temp.parameterName.CompareTo(parameter.parameterName) == 0)
            {
                nodeValue.parameterList[i] = parameter.Clone();
                break;
            }
        }
    }
Beispiel #3
0
    private void SaveSubTree(string subTreeConfigName, int subTreeNodeId)
    {
        //ProDebug.Logger.LogError("SaveSubTree:" + subTreeConfigName + "     " + subTreeNodeId);

        NodeValue subTreeNode = GetNode(subTreeNodeId);

        if (null == subTreeNode || subTreeNode.NodeType != (int)NODE_TYPE.SUB_TREE)
        {
            return;
        }
        if (subTreeNode.subTreeType != (int)SUB_TREE_TYPE.NORMAL)
        {
            return;
        }

        BehaviorTreeData subTreeData = new BehaviorTreeData();

        subTreeData.fileName = subTreeConfigName;

        List <NodeValue> nodeList = new List <NodeValue>();

        FindChild(_behaviorTreeData, subTreeNodeId, ref nodeList);

        List <NodeValue> newNodeList = new List <NodeValue>();

        for (int i = 0; i < nodeList.Count; ++i)
        {
            NodeValue childNode    = nodeList[i];
            NodeValue newNodeValue = childNode.Clone();

            if (newNodeValue.subTreeEntry)
            {
                newNodeValue.isRootNode   = true;
                newNodeValue.parentNodeID = -1;
                subTreeData.rootNodeId    = newNodeValue.id;
            }
            newNodeValue.parentSubTreeNodeId = -1;

            subTreeData.nodeList.Add(newNodeValue);
        }

        for (int i = 0; i < _behaviorTreeData.parameterList.Count; ++i)
        {
            BehaviorParameter parameter = _behaviorTreeData.parameterList[i];
            subTreeData.parameterList.Add(parameter.Clone());
        }

        subTreeData = StandardID(subTreeData);

        SaveFile(subTreeConfigName, subTreeData);
    }
Beispiel #4
0
    //将配置好的Parameter存到环境dic中
    public void InitParmeter()
    {
        for (int i = 0; i < _parameterList.Count; ++i)
        {
            BehaviorParameter parameter = _parameterList[i];

            BehaviorParameter cacheParaemter = null;
            if (!_environmentParameterDic.TryGetValue(parameter.parameterName, out cacheParaemter))
            {
                cacheParaemter = parameter.Clone();
                _environmentParameterDic[parameter.parameterName] = cacheParaemter;
            }

            cacheParaemter.intValue   = parameter.intValue;
            cacheParaemter.floatValue = parameter.floatValue;
            cacheParaemter.boolValue  = parameter.boolValue;
        }
    }
Beispiel #5
0
    public void AddParameter(List <BehaviorParameter> parameterList)
    {
        for (int i = 0; i < parameterList.Count; ++i)
        {
            BehaviorParameter parameter = parameterList[i];
            if (_allParameterDic.ContainsKey(parameter.parameterName))
            {
                continue;
            }

            //Debug.LogError(parameter.parameterName + "     " + (BehaviorParameterType)(parameter.parameterType));
            _allParameterDic[parameter.parameterName] = parameter.Clone();

            // 暂时这么处理,以后改成读取默认值
            _allParameterDic[parameter.parameterName].intValue   = 0;
            _allParameterDic[parameter.parameterName].floatValue = 0;
            _allParameterDic[parameter.parameterName].boolValue  = false;
        }

        if (parameterList.Count > 0)
        {
            Debug.Log("暂时这么处理,以后改成读取默认值");
        }
    }