コード例 #1
0
 public bool RemoveState(AnimationEventState eventState)
 {
     if (m_stateList.Contains(eventState))
     {
         m_stateList.Remove(eventState);
         return(true);
     }
     return(false);
 }
コード例 #2
0
        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];
                }
            }
        }
コード例 #3
0
        public AnimationEventState GetState(int stateNameHash)
        {
            for (int i = 0; i < m_stateList.Count; ++i)
            {
                AnimationEventState eventState = m_stateList[i];
                if (eventState.NameHash == stateNameHash)
                {
                    return(eventState);
                }
            }

            return(null);
        }
コード例 #4
0
        public AnimationEventState GetState(string stateName)
        {
            for (int i = 0; i < m_stateList.Count; ++i)
            {
                AnimationEventState eventState = m_stateList[i];
                if (eventState.Name.Equals(stateName, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(eventState);
                }
            }

            return(null);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public AnimationEventState Clone()
        {
            AnimationEventState clone = new AnimationEventState(Name);

            clone.Visible       = Visible;
            clone.isLooping     = isLooping;
            clone.AnimationTime = AnimationTime;
            clone.clipName      = clipName;
            //clone.m_eventList = m_eventList;

            for (int i = 0; i < m_eventList.Count; i++)
            {
                AnimationEventInfo animationEventInfo = m_eventList[i];
                clone.AddAnimationEvent(animationEventInfo.Clone());
            }

            return(clone);
        }
コード例 #7
0
        private static void DeserializeAnimationEvent(string line, AnimationEventState eventState)
        {
            string[] tokens = line.Split(charSeparators, System.StringSplitOptions.None);

            if (tokens.Length >= 4)
            {
                string functionName = tokens[0];
                int    frame        = int.Parse(tokens[1]);

                float time = 0.0f;
                if (tokens.Length >= 3)
                {
                    float.TryParse(tokens[2], out time);
                }

                string param = "";
                if (tokens.Length >= 4)
                {
                    param = tokens[3];
                }

                bool eventOnExit = false;
                if (tokens.Length >= 5)
                {
                    bool.TryParse(tokens[4], out eventOnExit);
                }


                AnimationEventInfo animationEventInfo = new AnimationEventInfo();
                animationEventInfo.FunctionName = functionName;

                animationEventInfo.Frame = frame;
                //animationEvent.Param = param;
                animationEventInfo.attribute = AnimationEventUtil.CreateAttribute(functionName, param);
                AnimationEventUtil.Serialize(out param, animationEventInfo.attribute);
                animationEventInfo.param        = param;
                animationEventInfo.Time         = time;
                animationEventInfo.EventOnExit  = eventOnExit;
                animationEventInfo.NomalizeTime = time / eventState.AnimationTime;

                eventState.AddAnimationEvent(animationEventInfo);
            }
        }
コード例 #8
0
 public AnimationEventState AddState(AnimationEventState eventState)
 {
     m_stateList.Add(eventState);
     return(eventState);
 }