Ejemplo n.º 1
0
        /// <summary>
        /// 获取事件的节点总数
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <returns>所有结点的名字</returns>
        public int GetNodeCount(int i)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;

            return(list.Count);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取事件的节点的后续节点名
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <param name="k">后续结点的序号</param>
        /// <returns>结点名</returns>
        public string GetNextNodeName(int i, int j, int k)
        {
            FlowChartMetaData eventNode = entranceNodeList[i - 1];
            string            nodeName;

            if (j == 0) // 直接取当前入口结点
            {
                List <FlowChartMetaData> list = new List <FlowChartMetaData>();
                GetNextNode(eventNode, list);
                FlowChartMetaData nextMetaData = list[k - 1];

                nodeName = nextMetaData.DataType + "_" + flowChartID + "_" + nextMetaData.ID;
            }
            else
            {
                List <FlowChartMetaData> list     = eventTable[eventNode] as List <FlowChartMetaData>;
                FlowChartMetaData        metaData = list[j - 1];
                list = new List <FlowChartMetaData>();
                GetNextNode(metaData, list);
                FlowChartMetaData nextMetaData = list[k - 1];

                nodeName = nextMetaData.DataType + "_" + flowChartID + "_" + nextMetaData.ID;
            }

            return(nodeName);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 添加连入流程图的元数据
 /// </summary>
 /// <param name="metaData">元数据</param>
 public void AddPreviousMetaData(FlowChartMetaData metaData)
 {
     if (!previousMetaDataList.Contains(metaData))
     {
         previousMetaDataList.Add(metaData);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取事件函数的名字
        /// </summary>
        /// <param name="i">事件函数的序号</param>
        /// <returns>事件函数的名字</returns>
        public string GetEventFunctionName(int i)
        {
            FlowChartMetaData eventNode    = entranceNodeList[i - 1];
            string            functionName = eventNode.DataType + "_" + flowChartID + "_" + eventNode.ID;

            return(functionName);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 添加连出流程图的元数据
 /// </summary>
 /// <param name="metaData">元数据</param>
 public void AddNextMetaData(FlowChartMetaData metaData)
 {
     if (!nextMetaDataList.Contains(metaData))
     {
         nextMetaDataList.Add(metaData);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取事件的的节点的生成代码
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <returns>结点的生成代码</returns>
        public string GetNodeCode(int i, int j)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData  = list[j - 1];

            return(metaData.Code);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取事件的节点的分支执行流程数量
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <returns>分支执行流程数量</returns>
        public int GetNodeSwitchCount(int i, int j)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData  = list[j - 1];

            return(metaData.NextMetaDataList.Count);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取事件的节点的连接线上的条件内容
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <param name="k">条件的序号</param>
        /// <returns>条件内容</returns>
        public string GetConditionResult(int i, int j, int k)
        {
            FlowChartMetaData        eventNode    = entranceNodeList[i - 1];
            List <FlowChartMetaData> list         = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData     = list[j - 1];
            FlowChartMetaData        nextMetaData = metaData.NextMetaDataList[k - 1];

            return(nextMetaData.Code);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取当前结点下一个结点的集合
 /// </summary>
 /// <param name="metaData">当前结点</param>
 /// <param name="list">保存集合的链表</param>
 public void GetNextNode(FlowChartMetaData metaData, List <FlowChartMetaData> list)
 {
     foreach (FlowChartMetaData m in metaData.NextMetaDataList)
     {
         foreach (FlowChartMetaData n in m.NextMetaDataList)
         {
             list.Add(n);
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取事件的结点的名字
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <returns>结点的名字</returns>
        public string GetNodeName(int i, int j)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData  = list[j - 1];

            string nodeName = metaData.DataType + "_" + flowChartID + "_" + metaData.ID;

            return(nodeName);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取事件的的节点的连接线连接的后续节点类型是否结束节点
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <param name="k">连接线的序号</param>
        /// <returns>是否是结束结点</returns>
        public bool IsNextNodeFinish(int i, int j, int k)
        {
            FlowChartMetaData        eventNode   = entranceNodeList[i - 1];
            List <FlowChartMetaData> list        = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData    = list[j - 1];
            FlowChartMetaData        line        = metaData.NextMetaDataList[k - 1];
            FlowChartMetaData        newMetaData = line.NextMetaDataList[0];

            bool result = newMetaData.DataType == "EndNode";

            return(result);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取事件的显示文本
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <returns>显示文本</returns>
        public string GetEventText(int i)
        {
            FlowChartMetaData eventNode = entranceNodeList[i - 1];
            string            text      = eventNode.DisplayText;

            if (text == null)
            {
                text = "";
            }

            return(text);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 获取事件的结点的显示文本
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <returns>显示文本</returns>
        public string GetNodeText(int i, int j)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;
            FlowChartMetaData        metaData  = list[j - 1];
            string text = metaData.DisplayText;

            if (text == null)
            {
                text = "";
            }

            return(text);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 将所有后续元数据加入链表
        /// </summary>
        /// <param name="metaData">当前元数据</param>
        /// <param name="list">保存元数据的链表</param>
        private void GetNodeNames(FlowChartMetaData metaData, List <FlowChartMetaData> list)
        {
            if (!list.Contains(metaData))
            {
                if (metaData.DataType != "Line" && metaData.DataType != "AILine")
                {
                    list.Add(metaData);
                }

                foreach (FlowChartMetaData d in metaData.NextMetaDataList)
                {
                    GetNodeNames(d, list);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 获取事件的所有的节点的名字
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <returns>所有结点的名字</returns>
        public string GetNodeNames(int i)
        {
            FlowChartMetaData        eventNode = entranceNodeList[i - 1];
            List <FlowChartMetaData> list      = eventTable[eventNode] as List <FlowChartMetaData>;

            string nodeNames = "";

            foreach (FlowChartMetaData metaData in list)
            {
                nodeNames += metaData.DataType + "_" + flowChartID + "_" + metaData.ID + ", ";
            }
            nodeNames = nodeNames.TrimEnd(new char[] { ',', ' ' });

            return(nodeNames);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 获取事件的节点的后续连接线的数量
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <param name="j">结点的序号</param>
        /// <returns>结点后续连接线的数量</returns>
        public int GetNextConnetionCount(int i, int j)
        {
            FlowChartMetaData eventNode = entranceNodeList[i - 1];
            int count;

            if (j == 0) // 直接取入口结点
            {
                count = eventNode.NextMetaDataList.Count;
            }
            else
            {
                List <FlowChartMetaData> list     = eventTable[eventNode] as List <FlowChartMetaData>;
                FlowChartMetaData        metaData = list[j - 1];
                count = metaData.NextMetaDataList.Count;
            }

            return(count);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 获取当前结点下一个结点的集合
 /// </summary>
 /// <param name="metaData">当前结点</param>
 /// <param name="list">保存集合的链表</param>
 public void GetNextNode(FlowChartMetaData metaData, List<FlowChartMetaData> list)
 {
     foreach(FlowChartMetaData m in metaData.NextMetaDataList)
     {
         foreach(FlowChartMetaData n in m.NextMetaDataList)
         {
             list.Add(n);
         }
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 将所有后续元数据加入链表
 /// </summary>
 /// <param name="metaData">当前元数据</param>
 /// <param name="list">保存元数据的链表</param>
 private void GetNodeNames(FlowChartMetaData metaData, List<FlowChartMetaData> list)
 {
     if(!list.Contains(metaData))
     {
         if(metaData.DataType != "Line" && metaData.DataType != "AILine")
         {
             list.Add(metaData);
         }
         
         foreach(FlowChartMetaData d in metaData.NextMetaDataList)
         {
             GetNodeNames(d, list);
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取下一个绘图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">绘图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">流程图索引哈希表</param>
        /// <param name="actionsTable">动作组数据哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable, Hashtable actionsTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, true);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetCompileData(g);
                DataElement dataElement =  dataManager.GetCompileDataElement(g);

                if (!graphElementList.Contains(g))
                {                    
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.DisplayText = g.Text;                    
                    
                    if (g is AIStateGraphElement) // 状态
                    {
                        string stateNodeName = CodeProviderClass.GetStateString(data);
                        newMetaData.Code = stateNodeName;

                        InitSetStateMetaData(metaData, newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);
                    }
                    else if (g is AILineGraphElement) // 连接线
                    {
                        newMetaData.Code = CodeProviderClass.GetEventString(data);

                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);                        
                    }
                    else if (g is AIActionGraphElement) // 动作
                    {
                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);
                    }
                    else if (g is AIActionsGraphElement) // 动作组
                    {                    
                        List<FlowChartMetaData> metaDataList = actionsTable[g] as List<FlowChartMetaData>;

                        metaDataList[0].AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(metaDataList[0]);

                        FindNextMetaData(dataManager, g, metaDataList[metaDataList.Count - 1], graphElementList, graphElementTable, actionsTable);
                    }
                }
                else
                {
                    if (g is AIActionsGraphElement) // 动作组要特殊处理
                    {
                        List<FlowChartMetaData> metaDataList = actionsTable[g] as List<FlowChartMetaData>;
                        metaDataList[0].AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(metaDataList[0]);
                    }
                    else if (g is AIStateGraphElement) // 状态结点要特殊处理
                    {
                        FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;

                        InitSetStateMetaData(metaData, newMetaData);
                    }
                    else
                    {
                        FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                    }                    
                }
            }                      
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 获取设置状态的绘图元数据
        /// </summary>
        /// <param name="previousMetaData">前一个元数据</param>
        /// <param name="stateMetaData">状态元数据</param>
        private void InitSetStateMetaData(FlowChartMetaData previousMetaData, FlowChartMetaData stateMetaData)
        {
            FlowChartMetaData setStateMetaData = new FlowChartMetaData(maxID, null, "AISetStateNode");
            setStateMetaData.DisplayText = "设置状态";
            setStateMetaData.AddPreviousMetaData(previousMetaData);
            previousMetaData.AddNextMetaData(setStateMetaData);
            maxID++;

            FlowChartMetaData lineMetaData = new FlowChartMetaData(maxID, "1", "AILine");
            lineMetaData.DisplayText = "1";
            setStateMetaData.AddNextMetaData(lineMetaData);
            lineMetaData.AddPreviousMetaData(setStateMetaData);
            maxID++;

            lineMetaData.AddNextMetaData(stateMetaData);
            stateMetaData.AddPreviousMetaData(lineMetaData);            
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 获取流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">流程图插槽容器的链表</param>
        /// <returns>流程图元数据的链表</returns>
        protected override List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            // 初始化ID
            maxID = dataManager.CurrentFlowChartManager.CurrentGraphManager.IDIndex + 1;

            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();
            dataManager.InitCompileTable();

            Hashtable actionsTable = new Hashtable(); // 动作组数据哈希表

            // 预处理动作组结点
            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is AIActionsGraphElement)
                {
                    AIActionsGraphElement actionsGraphElement = slotContainer as AIActionsGraphElement;
                    List<FlowChartMetaData> actionsMetaDataList = GetActionsMetaDataList(dataManager, actionsGraphElement);
                    actionsTable[actionsGraphElement] = actionsMetaDataList;
                }
            }

            // 预处理子绘图结点
            AIStateGraphElement stateNode = null;            

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                // 所有子绘图的图元都重新分配ID
                if (slotContainer is InnerChart)
                {
                    InnerChart innerChart = slotContainer as InnerChart;
                    InnerChartEditor innerChartEditor = dataManager.GetDataElement(innerChart) as InnerChartEditor;
                    List<GraphElement> list = innerChartEditor.GraphElementList;

                    foreach (GraphElement graphElement in list)
                    {
                        graphElement.ID = maxID;
                        graphElement.Tag = innerChart.ID;
                        maxID++;

                        dataManager.AddCompileData(graphElement, innerChartEditor.GetDataElement(graphElement));

                        // 重命名名称                        
                        RenameGraphElement(dataManager, graphElement);

                        if (graphElement is AIStateGraphElement)
                        {
                            AIStateGraphElement aiStateGraphElement = graphElement as AIStateGraphElement;

                            if (aiStateGraphElement.IsInitialState)
                            {
                                stateNode = aiStateGraphElement;
                            }
                        }
                        else if (graphElement is AIActionsGraphElement)
                        {
                            AIActionsGraphElement actionsGraphElement = graphElement as AIActionsGraphElement;
                            List<FlowChartMetaData> actionsMetaDataList = GetActionsMetaDataList(dataManager, actionsGraphElement);
                            actionsTable[actionsGraphElement] = actionsMetaDataList;
                        }
                    }
                }
            }

            // 处理绘图结点
            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is AIStateGraphElement)
                {
                    AIStateGraphElement stateGraphElement = slotContainer as AIStateGraphElement;

                    if (stateGraphElement.IsInitialState)
                    {
                        stateNode = stateGraphElement;
                        break;
                    }                    
                }
            }

            if (stateNode != null)
            {
                object data = dataManager.GetCompileData(stateNode);
                DataElement dataElement = dataManager.GetCompileDataElement(stateNode);
                FlowChartMetaData metaData = new FlowChartMetaData(stateNode.ID, data, "AIStateNode");
                string stateNodeName = CodeProviderClass.GetStateString(data);

                metaData.Code = stateNodeName;
                metaData.DisplayText = stateNode.Text;
                FindNextMetaData(dataManager, stateNode, metaData, graphElementList, graphElementTable, actionsTable);
                metaDataList.Add(metaData);
            }

            return metaDataList;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取动作组的元数据链表
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="aiActionsGraphElement">动作组图元</param>
        /// <returns>动作组的元数据链表</returns>
        private List<FlowChartMetaData> GetActionsMetaDataList(DataManager dataManager, AIActionsGraphElement aiActionsGraphElement)
        {
            object data = dataManager.GetCompileData(aiActionsGraphElement);

            List<object> actions = CodeProviderClass.SplitMultiActionIntoSingle(data);
            List<FlowChartMetaData> actionsMetaDataList = new List<FlowChartMetaData>();

            // 把显示文本拆分
            List<string> displayTextList = new List<string>();
            string[] tempArray = aiActionsGraphElement.Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in tempArray)
            {
                displayTextList.Add(s.TrimEnd(new char[] { '\r' }).TrimStart(new char[] { '◆', ' ' }));
            }

            for (int i = 0; i < actions.Count; i++)
            {
                FlowChartMetaData actionMetaData = new FlowChartMetaData(maxID, actions[i], "AIActionNode");
                actionMetaData.DisplayText = displayTextList[i];
                actionsMetaDataList.Add(actionMetaData);
                maxID++;
            }

            for (int i = 0; i < actions.Count - 1; i++)
            {
                FlowChartMetaData actionMetaData = actionsMetaDataList[i];
                FlowChartMetaData nextMetaData = actionsMetaDataList[i + 1];

                FlowChartMetaData lineMetaData;
                int returnValueCount = CodeProviderClass.GetActionRetCount(actions[i]);

                for (int j = 1; j <= returnValueCount; j++)
                {
                    lineMetaData = new FlowChartMetaData(maxID, j.ToString(), "AILine");
                    lineMetaData.DisplayText = j.ToString();
                    actionMetaData.AddNextMetaData(lineMetaData);
                    lineMetaData.AddPreviousMetaData(actionMetaData);
                    lineMetaData.AddNextMetaData(nextMetaData);
                    nextMetaData.AddPreviousMetaData(lineMetaData);

                    maxID++;
                }
            }

            return actionsMetaDataList;
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 添加连入流程图的元数据
 /// </summary>
 /// <param name="metaData">元数据</param>
 public void AddPreviousMetaData(FlowChartMetaData metaData)
 {
     if(!previousMetaDataList.Contains(metaData))
     {
         previousMetaDataList.Add(metaData);
     }
 }
Ejemplo n.º 24
0
Archivo: Main.cs Proyecto: viticm/pap2
        private List<string> customFunctionList = new List<string>(); // 自定义动作脚本链表

        /// <summary>
        /// 生成代码主体
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="metaData">流程图元数据</param>
        /// <param name="list">流程图元数据链表</param>
        private void GenerateCode(StringBuilder code, FlowChartMetaData metaData, List<FlowChartMetaData> list)
        {
            if(!list.Contains(metaData))
            {
                list.Add(metaData);

                switch(metaData.DataType)
                {
                    case "AIStateNode": // AI状态结点
                        {
                            code.AppendLine(string.Format("    -- {0}", metaData.DisplayText));
                            code.AppendLine(string.Format("    state = ai.NewState({0})", 
                                            metaData.Code));

                            List<FlowChartMetaData> nextMetaDataList = new List<FlowChartMetaData>();

                            foreach (FlowChartMetaData aiLine in metaData.NextMetaDataList)
                            {
                                code.AppendLine(string.Format("    state.HandleEvent({0}, {1})",
                                                CodeProviderClass.GetEventString(aiLine.Data), aiLine.NextMetaDataList[0].ID));
                                nextMetaDataList.Add(aiLine.NextMetaDataList[0]);
                            }

                            code.AppendLine();

                            foreach (FlowChartMetaData nextMetaData in nextMetaDataList)
                            {
                                GenerateCode(code, nextMetaData, list);
                            }                            

                            break;
                        }
                    case "AIActionNode": // AI动作结点
                        {
                            if(metaData.DisplayText != "")
                            {
                                code.AppendLine(string.Format("    -- {0}", metaData.DisplayText));
                            }
                            
                            string[] information = CodeProviderClass.GetActionInformation(metaData.Data);
                            int actionID = int.Parse(information[2]);

                            if(actionID > 1000) // 自定义动作
                            {
                                code.AppendLine(string.Format("    action = ai.NewAction({0}, {1})",
                                                              metaData.ID, information[2]));

                                if (actionID > 2000) // ID大于2000的Action为本文件内自定义动作
                                {
                                    customFunctionList.Add(information[3]);
                                }
                            }                            
                            else // 系统动作
                            {
                                code.AppendLine(string.Format("    action = ai.NewAction({0}, AI_ACTION.{1})",
                                    metaData.ID, information[0]));
                            }                            

                            if(information[1] != "")
                            {                                
                                code.AppendLine(string.Format("    action.SetParam({0})", information[1]));
                            }                            
                            
                            List<FlowChartMetaData> nextMetaDataList = new List<FlowChartMetaData>();
                            SortedList<string, string> sortedList = new SortedList<string, string>();

                            foreach(FlowChartMetaData aiLine in metaData.NextMetaDataList)
                            {
                                sortedList.Add(aiLine.Data as string, aiLine.NextMetaDataList[0].ID.ToString());
                                nextMetaDataList.Add(aiLine.NextMetaDataList[0]);
                            }
                            
                            string branchArgs = "";

                            for(int i = 0; i < sortedList.Count; i++)
                            {
                                branchArgs += string.Format("{0}, ", sortedList.Values[i]);
                                
                            }

                            branchArgs = branchArgs.TrimEnd(new char[] { ',', ' ' });                                                        

                            if(branchArgs != "")
                            {
                                code.AppendLine(string.Format("    action.SetBranch({0})", branchArgs));
                            }

                            // 注册调试输出
                            code.AppendLine(string.Format("    g_AIDebugInfo[{0}] = '[{0}] {1}({2})'", metaData.ID.ToString(),
                                                          information[0], information[1].Replace("'", "")));
                            code.AppendLine();
                            
                            foreach(FlowChartMetaData nextMetaData in nextMetaDataList)
                            {
                                GenerateCode(code, nextMetaData, list);
                            }

                            break;
                        }
                    case "AISetStateNode": // AI状态转换结点
                        {
                            code.AppendLine(string.Format("    -- {0}", metaData.DisplayText));
                            code.AppendLine(string.Format("    action = ai.NewAction({0}, AI_ACTION.SET_STATE)", metaData.ID));
                            code.AppendLine(string.Format("    action.SetParam({0})", metaData.NextMetaDataList[0].NextMetaDataList[0].Code));

                            // 注册调试输出
                            code.AppendLine(string.Format("    g_AIDebugInfo[{0}] = '[{0}] SetParam({1})'", metaData.ID.ToString(),
                                                          metaData.NextMetaDataList[0].NextMetaDataList[0].Code));
                            code.AppendLine();

                            GenerateCode(code, metaData.NextMetaDataList[0].NextMetaDataList[0], list);

                            break;
                        }
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 获取事件元数据
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <returns>事件元数据</returns>
        public FlowChartMetaData GetEventNode(int i)
        {
            FlowChartMetaData eventNode = entranceNodeList[i - 1];

            return(eventNode);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取下一个流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">流程图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">流程图索引哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, false);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetData(g);                
                
                if(!graphElementList.Contains(g))
                {
                    DataElement dataElement = dataManager.GetDataElement(g);
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.Code = CodeProvider.CodeProviderClass.ConvertToCode(data, dataElement.DataType);
                    newMetaData.DisplayText = g.TooltipText;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                    FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable);
                }
                else
                {
                    FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                }
            }

            if (graphElement is ConditionGraphElement) // 条件结点
            {
                bool avail = true; // 是否需要生成else连接线

                foreach(GraphElement g in list)
                {
                    if(dataManager.GetData(g) == null) // 找到else连接线
                    {
                        avail = false;
                        break;
                    }
                }

                if(avail) // 需要生成else连接线
                {
                    FlowChartMetaData lineMetaData = new FlowChartMetaData(0, null, "Line");
                    lineMetaData.Code = "";
                    lineMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(lineMetaData);
                    FlowChartMetaData endMetaData = new FlowChartMetaData(0, null, "EndNode");
                    endMetaData.AddPreviousMetaData(lineMetaData);
                    lineMetaData.AddNextMetaData(endMetaData);
                }
                else // 连接线需要重排序
                {
                    List<GraphElement> lineList = new List<GraphElement>();
                    GraphElement elseLine = null;
                    FlowChartMetaData newMetaData;

                    foreach(GraphElement g in list)
                    {
                        if(dataManager.GetData(g) == null) // else连接线
                        {
                            elseLine = g;
                        }
                        else // 普通连接线
                        {
                            lineList.Add(g);
                        }
                    }

                    metaData.ClearNextMetaDataList();
                    foreach(GraphElement g in lineList)
                    {
                        newMetaData = graphElementTable[g] as FlowChartMetaData;
                        metaData.AddNextMetaData(newMetaData);
                    }
                    newMetaData = graphElementTable[elseLine] as FlowChartMetaData;
                    metaData.AddNextMetaData(newMetaData);
                }
            }
            else
            {
                if(list.Count == 0) // 当前图元没有后续图元
                {
                    FlowChartMetaData lineMetaData = new FlowChartMetaData(0, null, "Line");
                    lineMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(lineMetaData);
                    FlowChartMetaData endMetaData = new FlowChartMetaData(0, null, "EndNode");
                    endMetaData.AddPreviousMetaData(lineMetaData);
                    lineMetaData.AddNextMetaData(endMetaData);
                }
            }                        
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 获取图元数据链表
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">插槽容器链表</param>
        /// <returns>图元数据链表</returns>
        protected virtual List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer.IsEntrance)
                {
                    object data = dataManager.GetData(slotContainer);
                    DataElement dataElement = dataManager.GetDataElement(slotContainer);
                    FlowChartMetaData metaData = new FlowChartMetaData(slotContainer.ID, data, slotContainer.TypeString);
                    metaData.DisplayText = slotContainer.TooltipText;
                    FindNextMetaData(dataManager, slotContainer, metaData, graphElementList, graphElementTable);
                    metaDataList.Add(metaData);
                }
            }

            return metaDataList;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 获取下一个图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">绘图索引哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, false);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetData(g);

                if (!graphElementList.Contains(g))
                {
                    DataElement dataElement = dataManager.GetDataElement(g);
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.DisplayText = g.TooltipText;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                    FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable);
                }
                else
                {
                    FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                }
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 添加连出流程图的元数据
 /// </summary>
 /// <param name="metaData">元数据</param>
 public void AddNextMetaData(FlowChartMetaData metaData)
 {
     if(!nextMetaDataList.Contains(metaData))
     {
         nextMetaDataList.Add(metaData);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 获取事件的内容
        /// </summary>
        /// <param name="i">事件的序号</param>
        /// <returns>事件的内容</returns>
        public object GetEventData(int i)
        {
            FlowChartMetaData eventNode = entranceNodeList[i - 1];

            return(eventNode.Data);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 获取流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">流程图插槽容器的链表</param>
        /// <returns>流程图元数据的链表</returns>
        protected override List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is EventGraphElement)
                {
                    object data = dataManager.GetData(slotContainer);
                    DataElement dataElement = dataManager.GetDataElement(slotContainer);
                    FlowChartMetaData metaData = new FlowChartMetaData(slotContainer.ID, data, "EventNode");
                    metaData.Code = CodeProvider.CodeProviderClass.ConvertToCode(data, dataElement.DataType);
                    metaData.DisplayText = slotContainer.TooltipText;
                    FindNextMetaData(dataManager, slotContainer, metaData, graphElementList, graphElementTable);
                    metaDataList.Add(metaData);
                }
            }

            return metaDataList;
        }