Exemplo n.º 1
0
        private void LoadGoalScript(string script_name, int index)
        {
            List <TextAssetParser> list = new List <TextAssetParser>();
            TextAsset textAsset         = Resources.Load("Scripts/AI/" + script_name + "Goals") as TextAsset;

            if (textAsset)
            {
                TextAssetParser textAssetParser = new TextAssetParser(textAsset);
                list.Add(textAssetParser);
                this.m_GoalParsersByName.Add(script_name, textAssetParser);
                Resources.UnloadAsset(textAsset);
            }
            else
            {
                for (int i = 0; i < 9999; i++)
                {
                    AI.AIID aiid = (AI.AIID)index;
                    string  text = aiid.ToString() + "Goals_" + i.ToString();
                    textAsset = (Resources.Load("Scripts/AI/" + text) as TextAsset);
                    if (!textAsset)
                    {
                        break;
                    }
                    TextAssetParser textAssetParser2 = new TextAssetParser(textAsset);
                    list.Add(textAssetParser2);
                    this.m_GoalParsersByName.Add(text, textAssetParser2);
                    Resources.UnloadAsset(textAsset);
                }
            }
            this.m_GoalParsers.Add(index, list);
        }
Exemplo n.º 2
0
        public override void Initialize()
        {
            base.Initialize();
            this.m_WantedBlend       = this.DEFAULT_BLEND;
            this.m_WantedAttackBlend = this.DEFAULT_BLEND;
            TextAssetParser textAssetParser = AIManager.Get().m_AnimatorDataParsers[this.GetStatesDataScript()];

            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "State")
                {
                    StateData stateData = new StateData();
                    stateData.m_ClipName = key.GetVariable(1).SValue;
                    stateData.m_Duration = key.GetVariable(2).FValue;
                    stateData.m_Loop     = (key.GetVariable(3).IValue != 0);
                    this.m_StatesData.Add(key.GetVariable(0).SValue, stateData);
                    this.m_StateNames.Add(key.GetVariable(0).SValue);
                    if (!this.m_HasSpecificIdle)
                    {
                        this.m_HasSpecificIdle = key.GetVariable(0).SValue.Contains("SpecificIdle");
                    }
                }
            }
        }
Exemplo n.º 3
0
    private void LoadScript()
    {
        this.m_PocketPosition = new Vector3[5];
        this.m_PocketRotation = new Quaternion[5];
        string    str       = (Mathf.Floor(Camera.main.aspect * 10f) / 10f).ToString();
        TextAsset textAsset = Resources.Load("Scripts/Backpack" + str) as TextAsset;

        if (!textAsset)
        {
            textAsset = (Resources.Load("Scripts/Backpack") as TextAsset);
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Transform")
            {
                int num = (int)Enum.Parse(typeof(BackpackPocket), key.GetVariable(0).SValue);
                this.m_PocketPosition[num].x = key.GetVariable(1).FValue;
                this.m_PocketPosition[num].y = key.GetVariable(2).FValue;
                this.m_PocketPosition[num].z = key.GetVariable(3).FValue;
                this.m_PocketRotation[num].x = key.GetVariable(4).FValue;
                this.m_PocketRotation[num].y = key.GetVariable(5).FValue;
                this.m_PocketRotation[num].z = key.GetVariable(6).FValue;
                this.m_PocketRotation[num].w = key.GetVariable(7).FValue;
            }
        }
    }
Exemplo n.º 4
0
        private void InitializeBloodFXData()
        {
            string    path      = "Scripts/AI/BloodFXData";
            TextAsset textAsset = Resources.Load(path) as TextAsset;

            if (!textAsset)
            {
                DebugUtils.Assert("Can't load BloodFXData script!", true, DebugUtils.AssertType.Info);
                return;
            }
            TextAssetParser textAssetParser = new TextAssetParser(textAsset);

            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "Blunt")
                {
                    List <string> value = new List <string>(key.GetVariable(0).SValue.Split(new char[]
                    {
                        ';'
                    }));
                    this.m_BloodFXNames.Add(0, value);
                }
                else if (key.GetName() == "Sharp")
                {
                    List <string> value2 = new List <string>(key.GetVariable(0).SValue.Split(new char[]
                    {
                        ';'
                    }));
                    this.m_BloodFXNames.Add(1, value2);
                }
            }
            Resources.UnloadAsset(textAsset);
        }
Exemplo n.º 5
0
        public TextAssetParser GetGoalParser(string name)
        {
            TextAssetParser result = null;

            this.m_GoalParsersByName.TryGetValue(name, out result);
            return(result);
        }
Exemplo n.º 6
0
    private void ParseScript(TextAsset script)
    {
        TextAssetParser textAssetParser = new TextAssetParser(script);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "PropFloat")
            {
                this.m_ReplicatedAnimatorParams.Add(new ReplicatedAnimator.AnimParam(key.GetVariable(0).SValue, typeof(float)));
            }
            else if (key.GetName() == "PropInt")
            {
                this.m_ReplicatedAnimatorParams.Add(new ReplicatedAnimator.AnimParam(key.GetVariable(0).SValue, typeof(int)));
            }
            else if (key.GetName() == "PropBool")
            {
                this.m_ReplicatedAnimatorParams.Add(new ReplicatedAnimator.AnimParam(key.GetVariable(0).SValue, typeof(bool)));
            }
            else if (key.GetName() == "DontInterruptState")
            {
                int key2 = Animator.StringToHash(key.GetVariable(0).SValue);
                if (!this.m_NonInterruptableStateSets.ContainsKey(key2))
                {
                    this.m_NonInterruptableStateSets.Add(key2, new HashSet <int>());
                }
                this.m_NonInterruptableStateSets[key2].Add(Animator.StringToHash(key.GetVariable(1).SValue));
            }
        }
    }
Exemplo n.º 7
0
    public static void LoadInfos(out Dictionary <int, ItemInfo> infos)
    {
        infos = new Dictionary <int, ItemInfo>();
        TextAsset textAsset = Resources.Load("Scripts/Items/Items") as TextAsset;

        DebugUtils.Assert(textAsset, true);
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key  key  = textAssetParser.GetKey(i);
            Type type = Type.GetType(key.GetVariable(1).SValue + "Info");
            if (type == null)
            {
                DebugUtils.Assert(DebugUtils.AssertType.Info);
            }
            else
            {
                ItemInfo itemInfo = Activator.CreateInstance(type) as ItemInfo;
                itemInfo.Load(key);
                infos.Add((int)itemInfo.m_ID, itemInfo);
            }
        }
        Resources.UnloadAsset(textAsset);
    }
Exemplo n.º 8
0
    private void Load(TextAsset asset)
    {
        TextAssetParser textAssetParser = new TextAssetParser();

        textAssetParser.Parse(asset);
        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "State")
            {
                this.CreateState(key, false);
            }
            else if (key.GetName() == "DefaultState")
            {
                this.CreateState(key, true);
            }
            else if (key.GetName() == "StateGroup")
            {
                this.CreateStateGroup(key);
            }
            else if (key.GetName() == "Transition")
            {
                this.CreateTransition(key);
            }
        }
    }
Exemplo n.º 9
0
        public override void Initialize(Being being)
        {
            base.Initialize(being);
            if (this.m_ActiveGoal != null)
            {
                this.m_ActiveGoal.Deactivate();
            }
            this.m_Goals.Clear();
            if (!AIManager.Get().m_GoalParsers.ContainsKey((int)this.m_AI.m_ID))
            {
                DebugUtils.Assert("[GoalsModule:Initialize] ERROR, missing goals parser of ai " + this.m_AI.m_ID.ToString(), true, DebugUtils.AssertType.Info);
                return;
            }
            TextAssetParser textAssetParser = null;

            if (this.m_AI.m_PresetName != string.Empty)
            {
                textAssetParser = AIManager.Get().GetGoalParser(this.m_AI.m_PresetName);
            }
            if (textAssetParser == null)
            {
                textAssetParser = AIManager.Get().GetRandomGoalsParser(this.m_AI.m_ID);
            }
            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "Goal")
                {
                    AIGoal aigoal = this.CreateGoal(key.GetVariable(0).SValue);
                    aigoal.m_Priority    = key.GetVariable(1).IValue;
                    aigoal.m_Probability = ((key.GetVariablesCount() > 2) ? key.GetVariable(2).FValue : 1f);
                    if (aigoal.m_Type == AIGoalType.HumanJumpBack || aigoal.m_Type == AIGoalType.JumpBack)
                    {
                        this.m_JumpBackGoal = aigoal;
                    }
                    else if (aigoal.m_Type == AIGoalType.HumanPunchBack || aigoal.m_Type == AIGoalType.PunchBack)
                    {
                        this.m_PunchBackGoal = aigoal;
                    }
                    else if (aigoal.m_Type == AIGoalType.HumanTaunt)
                    {
                        this.m_TauntGoal = aigoal;
                    }
                    this.m_Goals.Add(aigoal);
                }
                else
                {
                    DebugUtils.Assert("[GoalsModule::Initialize] Unknown keyword - " + key.GetName(), true, DebugUtils.AssertType.Info);
                }
            }
            if (this.m_GoalToActivate != AIGoalType.None)
            {
                this.ActivateGoal(this.m_GoalToActivate);
                this.m_GoalToActivate = AIGoalType.None;
            }
        }
Exemplo n.º 10
0
        private void InitFootstepsData()
        {
            for (int i = 0; i < 16; i++)
            {
                this.m_FootstepDatas.Add(i, new AIFootstepData());
            }
            TextAssetParser textAssetParser = new TextAssetParser(this.m_FootstepDataScript);

            for (int j = 0; j < textAssetParser.GetKeysCount(); j++)
            {
                Key             key  = textAssetParser.GetKey(j);
                EObjectMaterial key2 = (EObjectMaterial)Enum.Parse(typeof(EObjectMaterial), key.GetName());
                for (int k = 0; k < key.GetKeysCount(); k++)
                {
                    AIFootstepData aifootstepData = this.m_FootstepDatas[(int)key2];
                    Key            key3           = key.GetKey(k);
                    if (key3.GetName() == "FX")
                    {
                        string[] array = key3.GetVariable(0).SValue.Split(new char[]
                        {
                            ';'
                        });
                        for (int l = 0; l < array.Length; l++)
                        {
                            aifootstepData.m_FXNames.Add(array[l]);
                        }
                    }
                    else if (key3.GetName() == "Sound")
                    {
                        string   svalue = key3.GetVariable(0).SValue;
                        string[] array2 = key3.GetVariable(1).SValue.Split(new char[]
                        {
                            ';'
                        });
                        for (int m = 0; m < array2.Length; m++)
                        {
                            aifootstepData.m_WalkSounds.Add(Resources.Load <AudioClip>(svalue + array2[m]));
                        }
                        if (key3.GetVariablesCount() > 2)
                        {
                            array2 = key3.GetVariable(2).SValue.Split(new char[]
                            {
                                ';'
                            });
                            for (int n = 0; n < array2.Length; n++)
                            {
                                aifootstepData.m_RunSounds.Add(Resources.Load <AudioClip>(svalue + array2[n]));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
    private TextAssetParser GetParser()
    {
        TextAssetParser textAssetParser = null;

        if (this.m_HumanAI)
        {
            string  text = null;
            AI.AIID id   = this.m_HumanAI.m_ID;
            switch (id)
            {
            case AI.AIID.Hunter:
                text = "AI/SavageAnimEvents";
                break;

            case AI.AIID.Spearman:
                text = "AI/SpearmanAnimEvents";
                break;

            case AI.AIID.Thug:
                text = "AI/ThugAnimEvents";
                break;

            case AI.AIID.Savage:
                text = "AI/SavageAnimEvents";
                break;

            default:
                if (id == AI.AIID.KidRunner)
                {
                    text = "AI/KidRunnerAnimEvents";
                }
                break;
            }
            if (text != null && !AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.TryGetValue(text, out textAssetParser))
            {
                textAssetParser = new TextAssetParser();
                textAssetParser.Parse(text, true);
                AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.Add(text, textAssetParser);
            }
        }
        else if (this.m_AnimEventsScript != null && !AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.TryGetValue(this.m_AnimEventsScript.name, out textAssetParser))
        {
            textAssetParser = new TextAssetParser(this.m_AnimEventsScript);
            AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.Add(this.m_AnimEventsScript.name, textAssetParser);
        }
        if (textAssetParser == null)
        {
            Debug.Log("Could not parse animation event script for: " + base.name);
            textAssetParser = new TextAssetParser();
        }
        return(textAssetParser);
    }
Exemplo n.º 12
0
 public static void PreParseAnimationEventScripts()
 {
     foreach (string text in AnimationEventsReceiver.s_ScriptsToPreparse)
     {
         TextAssetParser textAssetParser;
         if (!AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.TryGetValue(text, out textAssetParser))
         {
             textAssetParser = new TextAssetParser();
             textAssetParser.Parse(text, true);
             AnimationEventsReceiver.s_ParsedAnimEventScriptsCache.Add(text, textAssetParser);
         }
     }
 }
Exemplo n.º 13
0
    private void LoadScript()
    {
        TextAsset textAsset = Resources.Load(this.m_CocaineScript) as TextAsset;

        if (!textAsset)
        {
            DebugUtils.Assert("Can't load Sanity script - " + this.m_CocaineScript, true, DebugUtils.AssertType.Info);
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Duartion")
            {
                this.m_Duration = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "StaminaConsumptionMul")
            {
                this.m_StaminaConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "HPConsumptionMul")
            {
                this.m_HPConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "FatConsumptionMul")
            {
                this.m_FatConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "CarboConsumptionMul")
            {
                this.m_CarboConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "ProteinsConsumptionMul")
            {
                this.m_ProteinsConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "HydrationConsumptionMul")
            {
                this.m_HydrationConsumptionMul = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "IncreaseEnergyPerSec")
            {
                this.m_IncreaseEnergyPerSec = key.GetVariable(0).FValue;
            }
        }
        Resources.UnloadAsset(textAsset);
    }
Exemplo n.º 14
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);
            }
        }
    }
Exemplo n.º 15
0
    public void LoadScript()
    {
        string    text      = "Scripts/Player/Player_Sounds";
        TextAsset textAsset = Resources.Load(text) as TextAsset;

        if (DebugUtils.Assert(textAsset != null, "[PlayerAudioModule::LoadScript] ERROR - can't load script " + text, true, DebugUtils.AssertType.Info))
        {
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key       key   = textAssetParser.GetKey(i);
            string    text2 = "m_" + key.GetName() + "Sounds";
            FieldInfo field = base.GetType().GetField(text2);
            if (!DebugUtils.Assert(field != null, "[PlayerAudioModule::LoadScript] ERROR - can't find member - " + text2, true, DebugUtils.AssertType.Info))
            {
                List <AudioClip> list = new List <AudioClip>();
                for (int j = 0; j < key.GetVariablesCount(); j++)
                {
                    string    svalue    = key.GetVariable(j).SValue;
                    AudioClip audioClip = Resources.Load <AudioClip>("Sounds/Player/" + svalue);
                    if (!audioClip)
                    {
                        audioClip = Resources.Load <AudioClip>("Sounds/TempSounds/Player/" + svalue);
                    }
                    if (!audioClip)
                    {
                        audioClip = Resources.Load <AudioClip>("Sounds/PlayerVO/" + svalue);
                    }
                    if (!audioClip)
                    {
                        DebugUtils.Assert("[PlayerAudioModule::LoadScript] Can't load audio clip - " + svalue, true, DebugUtils.AssertType.Info);
                    }
                    else
                    {
                        list.Add(audioClip);
                    }
                }
                field.SetValue(this, list);
            }
        }
    }
Exemplo n.º 16
0
    public void LoadScript(string script_name)
    {
        if (MainLevel.Instance.m_GameMode == GameMode.Debug)
        {
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(Resources.Load(Scenario.s_ScriptPath + script_name) as TextAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Node")
            {
                ScenarioNode scenarioNode = new ScenarioNode();
                scenarioNode.Load(key);
                this.AddNode(scenarioNode);
            }
        }
    }
Exemplo n.º 17
0
    private void LoadTextures()
    {
        TextAsset textAsset = Resources.Load("Scripts/Cursors") as TextAsset;

        DebugUtils.Assert(textAsset, "ERROR - Missing Cursors script.", true, DebugUtils.AssertType.Info);
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Cursor")
            {
                CursorManager.TYPE key2      = (CursorManager.TYPE)Enum.Parse(typeof(CursorManager.TYPE), key.GetVariable(0).SValue);
                Texture2D          texture2D = Resources.Load <Texture2D>("Cursors/" + key.GetVariable(1).SValue);
                DebugUtils.Assert(texture2D != null, "ERROR - Missing cursor texture. TYPE = " + key2.ToString(), true, DebugUtils.AssertType.Info);
                this.m_TexturesMap.Add(key2, texture2D);
            }
        }
        Resources.UnloadAsset(textAsset);
    }
Exemplo n.º 18
0
 private void InitializeAnimatorDataParsers()
 {
     for (int i = 0; i < 44; i++)
     {
         List <TextAssetParser> list = new List <TextAssetParser>();
         AI.AIID   aiid      = (AI.AIID)i;
         string    text      = aiid.ToString() + "AnimatorData";
         TextAsset textAsset = Resources.Load("Scripts/AI/" + text) as TextAsset;
         if (textAsset)
         {
             TextAssetParser textAssetParser = new TextAssetParser(textAsset);
             list.Add(textAssetParser);
             this.m_AnimatorDataParsers.Add(text, textAssetParser);
             Resources.UnloadAsset(textAsset);
         }
         else
         {
             Debug.Log("Can't load animator data script - " + text);
         }
     }
 }
Exemplo n.º 19
0
    public void LoadScript()
    {
        Skill.s_Instances.Clear();
        TextAssetParser textAssetParser = new TextAssetParser(this.m_SkillsScript);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Skill")
            {
                string svalue = key.GetVariable(0).SValue;
                Type   type   = Type.GetType(svalue + "Skill");
                Skill  skill  = Activator.CreateInstance(type) as Skill;
                skill.Initialize(svalue);
                for (int j = 0; j < key.GetKeysCount(); j++)
                {
                    skill.Load(key.GetKey(j));
                }
                this.m_Skills.Add(skill);
            }
        }
    }
Exemplo n.º 20
0
        private void InitializeAIParams()
        {
            TextAsset textAsset = Resources.Load("Scripts/AI/AIData") as TextAsset;

            if (!textAsset)
            {
                DebugUtils.Assert("Can't load AIData script!", true, DebugUtils.AssertType.Info);
                return;
            }
            TextAssetParser textAssetParser = new TextAssetParser(textAsset);

            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "AI")
                {
                    AIParams aiparams = new AIParams();
                    aiparams.Load(key);
                    this.m_AIParamsMap.Add((int)Enum.Parse(typeof(AI.AIID), key.GetVariable(0).SValue), aiparams);
                }
            }
            Resources.UnloadAsset(textAsset);
        }
Exemplo n.º 21
0
 private void InitializeGoalParsers()
 {
     for (int i = 0; i < 39; i++)
     {
         List <TextAssetParser> list = new List <TextAssetParser>();
         AI.AIID   aiid      = (AI.AIID)i;
         string    text      = aiid.ToString() + "Goals";
         string    path      = "Scripts/AI/" + text;
         TextAsset textAsset = Resources.Load(path) as TextAsset;
         if (textAsset)
         {
             TextAssetParser textAssetParser = new TextAssetParser(textAsset);
             list.Add(textAssetParser);
             this.m_GoalParsersByName.Add(text, textAssetParser);
             Resources.UnloadAsset(textAsset);
         }
         else
         {
             for (int j = 0; j < 9999; j++)
             {
                 AI.AIID aiid2 = (AI.AIID)i;
                 text      = aiid2.ToString() + "Goals_" + j.ToString();
                 path      = "Scripts/AI/" + text;
                 textAsset = (Resources.Load(path) as TextAsset);
                 if (!textAsset)
                 {
                     break;
                 }
                 TextAssetParser textAssetParser2 = new TextAssetParser(textAsset);
                 list.Add(textAssetParser2);
                 this.m_GoalParsersByName.Add(text, textAssetParser2);
                 Resources.UnloadAsset(textAsset);
             }
         }
         this.m_GoalParsers.Add(i, list);
     }
 }
Exemplo n.º 22
0
    private void ParseClipsReplaceScript()
    {
        string text = base.GetType().ToString();

        text += "_ClipsReplace";
        TextAsset textAsset = Resources.Load("Scripts/Player/ClipsReplace/" + text) as TextAsset;

        if (!textAsset)
        {
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        if (this.m_ClipReplaceMap == null)
        {
            this.m_ClipReplaceMap = new Dictionary <string, List <KeyValuePair <string, string> > >();
        }
        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Item")
            {
                string svalue = key.GetVariable(0).SValue;
                this.m_ClipReplaceMap[svalue] = new List <KeyValuePair <string, string> >();
                for (int j = 0; j < key.GetKeysCount(); j++)
                {
                    Key key2 = key.GetKey(j);
                    if (key2.GetName() == "Clip")
                    {
                        KeyValuePair <string, string> item = new KeyValuePair <string, string>(key2.GetVariable(0).SValue, key2.GetVariable(1).SValue);
                        this.m_ClipReplaceMap[svalue].Add(item);
                    }
                }
            }
        }
    }
Exemplo n.º 23
0
    private void ParseClipsReplaceScript()
    {
        string text = base.GetType().ToString();

        text += "_ClipsReplace";
        TextAsset textAsset = Resources.Load("Scripts/Player/ClipsReplace/" + text) as TextAsset;

        if (!textAsset)
        {
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        if (PlayerController.NEW_ANIM_OVERRIDES)
        {
            AnimatorOverrideController animatorOverrideController = this.m_Animator.runtimeAnimatorController as AnimatorOverrideController;
            if (animatorOverrideController == null)
            {
                animatorOverrideController = new AnimatorOverrideController(this.m_Animator.runtimeAnimatorController);
                this.m_Animator.runtimeAnimatorController = animatorOverrideController;
            }
            if (this.m_ClipOverrides == null)
            {
                this.m_ClipOverrides = new Dictionary <string, List <KeyValuePair <AnimationClip, AnimationClip> > >();
            }
            for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
            {
                Key key = textAssetParser.GetKey(i);
                if (key.GetName() == "Item")
                {
                    string svalue = key.GetVariable(0).SValue;
                    this.m_ClipOverrides[svalue] = new List <KeyValuePair <AnimationClip, AnimationClip> >();
                    for (int j = 0; j < key.GetKeysCount(); j++)
                    {
                        Key key2 = key.GetKey(j);
                        if (key2.GetName() == "Clip")
                        {
                            AnimationClip key3  = animatorOverrideController[key2.GetVariable(0).SValue];
                            AnimationClip value = animatorOverrideController[key2.GetVariable(1).SValue];
                            this.m_ClipOverrides[svalue].Add(new KeyValuePair <AnimationClip, AnimationClip>(key3, value));
                        }
                    }
                }
            }
            return;
        }
        if (this.m_ClipReplaceMap == null)
        {
            this.m_ClipReplaceMap = new Dictionary <string, List <KeyValuePair <string, string> > >();
        }
        for (int k = 0; k < textAssetParser.GetKeysCount(); k++)
        {
            Key key4 = textAssetParser.GetKey(k);
            if (key4.GetName() == "Item")
            {
                string svalue2 = key4.GetVariable(0).SValue;
                this.m_ClipReplaceMap[svalue2] = new List <KeyValuePair <string, string> >();
                for (int l = 0; l < key4.GetKeysCount(); l++)
                {
                    Key key5 = key4.GetKey(l);
                    if (key5.GetName() == "Clip")
                    {
                        KeyValuePair <string, string> item = new KeyValuePair <string, string>(key5.GetVariable(0).SValue, key5.GetVariable(1).SValue);
                        this.m_ClipReplaceMap[svalue2].Add(item);
                    }
                }
            }
        }
    }
Exemplo n.º 24
0
 public void init()
 {
     introductionMC = TextAssetParser.parseTextAsset(introduction);
 }
Exemplo n.º 25
0
    private void SetupEvents()
    {
        AI ai = null;

        if (this.m_Being && this.m_Being.IsAI())
        {
            ai = base.GetComponent <AI>();
            if (ai.IsHuman())
            {
                this.m_HumanAI = (HumanAI)ai;
            }
            this.m_AudioSource.spatialize = true;
        }
        TextAssetParser parser        = this.GetParser();
        AnimationClip   animationClip = null;

        AnimationClip[] animationClips = this.m_Animator.runtimeAnimatorController.animationClips;
        for (int i = 0; i < parser.GetKeysCount(); i++)
        {
            Key key = parser.GetKey(i);
            if (key.GetName() == "Anim")
            {
                string svalue = key.GetVariable(0).SValue;
                foreach (AnimationClip animationClip2 in animationClips)
                {
                    if (animationClip2.name == svalue)
                    {
                        animationClip = animationClip2;
                        break;
                    }
                }
                if (!animationClip)
                {
                    DebugUtils.Assert(false, "Can't find player anim clip " + svalue, true, DebugUtils.AssertType.Info);
                }
                else
                {
                    AnimationEvent[] events = animationClip.events;
                    float            length = animationClip.length;
                    for (int k = 0; k < key.GetKeysCount(); k++)
                    {
                        Key key2 = key.GetKey(k);
                        if (key2.GetName() == "Event")
                        {
                            AnimEventID value = EnumUtils <AnimEventID> .GetValue(key2.GetVariable(0).SValue);

                            bool flag = false;
                            for (int l = 0; l < events.Length; l++)
                            {
                                if (events[l].intParameter == (int)value)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                float          fvalue         = key2.GetVariable(1).FValue;
                                AnimationEvent animationEvent = new AnimationEvent();
                                animationEvent.intParameter = (int)value;
                                animationEvent.time         = length * fvalue;
                                animationEvent.functionName = "AnimEvent";
                                animationClip.AddEvent(animationEvent);
                                List <AnimationEvent> list = null;
                                if (!this.m_Events.TryGetValue(Animator.StringToHash(svalue), out list))
                                {
                                    this.m_Events[Animator.StringToHash(svalue)] = new List <AnimationEvent>();
                                }
                                this.m_Events[Animator.StringToHash(svalue)].Add(animationEvent);
                            }
                        }
                        else if (key2.GetName() == "Sound")
                        {
                            string svalue2 = key2.GetVariable(0).SValue;
                            if (!this.m_Sounds.ContainsKey(svalue2))
                            {
                                this.m_Sounds[svalue2] = new List <AudioClip>();
                                string    text      = (ai && ai.m_SoundPreset != AI.SoundPreset.None) ? (ai.m_SoundPreset.ToString() + "/") : "";
                                AudioClip audioClip = Resources.Load <AudioClip>(string.Concat(new string[]
                                {
                                    "Sounds/",
                                    key2.GetVariable(1).SValue,
                                    "/",
                                    text,
                                    svalue2
                                }));
                                if (audioClip)
                                {
                                    this.m_Sounds[svalue2].Add(audioClip);
                                }
                                else
                                {
                                    for (int m = 1; m < 99; m++)
                                    {
                                        audioClip = Resources.Load <AudioClip>(string.Concat(new string[]
                                        {
                                            "Sounds/",
                                            key2.GetVariable(1).SValue,
                                            "/",
                                            text,
                                            svalue2,
                                            (m < 10) ? "0" : "",
                                            m.ToString()
                                        }));
                                        if (!audioClip)
                                        {
                                            break;
                                        }
                                        this.m_Sounds[svalue2].Add(audioClip);
                                    }
                                }
                            }
                            if (this.m_Sounds[svalue2].Count == 0)
                            {
                                DebugUtils.Assert("Missing clips of sound - " + svalue2, true, DebugUtils.AssertType.Info);
                            }
                            float num   = length * key2.GetVariable(2).FValue;
                            bool  flag2 = false;
                            for (int n = 0; n < events.Length; n++)
                            {
                                if (!(events[n].functionName != "SoundEvent") && events[n].stringParameter == svalue2 && events[n].time == num)
                                {
                                    flag2 = true;
                                    break;
                                }
                            }
                            if (!flag2)
                            {
                                animationClip.AddEvent(new AnimationEvent
                                {
                                    stringParameter = svalue2,
                                    time            = num,
                                    functionName    = "SoundEvent"
                                });
                            }
                        }
                        else if (key2.GetName() == "Footstep")
                        {
                            float  num2    = length * key2.GetVariable(0).FValue;
                            string svalue3 = key2.GetVariable(1).SValue;
                            if (!this.m_TransformsForFXesMap.ContainsKey(svalue3))
                            {
                                Transform transform = base.transform.FindDeepChild(svalue3);
                                DebugUtils.Assert(transform != null, "Can't find objects - " + svalue3, true, DebugUtils.AssertType.Info);
                                this.m_TransformsForFXesMap.Add(svalue3, transform);
                            }
                            bool flag3 = false;
                            for (int num3 = 0; num3 < events.Length; num3++)
                            {
                                if (!(events[num3].functionName != "FootstepEvent") && events[num3].stringParameter == svalue3 && events[num3].time == num2)
                                {
                                    flag3 = true;
                                    break;
                                }
                            }
                            if (!flag3)
                            {
                                animationClip.AddEvent(new AnimationEvent
                                {
                                    stringParameter = svalue3,
                                    time            = num2,
                                    functionName    = "FootstepEvent"
                                });
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 26
0
    private void LoadScript()
    {
        TextAsset textAsset = Resources.Load(this.m_SanityScript) as TextAsset;

        if (!textAsset)
        {
            DebugUtils.Assert("Can't load Sanity script - " + this.m_SanityScript, true, DebugUtils.AssertType.Info);
            return;
        }
        TextAssetParser textAssetParser = new TextAssetParser(textAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "ItemHallucinationsSanityLevel")
            {
                this.m_ItemHallucinationsSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "ItemHallucinationMinInterval")
            {
                this.m_ItemHallucinationMinInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "ItemHallucinationMaxInterval")
            {
                this.m_ItemHallucinationMaxInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "ItemHallucinationsMinCount")
            {
                this.m_ItemHallucinationsMinCount = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "ItemHallucinationsMaxCount")
            {
                this.m_ItemHallucinationsMaxCount = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "AIHallucinationsSanityLevel")
            {
                this.m_AIHallucinationsSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "AIHallucinationMinInterval")
            {
                this.m_AIHallucinationMinInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "AIHallucinationMaxInterval")
            {
                this.m_AIHallucinationMaxInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "AIHallucinationsMinCount")
            {
                this.m_AIHallucinationsMinCount = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "AIHallucinationsMaxCount")
            {
                this.m_AIHallucinationsMaxCount = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "StartEffectSanityLevel")
            {
                this.m_StartEffectSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "DisappearChatterChance")
            {
                this.m_DisappearChatterChance = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MinSpawnStalkerInterval")
            {
                this.m_MinSpawnStalkerInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MaxSpawnStalkerInterval")
            {
                this.m_MaxSpawnStalkerInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "WhispersSanityLevel")
            {
                this.m_WhispersSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "MinWhispersInterval")
            {
                this.m_MinWhispersInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MaxWhispersInterval")
            {
                this.m_MaxWhispersInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MinRandomWhispersInterval")
            {
                this.m_MinRandomWhispersInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MaxRandomWhispersInterval")
            {
                this.m_MaxRandomWhispersInterval = key.GetVariable(0).FValue;
            }
            else if (key.GetName() == "MaxWhispersQueue")
            {
                this.m_MaxWhispersQueue = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "Event")
            {
                string svalue = key.GetVariable(0).SValue;
                if (Enum.IsDefined(typeof(PlayerSanityModule.SanityEventType), svalue))
                {
                    PlayerSanityModule.SanityEventType key2 = (PlayerSanityModule.SanityEventType)Enum.Parse(typeof(PlayerSanityModule.SanityEventType), svalue);
                    this.m_EventsMap[(int)key2].m_SanityChange[0] = key.GetVariable(1).IValue;
                    this.m_EventsMap[(int)key2].m_SanityChange[1] = key.GetVariable(2).IValue;
                    this.m_EventsMap[(int)key2].m_SanityChange[2] = key.GetVariable(3).IValue;
                    this.m_EventsMap[(int)key2].m_Interval        = key.GetVariable(4).FValue;
                    this.m_EventsMap[(int)key2].m_TextID          = key.GetVariable(5).SValue;
                }
            }
            else if (key.GetName() == "StalkerStalkingSanityLevel")
            {
                this.m_StalkerStalkingSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "StalkerAttackSanityLevel")
            {
                this.m_StalkerAttackSanityLevel = key.GetVariable(0).IValue;
            }
            else if (key.GetName() == "Whisper")
            {
                PlayerSanityModule.WhisperType key3 = (PlayerSanityModule.WhisperType)Enum.Parse(typeof(PlayerSanityModule.WhisperType), key.GetVariable(0).SValue);
                for (int j = 0; j < key.GetKeysCount(); j++)
                {
                    Key key4 = key.GetKey(j);
                    if (key4.GetName() == "Clip")
                    {
                        AudioClip audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key4.GetVariable(0).SValue);
                        if (!audioClip)
                        {
                            audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key4.GetVariable(0).SValue);
                        }
                        if (!audioClip)
                        {
                            DebugUtils.Assert("Can't find clip - " + key4.GetVariable(0).SValue, true, DebugUtils.AssertType.Info);
                        }
                        if (!this.m_WhispersMap.ContainsKey((int)key3))
                        {
                            List <AudioClip> value = new List <AudioClip>();
                            this.m_WhispersMap.Add((int)key3, value);
                        }
                        this.m_WhispersMap[(int)key3].Add(audioClip);
                    }
                }
            }
            else if (key.GetName() == "DisappearItemSounds")
            {
                for (int k = 0; k < key.GetKeysCount(); k++)
                {
                    Key key5 = key.GetKey(k);
                    if (key5.GetName() == "Clip")
                    {
                        AudioClip audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key5.GetVariable(0).SValue);
                        if (!audioClip2)
                        {
                            audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key5.GetVariable(0).SValue);
                        }
                        if (!audioClip2)
                        {
                            DebugUtils.Assert("Can't find clip - " + key5.GetVariable(0).SValue, true, DebugUtils.AssertType.Info);
                        }
                        if (!this.m_DisappearItem.Contains(audioClip2))
                        {
                            this.m_DisappearItem.Add(audioClip2);
                        }
                    }
                }
            }
            else if (key.GetName() == "DisappearAISounds")
            {
                for (int l = 0; l < key.GetKeysCount(); l++)
                {
                    Key key6 = key.GetKey(l);
                    if (key6.GetName() == "Clip")
                    {
                        AudioClip audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key6.GetVariable(0).SValue);
                        if (!audioClip3)
                        {
                            audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key6.GetVariable(0).SValue);
                        }
                        if (!audioClip3)
                        {
                            DebugUtils.Assert("Can't find clip - " + key6.GetVariable(0).SValue, true, DebugUtils.AssertType.Info);
                        }
                        if (!this.m_DisappearAI.Contains(audioClip3))
                        {
                            this.m_DisappearAI.Add(audioClip3);
                        }
                    }
                }
            }
            else if (key.GetName() == "LowEnegryWhispersLevel")
            {
                this.m_LowEnegryWhispersLevel = key.GetVariable(0).FValue;
            }
        }
        Resources.UnloadAsset(textAsset);
    }
Exemplo n.º 27
0
        private void InitHumanSoundsParser()
        {
            TextAsset textAsset = Resources.Load("Scripts/AI/HumanSounds") as TextAsset;

            if (textAsset)
            {
                TextAssetParser textAssetParser = new TextAssetParser(textAsset);
                for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
                {
                    Key key = textAssetParser.GetKey(i);
                    if (key.GetName() == "Sound")
                    {
                        HumanAISoundModule.SoundType key2 = (HumanAISoundModule.SoundType)Enum.Parse(typeof(HumanAISoundModule.SoundType), key.GetVariable(0).SValue);
                        this.m_Tribe0Sounds[(int)key2] = new List <AudioClip>();
                        this.m_Tribe1Sounds[(int)key2] = new List <AudioClip>();
                        this.m_Tribe2Sounds[(int)key2] = new List <AudioClip>();
                        string    svalue    = key.GetVariable(1).SValue;
                        string    path      = "Sounds/" + key.GetVariable(2).SValue + "/Tribe0/" + svalue;
                        AudioClip audioClip = Resources.Load <AudioClip>(path);
                        if (audioClip)
                        {
                            this.m_Tribe0Sounds[(int)key2].Add(audioClip);
                        }
                        else
                        {
                            for (int j = 1; j < 99; j++)
                            {
                                path = string.Concat(new string[]
                                {
                                    "Sounds/",
                                    key.GetVariable(2).SValue,
                                    "/Tribe0/",
                                    svalue,
                                    (j >= 10) ? string.Empty : "0",
                                    j.ToString()
                                });
                                audioClip = Resources.Load <AudioClip>(path);
                                if (!audioClip)
                                {
                                    break;
                                }
                                this.m_Tribe0Sounds[(int)key2].Add(audioClip);
                            }
                        }
                        path      = "Sounds/" + key.GetVariable(2).SValue + "/Tribe1/" + svalue;
                        audioClip = Resources.Load <AudioClip>(path);
                        if (audioClip)
                        {
                            this.m_Tribe1Sounds[(int)key2].Add(audioClip);
                        }
                        else
                        {
                            for (int k = 1; k < 99; k++)
                            {
                                path = string.Concat(new string[]
                                {
                                    "Sounds/",
                                    key.GetVariable(2).SValue,
                                    "/Tribe1/",
                                    svalue,
                                    (k >= 10) ? string.Empty : "0",
                                    k.ToString()
                                });
                                audioClip = Resources.Load <AudioClip>(path);
                                if (!audioClip)
                                {
                                    break;
                                }
                                this.m_Tribe1Sounds[(int)key2].Add(audioClip);
                            }
                        }
                        path      = "Sounds/" + key.GetVariable(2).SValue + "/Tribe2/" + svalue;
                        audioClip = Resources.Load <AudioClip>(path);
                        if (audioClip)
                        {
                            this.m_Tribe2Sounds[(int)key2].Add(audioClip);
                        }
                        else
                        {
                            for (int l = 1; l < 99; l++)
                            {
                                path = string.Concat(new string[]
                                {
                                    "Sounds/",
                                    key.GetVariable(2).SValue,
                                    "/Tribe2/",
                                    svalue,
                                    (l >= 10) ? string.Empty : "0",
                                    l.ToString()
                                });
                                audioClip = Resources.Load <AudioClip>(path);
                                if (!audioClip)
                                {
                                    break;
                                }
                                this.m_Tribe2Sounds[(int)key2].Add(audioClip);
                            }
                        }
                    }
                }
                Resources.UnloadAsset(textAsset);
            }
            else
            {
                DebugUtils.Assert("Missing HumanSounds script!", true, DebugUtils.AssertType.Info);
            }
        }
Exemplo n.º 28
0
    private void SetupEvents()
    {
        AI ai = null;
        TextAssetParser textAssetParser;

        if (this.m_Being.IsAI())
        {
            ai = base.GetComponent <AI>();
            string text = (!ai.IsHuman()) ? (ai.m_ID.ToString() + "AnimEvents") : "SavageAnimEvents";
            if (!AIManager.Get().m_AnimEventsParsers.ContainsKey(text))
            {
                Debug.Log(text);
            }
            textAssetParser = AIManager.Get().m_AnimEventsParsers[text];
            if (ai.IsHuman())
            {
                this.m_HumanAI = (HumanAI)ai;
            }
            this.m_FootstepAudioSource.spatialize = true;
            this.m_AudioSource.spatialize         = true;
        }
        else
        {
            textAssetParser = new TextAssetParser(this.m_AnimEventsScript);
        }
        Animator      component     = base.gameObject.GetComponent <Animator>();
        AnimationClip animationClip = null;

        AnimationClip[] animationClips = component.runtimeAnimatorController.animationClips;
        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Anim")
            {
                string svalue = key.GetVariable(0).SValue;
                foreach (AnimationClip animationClip2 in animationClips)
                {
                    if (animationClip2.name == svalue)
                    {
                        animationClip = animationClip2;
                        break;
                    }
                }
                if (!animationClip)
                {
                    DebugUtils.Assert(false, "Can't find player anim clip " + svalue, true, DebugUtils.AssertType.Info);
                }
                else
                {
                    AnimationEvent[] events = animationClip.events;
                    for (int k = 0; k < key.GetKeysCount(); k++)
                    {
                        Key key2 = key.GetKey(k);
                        if (key2.GetName() == "Event")
                        {
                            AnimEventID animEventID = (AnimEventID)Enum.Parse(typeof(AnimEventID), key2.GetVariable(0).SValue);
                            bool        flag        = false;
                            for (int l = 0; l < events.Length; l++)
                            {
                                if (events[l].intParameter == (int)animEventID)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                float          fvalue         = key2.GetVariable(1).FValue;
                                AnimationEvent animationEvent = new AnimationEvent();
                                animationEvent.intParameter = (int)animEventID;
                                animationEvent.time         = animationClip.length * fvalue;
                                animationEvent.functionName = "AnimEvent";
                                animationClip.AddEvent(animationEvent);
                                List <AnimationEvent> list = null;
                                if (!this.m_Events.TryGetValue(Animator.StringToHash(svalue), out list))
                                {
                                    this.m_Events[Animator.StringToHash(svalue)] = new List <AnimationEvent>();
                                }
                                this.m_Events[Animator.StringToHash(svalue)].Add(animationEvent);
                            }
                        }
                        else if (key2.GetName() == "Sound")
                        {
                            string svalue2 = key2.GetVariable(0).SValue;
                            if (!this.m_Sounds.ContainsKey(svalue2))
                            {
                                this.m_Sounds[svalue2] = new List <AudioClip>();
                                string text2 = (!ai || ai.m_SoundPreset == AI.SoundPreset.None) ? string.Empty : (ai.m_SoundPreset.ToString() + "/");
                                string path  = string.Concat(new string[]
                                {
                                    "Sounds/",
                                    key2.GetVariable(1).SValue,
                                    "/",
                                    text2,
                                    svalue2
                                });
                                AudioClip audioClip = Resources.Load <AudioClip>(path);
                                if (audioClip)
                                {
                                    this.m_Sounds[svalue2].Add(audioClip);
                                }
                                else
                                {
                                    for (int m = 1; m < 99; m++)
                                    {
                                        path = string.Concat(new string[]
                                        {
                                            "Sounds/",
                                            key2.GetVariable(1).SValue,
                                            "/",
                                            text2,
                                            svalue2,
                                            (m >= 10) ? string.Empty : "0",
                                            m.ToString()
                                        });
                                        audioClip = Resources.Load <AudioClip>(path);
                                        if (!audioClip)
                                        {
                                            break;
                                        }
                                        this.m_Sounds[svalue2].Add(audioClip);
                                    }
                                }
                            }
                            if (this.m_Sounds[svalue2].Count == 0)
                            {
                                DebugUtils.Assert("Missing clips of sound - " + svalue2, true, DebugUtils.AssertType.Info);
                            }
                            float num   = animationClip.length * key2.GetVariable(2).FValue;
                            bool  flag2 = false;
                            for (int n = 0; n < events.Length; n++)
                            {
                                if (!(events[n].functionName != "SoundEvent"))
                                {
                                    if (events[n].stringParameter == svalue2 && events[n].time == num)
                                    {
                                        flag2 = true;
                                        break;
                                    }
                                }
                            }
                            if (!flag2)
                            {
                                animationClip.AddEvent(new AnimationEvent
                                {
                                    stringParameter = svalue2,
                                    time            = num,
                                    functionName    = "SoundEvent"
                                });
                            }
                        }
                        else if (key2.GetName() == "Footstep")
                        {
                            float  num2    = animationClip.length * key2.GetVariable(0).FValue;
                            string svalue3 = key2.GetVariable(1).SValue;
                            if (!this.m_TransformsForFXesMap.ContainsKey(svalue3))
                            {
                                Transform transform = base.transform.FindDeepChild(svalue3);
                                DebugUtils.Assert(transform != null, "Can't find objects - " + svalue3, true, DebugUtils.AssertType.Info);
                                this.m_TransformsForFXesMap.Add(svalue3, transform);
                            }
                            bool flag3 = false;
                            for (int num3 = 0; num3 < events.Length; num3++)
                            {
                                if (!(events[num3].functionName != "FootstepEvent"))
                                {
                                    if (events[num3].stringParameter == svalue3 && events[num3].time == num2)
                                    {
                                        flag3 = true;
                                        break;
                                    }
                                }
                            }
                            if (!flag3)
                            {
                                animationClip.AddEvent(new AnimationEvent
                                {
                                    stringParameter = svalue3,
                                    time            = num2,
                                    functionName    = "FootstepEvent"
                                });
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 29
0
    private void LoadScript()
    {
        TextAssetParser textAssetParser = new TextAssetParser(Resources.Load(LiquidManager.s_ScriptName) as TextAsset);

        for (int i = 0; i < textAssetParser.GetKeysCount(); i++)
        {
            Key key = textAssetParser.GetKey(i);
            if (key.GetName() == "Liquid")
            {
                LiquidData liquidData = new LiquidData();
                liquidData.m_LiquidType = (LiquidType)Enum.Parse(typeof(LiquidType), key.GetVariable(0).SValue);
                for (int j = 0; j < key.GetKeysCount(); j++)
                {
                    Key key2 = key.GetKey(j);
                    if (key2.GetName() == "Components")
                    {
                        liquidData.m_LiquidComponent = (LiquidType)Enum.Parse(typeof(LiquidType), key2.GetVariable(0).SValue);
                        liquidData.m_ItemComponent   = (ItemID)Enum.Parse(typeof(ItemID), key2.GetVariable(1).SValue);
                    }
                    else if (key2.GetName() == "Fat")
                    {
                        liquidData.m_Fat = key2.GetVariable(0).FValue;
                    }
                    else if (key2.GetName() == "Carbohydrates")
                    {
                        liquidData.m_Carbohydrates = key2.GetVariable(0).FValue;
                    }
                    else if (key2.GetName() == "Proteins")
                    {
                        liquidData.m_Proteins = key2.GetVariable(0).FValue;
                    }
                    else if (key2.GetName() == "Water")
                    {
                        liquidData.m_Water = key2.GetVariable(0).FValue;
                    }
                    else if (key2.GetName() == "SanityChange")
                    {
                        liquidData.m_SanityChange = key2.GetVariable(0).IValue;
                    }
                    else if (key2.GetName() == "CookingResult")
                    {
                        liquidData.m_CookingResult = (LiquidType)Enum.Parse(typeof(LiquidType), key2.GetVariable(0).SValue);
                    }
                    else if (key2.GetName() == "DrinkEffect")
                    {
                        LiquidConsumeEffectData liquidConsumeEffectData = new LiquidConsumeEffectData();
                        liquidConsumeEffectData.m_ConsumeEffect       = (ConsumeEffect)Enum.Parse(typeof(ConsumeEffect), key2.GetVariable(0).SValue);
                        liquidConsumeEffectData.m_ConsumeEffectChance = key2.GetVariable(1).FValue;
                        liquidConsumeEffectData.m_ConsumeEffectDelay  = key2.GetVariable(2).FValue;
                        liquidConsumeEffectData.m_ConsumeEffectLevel  = key2.GetVariable(3).IValue;
                        liquidData.m_ConsumeEffects.Add(liquidConsumeEffectData);
                    }
                    else if (key2.GetName() == "Energy")
                    {
                        liquidData.m_Energy = key2.GetVariable(0).FValue;
                    }
                    else if (key2.GetName() == "PoisonDebuff")
                    {
                        liquidData.m_PoisonDebuff = key2.GetVariable(0).IValue;
                    }
                    else if (key2.GetName() == "Disgusting")
                    {
                        liquidData.m_Disgusting = (key2.GetVariable(0).IValue != 0);
                    }
                }
                this.m_LiquidDatas.Add(liquidData);
            }
        }
    }