private static void DeserializeState(string line, AnimationEventStates animationEventStates)
        {
            if (line.StartsWith("[") && line.EndsWith("]"))
            {
                int    start     = line.IndexOf('[');
                int    last      = line.LastIndexOf(']');
                string stateName = line.Substring(start + 1, last - start - 1);

                m_currentAnimationEventState = animationEventStates.GetState(stateName);
                if (m_currentAnimationEventState == null)
                {
                    m_currentAnimationEventState = new AnimationEventState(stateName);
                    animationEventStates.AddState(m_currentAnimationEventState);
                }
            }
            else if (line.StartsWith("!"))
            {
                string animationEvent = line.Substring(1);
                DeserializeAnimationEvent(animationEvent, m_currentAnimationEventState);
            }
            else
            {
                string[] tokens      = line.Split(charSeparators, System.StringSplitOptions.None);
                string   tokenoption = tokens[0].Trim();

                if (m_currentAnimationEventState == null || tokens.Length != 2)
                {
                    return;
                }

                if (tokenoption == "clipTime")
                {
                    float AnimationTime;
                    StringConverter.TryConvert(tokens[1], out AnimationTime);
                    m_currentAnimationEventState.AnimationTime = AnimationTime;
                }
                else if (tokenoption == "isLooping")
                {
                    bool isLooping;
                    StringConverter.TryConvert(tokens[1], out isLooping);
                    m_currentAnimationEventState.isLooping = isLooping;
                }
                else if (tokenoption == "visible")
                {
                    bool Visible;
                    StringConverter.TryConvert <bool>(tokens[1], out Visible);
                    m_currentAnimationEventState.Visible = Visible;
                }
                else if (tokenoption == "clipName")
                {
                    m_currentAnimationEventState.clipName = tokens[1];
                }
            }
        }
Пример #2
0
        public AnimationEventStates Clone(/*ReleaseStates releaseStates*/)
        {
            AnimationEventStates cloneAnimationEventStates = new AnimationEventStates();

            cloneAnimationEventStates.Init(m_releaseStates);
            for (int i = 0; i < m_stateList.Count; i++)
            {
                cloneAnimationEventStates.AddState(m_stateList[i].Clone());
            }
            cloneAnimationEventStates.StateSort();
            cloneAnimationEventStates.GraphName = m_graphName;

            //m_releaseStates = releaseStates;

            return(cloneAnimationEventStates);
        }
        public static bool Deserialize(AnimationEventScriptable eventScriptable,
                                       ref AnimationEventStates animationEventStates)
        {
            if (eventScriptable == null)
            {
                return(false);
            }

            //orcaAnimationStates = new OrcaAnimationStates();
            animationEventStates.GraphName = eventScriptable.name.Replace("_animationevent", string.Empty);
            animationEventStates.BoneList  = eventScriptable.boneNames;

            TextAsset graphAsset = eventScriptable.graphAsset;

            if (graphAsset != null)
            {
                DeserializeText(animationEventStates, graphAsset.text);
            }
            animationEventStates.StateSort();

            TextAsset sfxAsset = eventScriptable.sfxAsset;

            if (sfxAsset != null)
            {
                DeserializeText(animationEventStates, sfxAsset.text);
            }

            TextAsset vfxAsset = eventScriptable.vfxAsset;

            if (vfxAsset != null)
            {
                DeserializeText(animationEventStates, vfxAsset.text);
            }

            if (animationEventStates != null)
            {
                for (int i = 0; i < animationEventStates.StateList.Count; i++)
                {
                    AnimationEventState animationEventState = animationEventStates.StateList[i];
                    animationEventState.ConvertAnimationEvents();
                    animationEventState.SortAnimationEvent();
                }
            }
            return(true);
        }
        private static void DeserializeText(AnimationEventStates animationEventStates, string text)
        {
            string tempText = text.Replace("\r", "");

            string[] lines = tempText.Split('\n');

            E_SerializeState serializeState = E_SerializeState.None;

            foreach (string line in lines)
            {
                string token = line.Trim();
                if (token.StartsWith("//"))
                {
                    continue;
                }

                if (token == "#Version")
                {
                    serializeState = E_SerializeState.Version;
                }
                if (token == "#State")
                {
                    serializeState = E_SerializeState.State;
                }
                else
                {
                    switch (serializeState)
                    {
                    case E_SerializeState.Version:
                        DeserializeVersion(token);
                        break;

                    case E_SerializeState.State:
                        DeserializeState(token, animationEventStates);
                        break;
                    }
                }
            }
        }