Ejemplo n.º 1
0
 public void CopyFrom(ScriptableDataInfo other)
 {
     base.CopyFrom((StatementData)other);
     mLoaded       = other.mLoaded;
     mResourceName = other.mResourceName;
 }
Ejemplo n.º 2
0
 public void AddScriptableData(ScriptableDataInfo data)
 {
     mScriptableDatas.Add(data);
 }
Ejemplo n.º 3
0
    public bool Init(ScriptableData.ScriptableDataInfo config)
    {
        bool ret = false;

        ScriptableData.FunctionData story = config.First;
        if (story != null && (story.GetId() == "story" || story.GetId() == "script"))
        {
            ret = true;
            //参数
            ScriptableData.CallData callData = story.Call;
            if (callData != null && callData.HaveParam())
            {
                //第一个参数是剧情的id
                m_iStoryId = int.Parse(callData.GetParamId(0));
            }
            foreach (var info in story.Statements)
            {
                if (info.GetId() == "local")
                {
                    ScriptableData.FunctionData sectionData = info as ScriptableData.FunctionData;
                    if (null != sectionData)
                    {
                        foreach (ScriptableData.ISyntaxComponent def in sectionData.Statements)
                        {
                            ScriptableData.CallData defData = def as ScriptableData.CallData;
                            if (null != defData && defData.HaveId() && defData.HaveParam())
                            {
                                string id = defData.GetId();
                                if (id.StartsWith("@") && !id.StartsWith("@@"))
                                {
                                    StoryValue val = new StoryValue();
                                    val.InitFromDsl(defData.GetParam(0));
                                    if (!m_dicLocalVariables.ContainsKey(id))
                                    {
                                        m_dicLocalVariables.Add(id, val.Value);
                                    }
                                    else
                                    {
                                        m_dicLocalVariables[id] = val.Value;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.LogError("剧情" + m_iStoryId + "DSL语法,必须是个函数");
                    }
                }
                else if (info.GetId() == "onmessage")
                {
                    ScriptableData.FunctionData sectionData = info as ScriptableData.FunctionData;
                    if (null != sectionData)
                    {
                        StoryMessageHandler handler = new StoryMessageHandler();
                        handler.Load(sectionData);
                        m_listMessageHandlers.Add(handler);
                    }
                    else
                    {
                        Debug.LogError("剧情" + m_iStoryId + "DSL语法,必须是个函数");
                    }
                }
                else
                {
                    Debug.LogError("StoryInstance::Init,不知道DSL语法部分:" + info.GetId());
                }
            }
        }
        else
        {
            Debug.LogError("StoryInstance::Init,不是一个DSL语法");
        }
        return(ret);
    }