Exemplo n.º 1
0
 public virtual void OnUpdate(GTAnimator animator)
 {
     if (animator == null)
     {
         return;
     }
     if (OnUpdateDelegate != null)
     {
         OnUpdateDelegate(this);
     }
     if (ActiveActions != null && ActiveActions.Count > 0)
     {
         for (int i = 0; i < ActiveActions.Count; i++)
         {
             ClipAction action = ActiveActions[i];
             if (action == null)
             {
                 ActiveActions.RemoveAt(i);
                 i--;
                 continue;
             }
             if (action.EndTime <= animator.CurrentTime)
             {
                 action.OnEnd(this);
                 ActiveActions.Remove(action);
                 i--;
             }
             else if (action.m_Status == ClipAction.Status.Error || action.m_Status == ClipAction.Status.StopOnNextFrame)
             {
                 action.OnEnd(this);
                 ActiveActions.Remove(action);
                 i--;
             }
             else
             {
                 action.OnUpdate(this);
             }
         }
     }
     if (WaittingProcessActions != null && WaittingProcessActions.Count > 0)
     {
         for (int i = 0; i < WaittingProcessActions.Count; i++)
         {
             ClipAction action = WaittingProcessActions[i];
             if (action == null)
             {
                 WaittingProcessActions.RemoveAt(i);
                 i--;
                 continue;
             }
             if (action.BeginTime <= animator.CurrentTime && action.m_Status == ClipAction.Status.UnAction)
             {
                 action.OnBegin(this);
                 ActiveActions.Add(action);
                 WaittingProcessActions.Remove(action);
                 i--;
             }
         }
     }
 }
Exemplo n.º 2
0
 public void OnAnimatorUpdate(GTAnimator animator)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorUpdate, animator);
     }
 }
Exemplo n.º 3
0
 public void OnAnimatorUpdatePercentage(GTAnimator animator, float currentPercentage, float currentPlayTime)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorUpdatePercentage, animator, currentPercentage, currentPlayTime);
     }
 }
Exemplo n.º 4
0
 public void OnAnimatorUnPause(GTAnimator animator, float currentTime, float pauseTime)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorUnPause, animator, currentTime, pauseTime);
     }
 }
Exemplo n.º 5
0
 public void OnAnimatorPreBegin(GTAnimator animator, PlayTask task)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorPreBegin, animator);
     }
 }
Exemplo n.º 6
0
 public void OnAnimatorStop(GTAnimator animator)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorStop, animator);
     }
 }
Exemplo n.º 7
0
        public virtual void OnBegin(GTAnimator animator)
        {
            GetAllAction();
            WaittingProcessActions = new List <ClipAction>(Actions);
            switch (ActiveObjOperation)
            {
            case GameObjectActiveOperation.AlwaysChangeStatus:
                if (AnimateObj.activeSelf == false)
                {
                    AnimateObj.SetActive(true);
                }
                break;

            case GameObjectActiveOperation.OnlyActiveOnBegin:
                if (AnimateObj.activeSelf == false)
                {
                    AnimateObj.SetActive(true);
                }
                break;

            case GameObjectActiveOperation.DontOperate:
                break;

            default:
                break;
            }
            if (OnBeginDelegate != null)
            {
                OnBeginDelegate(this);
            }
        }
Exemplo n.º 8
0
 public void OnAnimatorBegin(GTAnimator animator)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorBegin, animator);
     }
 }
Exemplo n.º 9
0
 private void OnDestroy()
 {
     Playlist        = null;
     ListenEnd       = null;
     LastAnimator    = null;
     CurrentAnimator = null;
 }
Exemplo n.º 10
0
 public void OnAnimatorCannotPlay(GTAnimator animator)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorCannotPlay, animator);
     }
     ClearListen(animator);
 }
Exemplo n.º 11
0
 public void OnAnimatorEnd(GTAnimator animator)
 {
     if (Callback != null)
     {
         Callback(MsgType.OnAnimatorEnd, animator);
     }
     ClearListen(animator);
 }
Exemplo n.º 12
0
        public static GTAnimator Get(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }
            if (AllAnimator == null || AllAnimator.Count == 0)
            {
                return(null);
            }
            GTAnimator animator = null;

            AllAnimator.TryGetValue(name, out animator);
            return(animator);
        }
Exemplo n.º 13
0
 /// <summary>
 /// add listen when attach to an animator
 /// </summary>
 /// <param name="animator"></param>
 private void AddListen(GTAnimator animator)
 {
     if (animator != null)
     {
         animator.CannotPlayDelegate       += OnAnimatorCannotPlay;
         animator.PreBeginDelegate         += OnAnimatorPreBegin;
         animator.BeginDelegate            += OnAnimatorBegin;
         animator.UpdateDelegate           += OnAnimatorUpdate;
         animator.UpdatePercentageDelegate += OnAnimatorUpdatePercentage;
         animator.EndDelegate     += OnAnimatorEnd;
         animator.PauseDelegate   += OnAnimatorPause;
         animator.UnPauseDelegate += OnAnimatorUnPause;
         animator.StopDelegate    += OnAnimatorStop;
     }
 }
Exemplo n.º 14
0
 public virtual void OnAnimatorInited(GTAnimator animator)
 {
     GetAllAction();
     if (Actions != null && Actions.Count > 0)
     {
         for (int i = 0; i < Actions.Count; i++)
         {
             ClipAction action = Actions[i];
             if (action == null)
             {
                 continue;
             }
             action.OnClipInited(this);
         }
     }
 }
Exemplo n.º 15
0
        public static void Add(string name, GTAnimator animator)
        {
            if (animator == null)
            {
                return;
            }
            GTAnimator o = null;

            if (AllAnimator.TryGetValue(name, out o))
            {
                return;
            }
            else
            {
                AllAnimator.Add(name, animator);
            }
        }
Exemplo n.º 16
0
        public virtual void OnEnd(GTAnimator animator)
        {
            if (ActiveActions != null || ActiveActions.Count > 0)
            {
                for (int i = 0; i < ActiveActions.Count; i++)
                {
                    ClipAction action = ActiveActions[i];
                    if (action == null)
                    {
                        continue;
                    }
                    action.OnEnd(this);
                }
            }
            if (AnimateObj != null)
            {
                switch (ActiveObjOperation)
                {
                case GameObjectActiveOperation.AlwaysChangeStatus:
                    if (AnimateObj.activeSelf == true)
                    {
                        AnimateObj.SetActive(false);
                    }
                    break;

                case GameObjectActiveOperation.OnlyActiveOnBegin:
                    break;

                case GameObjectActiveOperation.DontOperate:
                    break;

                default:
                    break;
                }
            }
            if (OnEndDelegate != null)
            {
                OnEndDelegate(this);
            }
            m_Status = Status.UnAction;
        }
Exemplo n.º 17
0
        private void OnOneAnimatorUpdate(GTAnimator animator)
        {
            if (animator == null)
            {
                return;
            }
            if (Adapter != null)
            {
                MethodInfo info = Adapter.GetType().GetMethod("OnAnimatorUpdate");
                if (info != null)
                {
                    Adapter.GetType().InvokeMember("OnAnimatorUpdate", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, Adapter, new object[] { animator });
                }
                else
                {
                    //Utility.LogError("FixedPlaylist: can not callback your adapter caused by null method named 'OnAnimatorUpdate(void)'");
                }
            }
            Description des = GetDescription(animator);

            if (des == null || des.Animator == null)
            {
                return;
            }
            if (des.Adapter != null)
            {
                MethodInfo info = des.Adapter.GetType().GetMethod("OnAnimatorUpdate");
                if (info != null)
                {
                    des.Adapter.GetType().InvokeMember("OnAnimatorUpdate", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, des.Adapter, new object[] { animator });
                }
                else
                {
                    Utility.LogError("FixedPlaylist: can not callback your adapter caused by null method named 'OnAnimatorUpdate(void)'");
                }
            }
        }
Exemplo n.º 18
0
 public Description GetDescription(GTAnimator animator)
 {
     if (animator == null)
     {
         return(null);
     }
     if (Playlist == null || Playlist.Count == 0)
     {
         return(null);
     }
     for (int i = 0; i < Playlist.Count; i++)
     {
         Description des = Playlist[i];
         if (des == null)
         {
             continue;
         }
         if (des.Animator == animator)
         {
             return(des);
         }
     }
     return(null);
 }
Exemplo n.º 19
0
        private void OnOneAnimatorEnd(GTAnimator animator)
        {
            if (animator != null)
            {
                animator.PreBeginDelegate -= OnOneAnimatorPreStart;
                animator.BeginDelegate    -= OnOneAnimatorStart;
                animator.UpdateDelegate   -= OnOneAnimatorUpdate;
                animator.EndDelegate      -= OnOneAnimatorEnd;
            }
            if (Adapter != null)
            {
                MethodInfo info = Adapter.GetType().GetMethod("OnAnimatorEnd");
                if (info != null)
                {
                    Adapter.GetType().InvokeMember("OnAnimatorEnd", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, Adapter, new object[] { animator });
                }
                else
                {
                    Utility.LogError("FixedPlaylist: can not callback your adapter caused by null method named 'OnAnimatorEnd(void)'");
                }
            }
            Description des = GetDescription(animator);

            if (des == null)
            {
                return;
            }
            ActiveAnimators.Remove(des);
            if (des.Adapter != null)
            {
                MethodInfo info = des.Adapter.GetType().GetMethod("OnAnimatorEnd");
                if (info != null)
                {
                    des.Adapter.GetType().InvokeMember("OnAnimatorEnd", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, des.Adapter, new object[] { animator });
                }
                else
                {
                    Utility.LogError("FixedPlaylist: can not callback your adapter caused by null method named 'OnAnimatorEnd(void)'");
                }
                if (des.CallbackOnEnd)
                {
                    if (ListenEnd != null)
                    {
                        ListenEnd(this);
                    }
                }
            }
            if (WaittingProcessAnimators != null && WaittingProcessAnimators.Count > 0)
            {
                for (int i = 0; i < WaittingProcessAnimators.Count; i++)
                {
                    Description tempDes = WaittingProcessAnimators[i];
                    if (tempDes == null || tempDes.Animator == null)
                    {
                        continue;
                    }
                    if (tempDes.RelyOn == animator && tempDes.Time == -1 && tempDes.Animator.m_Status == GTAnimator.Status.UnAction)
                    {
                        GTAnimator.PlayTask task = new GTAnimator.PlayTask();
                        task.PlayAllClip = true;
                        task.PlayMode    = GTAnimator.PlayMode.DontPlayWhenBusying;

                        tempDes.Animator.PreBeginDelegate += OnOneAnimatorPreStart;
                        tempDes.Animator.BeginDelegate    += OnOneAnimatorStart;
                        tempDes.Animator.UpdateDelegate   += OnOneAnimatorUpdate;
                        tempDes.Animator.EndDelegate      += OnOneAnimatorEnd;
                        tempDes.Animator.Play(task);
                        WaittingProcessAnimators.Remove(tempDes);
                        ActiveAnimators.Add(tempDes);
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void OnEnable()
 {
     Instance = target as GTAnimator;
 }
Exemplo n.º 21
0
 public virtual void OnAnimatorEnd(GTAnimator animator)
 {
 }
Exemplo n.º 22
0
 private void Awake()
 {
     if (Playlist != null && Playlist.Count > 0)
     {
         for (int i = 0; i < Playlist.Count; i++)
         {
             Description des = Playlist[i];
             if (des == null)
             {
                 continue;
             }
             if (string.IsNullOrEmpty(des.IdentifyName) == false)
             {
                 des.Animator = GTAnimator.Get(des.IdentifyName);
             }
             if (string.IsNullOrEmpty(des.RelyOnAnimatorName) == false)
             {
                 des.RelyOn = GTAnimator.Get(des.RelyOnAnimatorName);
             }
             if (des.AdapterType != null && des.Animator != null)
             {
                 Component com = null;
                 if (des.AdapterObj != null)
                 {
                     com = des.AdapterObj.GetComponent(des.AdapterType.name);
                 }
                 else
                 {
                     com = des.Animator.GetComponent(des.AdapterType.name);
                 }
                 if (des.DriveOnStart == false)
                 {
                     if (com != null)
                     {
                         MethodInfo info = com.GetType().GetMethod("Drive");
                         if (info != null)
                         {
                             com.GetType().InvokeMember("Drive", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, com, new object[] { });
                         }
                         else
                         {
                             Utility.LogError("FixedPlaylist: can not drive your adapter caused by null method named 'Drive(void)'");
                         }
                     }
                 }
                 des.Adapter = com;
             }
         }
     }
     if (AdapterType != null)
     {
         if (AdapterObj != null)
         {
             Adapter = AdapterObj.GetComponent(AdapterType.name);
         }
         else
         {
             Adapter = GetComponent(AdapterType.name);
         }
         if (Adapter != null)
         {
             MethodInfo info = Adapter.GetType().GetMethod("Drive");
             if (info != null)
             {
                 Adapter.GetType().InvokeMember("Drive", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, Adapter, new object[] { });
             }
             else
             {
                 //Utility.LogError("FixedPlaylist: can not drive your adapter caused by null method named 'Drive(void)'");
             }
         }
     }
 }
Exemplo n.º 23
0
 public virtual void OnAnimatorBegin(GTAnimator animator)
 {
 }