コード例 #1
0
    /// <summary>
    /// 解析行为
    /// </summary>
    /// <param name="line">脚本行</param>
    /// <param name="tmpItem">行为生成类</param>
    /// <returns></returns>
    private static IFormulaItem TransBehavior(string line, IFormulaItem tmpItem)
    {
        // 解析内容
        // TODO 判断Formula的stack等级是否与当前stack等级一直? 不一致则新建将其加入上一级formula的子集
        // 参数列表内容
        var pos   = GetSmallBraketPos(line);
        var start = pos[0];
        var end   = pos[1];

        // 行为类型
        var type = line.Substring(0, start);
        // 行为参数
        var args = line.Substring(start + 1, end - start - 1);

        // 消除参数空格
        args = args.Replace(" ", "");
        // 使用参数+名称获取IFormula
        var item = GetFormula(type, args);
        // formula加入暂停item
        var pauseItem = GetFormula("Pause", "1");

        tmpItem = tmpItem == null ? pauseItem : tmpItem.After(pauseItem);
        tmpItem = tmpItem.After(item);

        return(tmpItem);
    }
コード例 #2
0
 /// <summary>
 /// 添加触发行为生成器
 /// </summary>
 /// <param name="formulaItem">行为单元生成器</param>
 public void AddActionFormulaItem(IFormulaItem formulaItem)
 {
     //if (formulaItem == null)
     //{
     //    throw new Exception("行为节点为空");
     //}
     if (actionFormulaItem == null)
     {
         actionFormulaItem = formulaItem;
     }
     else
     {
         actionFormulaItem.After(formulaItem);
     }
 }
コード例 #3
0
 /// <summary>
 /// 添加销毁行为生成器
 /// </summary>
 /// <param name="formulaItem">行为单元生成器</param>
 public void AddDetachFormulaItem(IFormulaItem formulaItem)
 {
     if (formulaItem == null)
     {
         throw new Exception("行为节点为空");
     }
     if (detachFormulaItem == null)
     {
         detachFormulaItem = formulaItem;
     }
     else
     {
         detachFormulaItem.After(formulaItem);
     }
 }