コード例 #1
0
        /// <summary>
        /// 把IL文件的一行解析为SceneActionPackage
        /// </summary>
        /// <param name="oneline">IL文件的行</param>
        /// <returns>动作序列包</returns>
        private SceneActionPackage ParseSceneActionPackage(string oneline)
        {
            SceneActionPackage sa;
            var lineitem = oneline.Split('^');

            if (lineitem.Length == IL_LINEITEM_NUM)
            {
                sa = new SceneActionPackage
                {
                    saNodeName   = lineitem[0],
                    aType        = (SActionType)Enum.Parse(typeof(SActionType), lineitem[0].Split('@')[1], false),
                    argsDict     = this.DispatchArgs(lineitem[1]),
                    condPolish   = this.DecodeString(lineitem[2]),
                    next         = lineitem[3],
                    trueRouting  = this.DispatchRouting(lineitem[4]),
                    falseRouting = this.DispatchRouting(lineitem[5]),
                    isBelongFunc = lineitem[6] == "1",
                    funcName     = lineitem[7],
                    aTag         = this.DecodeString(lineitem[8])
                };
            }
            else
            {
                LogUtils.LogLine("IL已损坏", "ILConvertor", LogLevel.Error);
                throw new Exception("IL损坏");
            }
            return(sa);
        }
コード例 #2
0
        /// <summary>
        /// 将IL解析为SAP
        /// </summary>
        private void ProcessIL()
        {
            this.ilPackageContainer = new Dictionary <string, Dictionary <string, SceneActionPackage> >();
            this.iResContainer      = new Dictionary <string, Dictionary <string, SceneAction> >();
            string currentSceneKey = String.Empty;

            foreach (string lineitem in this.splitContianer)
            {
                // 处理头部
                if (lineitem.StartsWith(">>>"))
                {
                    string mycommand = lineitem.Substring(3).Replace("\r\n", String.Empty);
                    // EOF标记
                    if (mycommand == "YuriEOF")
                    {
                        break;
                    }
                    // 场景标记
                    if (mycommand.StartsWith("YuriIL?"))
                    {
                        var commandItem = mycommand.Split('?');
                        currentSceneKey = commandItem[1];
                        this.ilPackageContainer.Add(currentSceneKey, new Dictionary <string, SceneActionPackage>());
                        this.iResContainer.Add(currentSceneKey, new Dictionary <string, SceneAction>());
                    }
                    else if (mycommand.StartsWith("YuriAEIL"))
                    {
                        var commandItem = mycommand.Split('?');
                        //GlobalDataContainer.GAME_PROJECT_NAME = commandItem[1];
                        //GlobalDataContainer.GAME_TITLE_NAME = commandItem[1];
                    }
                }
                else
                {
                    // sap
                    SceneActionPackage sap = this.ParseSceneActionPackage(lineitem);
                    this.ilPackageContainer[currentSceneKey].Add(sap.saNodeName, sap);
                    // sa
                    SceneAction sa = new SceneAction(sap);
                    this.iResContainer[currentSceneKey].Add(sa.NodeName, sa);
                }
            }
            LogUtils.LogLine("Finished Convert IL to SAP", "YuriIL Convertor", LogLevel.Normal);
        }
コード例 #3
0
        /// <summary>
        /// 处理动作项目为动作序列,封装成场景实例
        /// </summary>
        private List <Scene> ProcessSARelation()
        {
            var resList = new List <Scene>();

            foreach (var sapKvp in this.ilPackageContainer)
            {
                string sceneName     = sapKvp.Key;
                var    sapPool       = sapKvp.Value;
                var    saHeaderList  = new List <SceneAction>();
                var    yuriDict      = new Dictionary <string, SceneAction>();
                var    labelDictList = new List <Dictionary <string, SceneAction> >();
                foreach (var SAPPair in sapPool)
                {
                    var                labelDict = new Dictionary <string, SceneAction>();
                    string             nodename  = SAPPair.Key;
                    SceneActionPackage sap       = SAPPair.Value;
                    // 不脏的项目才入队展开
                    if (sap.dirtyBit == false)
                    {
                        saHeaderList.Add(this.iResContainer[sceneName][nodename]);
                        var openSet = new Queue <string>();
                        openSet.Enqueue(nodename);
                        // 广度优先遍历
                        while (openSet.Count != 0)
                        {
                            // 标记脏位
                            SceneActionPackage currentSAP = this.ilPackageContainer[sceneName][openSet.Dequeue()];
                            currentSAP.dirtyBit = true;
                            // 处理label字典
                            if (currentSAP.aType == SActionType.act_label)
                            {
                                labelDict[currentSAP.aTag] = this.iResContainer[sceneName][currentSAP.saNodeName];
                            }
                            // 处理next
                            if (!string.IsNullOrEmpty(currentSAP.next))
                            {
                                this.iResContainer[sceneName][currentSAP.saNodeName].Next =
                                    this.iResContainer[sceneName][currentSAP.next];
                            }
                            // 处理trueRouting
                            if (currentSAP.trueRouting.Count > 0)
                            {
                                this.iResContainer[sceneName][currentSAP.saNodeName].TrueRouting = new List <SceneAction>();
                                foreach (string trueSaName in currentSAP.trueRouting)
                                {
                                    this.iResContainer[sceneName][currentSAP.saNodeName].TrueRouting.Add(
                                        this.iResContainer[sceneName][trueSaName]);
                                    openSet.Enqueue(trueSaName);
                                }
                            }
                            // 处理falseRouting
                            if (currentSAP.falseRouting.Count > 0)
                            {
                                this.iResContainer[sceneName][currentSAP.saNodeName].FalseRouting = new List <SceneAction>();
                                foreach (string falseSaName in currentSAP.falseRouting)
                                {
                                    this.iResContainer[sceneName][currentSAP.saNodeName].FalseRouting.Add(
                                        this.iResContainer[sceneName][falseSaName]);
                                    openSet.Enqueue(falseSaName);
                                }
                            }
                            // 记录到Yuri向量
                            yuriDict.Add(currentSAP.saNodeName, this.iResContainer[sceneName][currentSAP.saNodeName]);
                        }
                        // 处理标签字典
                        labelDictList.Add(labelDict);
                    }
                }
                LogUtils.LogLine(String.Format("Finished SAP Relation Recovery: {0}", sceneName), "YuriIL Convertor", LogLevel.Normal);
                Scene parseScene = null;
                if (saHeaderList.Count > 0)
                {
                    SceneAction mainSa  = saHeaderList[0];
                    var         funcVec = new List <SceneFunction>();
                    for (int fc = 1; fc < saHeaderList.Count; fc++)
                    {
                        SceneAction fsa = saHeaderList[fc];
                        var         rsf = this.ParseSaToSF(fsa, sceneName);
                        rsf.LabelDictionary = labelDictList[fc];
                        funcVec.Add(rsf);
                    }
                    parseScene = new Scene(sceneName, mainSa, funcVec, labelDictList[0])
                    {
                        YuriDict = yuriDict
                    };
                }
                resList.Add(parseScene);
                LogUtils.LogLine(String.Format("Finished SAP Function Recovery: {0}", sceneName), "YuriIL Convertor", LogLevel.Normal);
            }
            return(resList);
        }