Ejemplo n.º 1
0
 public IValue <object> CalcValue(ScriptableData.ISyntaxComponent param)
 {
     if (param.IsValid() && param.GetId().Length == 0)
     {
         //处理括弧
         ScriptableData.CallData callData = param as ScriptableData.CallData;
         if (null != callData && callData.GetParamNum() > 0)
         {
             int ct = callData.GetParamNum();
             return(CalcValue(callData.GetParam(ct - 1)));
         }
         else
         {
             //不支持的语法
             return(null);
         }
     }
     else
     {
         IValue <object> ret = null;
         string          id  = param.GetId();
         IValueFactory   factory;
         if (m_ValueHandlers.TryGetValue(id, out factory))
         {
             ret = factory.Build(param);
         }
         return(ret);
     }
 }
Ejemplo n.º 2
0
 public IStoryValue <object> CalcValue(ScriptableData.ISyntaxComponent param)
 {
     if (param.IsValid() && param.GetId().Length == 0)
     {
         //处理括弧
         ScriptableData.CallData callData = param as ScriptableData.CallData;
         if (null != callData && callData.GetParamNum() > 0)
         {
             int ct = callData.GetParamNum();
             return(CalcValue(callData.GetParam(ct - 1)));
         }
         else
         {
             //不支持的语法
             return(null);
         }
     }
     else
     {
         IStoryValue <object> ret = null;
         string id = param.GetId();
         if (m_dicValueHandlers.ContainsKey(id))
         {
             ret = m_dicValueHandlers[id].Build(param);
         }
         return(ret);
     }
 }
Ejemplo n.º 3
0
        public void InitFromDsl(ScriptableData.ISyntaxComponent param)
        {
            string id     = param.GetId();
            int    idType = param.GetIdType();

            if (idType == ScriptableData.ValueData.ID_TOKEN && id.StartsWith("$"))
            {
                if (0 == id.CompareTo("$$"))
                {
                    SetArgument(c_Iterator);
                }
                else
                {
                    SetArgument(int.Parse(id.Substring(1)));
                }
            }
            else if (idType == ScriptableData.ValueData.ID_TOKEN && id.StartsWith("@"))
            {
                if (id.StartsWith("@@"))
                {
                    SetGlobal(id);
                }
                else
                {
                    SetLocal(id);
                }
            }
            else
            {
                CalcInitValue(param);
            }
        }
    /// <summary>
    /// 创建一个命令
    /// </summary>
    /// <param name="commandConfig"></param>
    /// <returns></returns>
    public IStoryCommand CreateCommand(ScriptableData.ISyntaxComponent commandConfig)
    {
        IStoryCommand        command = null;
        string               type    = commandConfig.GetId();
        IStoryCommandFactory factory = GetFactory(type);

        if (factory != null)
        {
            command = factory.Create(commandConfig);
        }
        else
        {
            m_log.Error("创建命令失败,命令类型:" + type);
        }
        return(command);
    }
Ejemplo n.º 5
0
        public ICommand CreateCommand(ScriptableData.ISyntaxComponent commandConfig)
        {
            ICommand        command = null;
            string          type    = commandConfig.GetId();
            ICommandFactory factory = GetFactory(type);

            if (null != factory)
            {
                command = factory.Create(commandConfig);
            }
            else
            {
                LogUtil.Debug("CreateCommand failed, unknown type:{0}.", type);
            }
            return(command);
        }
Ejemplo n.º 6
0
        public ISkillTriger CreateTriger(ScriptableData.ISyntaxComponent trigerConfig)
        {
            ISkillTriger        triger  = null;
            string              type    = trigerConfig.GetId();
            ISkillTrigerFactory factory = GetFactory(type);

            if (null != factory)
            {
                triger = factory.Create(trigerConfig);
            }
            else if (GlobalVariables.Instance.IsClient)
            {
                LogSystem.Error("CreateTriger failed, unkown type:{0}", type);
            }
            if (null != triger)
            {
                //DashFire.LogSystem.Debug("CreateTriger, type:{0} triger:{1}", type, triger.GetType().Name);
            }
            return(triger);
        }
Ejemplo n.º 7
0
        private void CalcInitValue(ScriptableData.ISyntaxComponent param)
        {
            IValue <object> val = ValueManager.Instance.CalcValue(param);

            if (null != val)
            {
                //对初始化即能求得值的函数,不需要再记录函数表达式,直接转换为常量值。
                if (val.HaveValue)
                {
                    SetValue(val.Value);
                }
                else
                {
                    SetProxy(val);
                }
            }
            else
            {
                string id     = param.GetId();
                int    idType = param.GetIdType();
                if (idType == ScriptableData.ValueData.NUM_TOKEN)
                {
                    if (id.IndexOf('.') >= 0)
                    {
                        SetValue(float.Parse(id, System.Globalization.NumberStyles.Float));
                    }
                    else if (id.StartsWith("0x"))
                    {
                        SetValue(uint.Parse(id.Substring(2), System.Globalization.NumberStyles.HexNumber));
                    }
                    else
                    {
                        SetValue(int.Parse(id, System.Globalization.NumberStyles.Integer));
                    }
                }
                else
                {
                    SetValue(id);
                }
            }
        }