Beispiel #1
0
    private void LoadSyntaxScript()
    {
        this.m_ScenarioSyntax.Clear();
        TextAsset       asset           = Resources.Load("Scripts/Scenario/ScenarioSyntax") as TextAsset;
        TextAssetParser textAssetParser = new TextAssetParser(asset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Syntax")
            {
                ScenarioSyntaxData scenarioSyntaxData = new ScenarioSyntaxData();
                scenarioSyntaxData.m_Encoded = key.GetVariable(1).SValue;
                this.m_ScenarioSyntax.Add(key.GetVariable(0).SValue, scenarioSyntaxData);
            }
        }
    }
    public ScenarioSyntaxData EncodeContent(string content)
    {
        if (content == null || content.Length == 0)
        {
            return(null);
        }
        if (this.m_ScenarioSyntax.Count == 0)
        {
            this.LoadSyntaxScript();
        }
        string[] array = content.Split(new char[]
        {
            ':'
        });
        ScenarioSyntaxData result = null;

        if (!this.m_ScenarioSyntax.TryGetValue(array[0], out result))
        {
            return(null);
        }
        return(result);
    }
Beispiel #3
0
 public void Load(Key key)
 {
     this.m_Name        = key.GetVariable(0).SValue;
     this.m_State       = ((!key.GetVariable(1).BValue) ? ScenarioNode.State.Inactive : ScenarioNode.State.None);
     this.m_ParentNames = key.GetVariable(6).SValue;
     if (this.m_ParentNames == ScenarioNode.NO_PARENTS)
     {
         this.m_ParentNames = string.Empty;
     }
     this.m_Loop = key.GetVariable(7).BValue;
     for (int i = 0; i < key.GetKeysCount(); i++)
     {
         Key key2 = key.GetKey(i);
         if (key2.GetName() == "Element")
         {
             string             svalue             = key2.GetVariable(0).SValue;
             ScenarioSyntaxData scenarioSyntaxData = ScenarioManager.Get().EncodeContent(svalue);
             if (scenarioSyntaxData == null)
             {
                 DebugUtils.Assert(string.Concat(new string[]
                 {
                     "[ScenarioNode:Load] Can't decode element - ",
                     svalue,
                     ", node - ",
                     this.m_Name,
                     ". Check spelling!"
                 }), true, DebugUtils.AssertType.Info);
             }
             else
             {
                 string[] array = scenarioSyntaxData.m_Encoded.Split(new char[]
                 {
                     ':'
                 });
                 DebugUtils.Assert(array.Length > 0, true);
                 ScenarioElement scenarioElement = this.CreateElement("Scenario" + array[0]);
                 if (scenarioElement == null)
                 {
                     DebugUtils.Assert("[ScenarioNode:Load] Can't create element - Scenario" + array[0], true, DebugUtils.AssertType.Info);
                 }
                 else
                 {
                     scenarioElement.m_Content        = svalue;
                     scenarioElement.m_EncodedContent = scenarioSyntaxData.m_Encoded;
                     array = svalue.Split(new char[]
                     {
                         ':'
                     });
                     for (int j = 1; j < array.Length; j++)
                     {
                         ScenarioElement scenarioElement2 = scenarioElement;
                         scenarioElement2.m_EncodedContent = scenarioElement2.m_EncodedContent + ":" + array[j];
                     }
                     scenarioElement.m_And  = key2.GetVariable(1).BValue;
                     scenarioElement.m_Node = this;
                     this.m_Elements.Add(scenarioElement);
                 }
             }
         }
     }
 }