Пример #1
0
        public IValue <object> Clone()
        {
            SkillValue obj = new SkillValue();

            obj.m_ArgIndex   = m_ArgIndex;
            obj.m_LocalName  = m_LocalName;
            obj.m_GlobalName = m_GlobalName;
            if (null != m_Proxy)
            {
                obj.m_Proxy = m_Proxy.Clone();
            }
            obj.m_HaveValue = m_HaveValue;
            obj.m_Value     = m_Value;
            return(obj);
        }
Пример #2
0
 public bool Init(ScriptableData.ScriptableDataInfo config)
 {
     bool ret = false;
     ScriptableData.FunctionData skill = config.First;
     if (null != skill && (skill.GetId() == "skill" || skill.GetId() == "script"))
     {
         ret = true;
         ScriptableData.CallData callData = skill.Call;
         if (null != callData && callData.HaveParam())
         {
             m_Id = int.Parse(callData.GetParamId(0));
         }
         for (int i = 0; i < skill.Statements.Count; i++)
         {
             if (skill.Statements[i].GetId() == "local")
             {
                 ScriptableData.FunctionData sectionData = skill.Statements[i] as ScriptableData.FunctionData;
                 if (null != sectionData)
                 {
                     for (int j = 0; j < sectionData.Statements.Count; j++)
                     {
                         ScriptableData.CallData defData = sectionData.Statements[j] as ScriptableData.CallData;
                         if (null != defData && defData.HaveId() && defData.HaveParam())
                         {
                             string id = defData.GetId();
                             if (id.StartsWith("@") && !id.StartsWith("@@"))
                             {
                                 SkillValue val = new SkillValue();
                                 val.InitFromDsl(defData.GetParam(0));
                                 if (!m_PreInitedLocalVariables.ContainsKey(id))
                                 {
                                     m_PreInitedLocalVariables.Add(id, val.Value);
                                 }
                                 else
                                 {
                                     m_PreInitedLocalVariables[id] = val.Value;
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     LogUtil.Error("Story {0} DSL, local must be a function !", m_Id);
                 }
             }
             else if (skill.Statements[i].GetId() == "onmessage")
             {
                 ScriptableData.FunctionData sectionData = skill.Statements[i] as ScriptableData.FunctionData;
                 if (null != sectionData)
                 {
                     MessageHandler handler = new MessageHandler();
                     handler.Load(sectionData);
                     string msgId = handler.MessageId;
                     if (!m_MessageQueues.ContainsKey(msgId))
                     {
                         m_MessageHandlers.Add(handler);
                         m_MessageQueues.Add(msgId, new Queue<MessageInfo>());
                     }
                     else
                     {
                         LogUtil.Error("Story {0} DSL, onmessage {1} duplicate, discard it !", m_Id, msgId);
                     }
                 }
                 else
                 {
                     LogUtil.Error("Story {0} DSL, onmessage must be a function !", m_Id);
                 }
             }
             else
             {
                 LogUtil.Error("Instance::Init, unknown part {0}", skill.Statements[i].GetId());
             }
         }
     }
     else
     {
         LogUtil.Error("Instance::Init, isn't story DSL");
     }
     //LogSystem.Debug("Instance.Init message handler num:{0} {1}", m_MessageHandlers.Count, ret);
     return ret;
 }