Exemple #1
0
        internal override bool Update(ActionSequence actionSequence, float deltaTime)
        {
            actionSequence.UpdateTimeAxis(deltaTime);
            if (null != action)
            {
                try
                {
                    action();
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    actionSequence.Stop();
                }
            }
            else if (null != actionLoop)
            {
                try
                {
                    actionLoop(actionSequence.cycles);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    actionSequence.Stop();
                }
            }

            return(true);
        }
Exemple #2
0
 /// <summary>
 /// 用Component作为ID停止指定的序列
 /// </summary>
 /// <param name="id"></param>
 /// <param name="sequence">停止指定的ActionSequence</param>
 public static void StopSequence(this Component id, ActionSequence sequence)
 {
     if (sequence != null)
     {
         sequence.Stop(id);
     }
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            int countAll, countActive;

            GUILayout.Label("ObjectPool State: Active/All", EditorStyles.boldLabel);
            ActionNodeAction.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("ActionNode: {0}/{1}", countActive, countAll));
            ActionNodeInterval.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("IntervalNode: {0}/{1}", countActive, countAll));
            ActionNodeCondition.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("ConditionNode: {0}/{1}", countActive, countAll));
            ActionSequence.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("Sequence: {0}/{1}", countActive, countAll));

            //Showing ActionSequences in progress
            ActionSequenceSystem actionSequenceSystem = target as ActionSequenceSystem;

            GUILayout.Label(string.Format("Sequence Count: {0}", actionSequenceSystem.ListSequence.Count), EditorStyles.boldLabel);
            for (int i = 0; i < actionSequenceSystem.ListSequence.Count; i++)
            {
                if (!actionSequenceSystem.ListSequence[i].isFinshed)
                {
                    GUILayout.Box(string.Format("{0} id: {1}\n Loop:{2}/{3}", i, actionSequenceSystem.ListSequence[i].id,
                                                actionSequenceSystem.ListSequence[i].cycles, actionSequenceSystem.ListSequence[i].loopTime), "TextArea");
                }
            }

            Repaint();
        }
        public static ActionSequence Delayer(float delay, Action action)
        {
            ActionSequence seq = GetSequence();

            seq.Interval(delay).Action(action);
            return(seq);
        }
Exemple #5
0
        //直接延迟动作
        public static ActionSequence Delayer(this Component id, float delay, Action action)
        {
            ActionSequence seq = ActionSequenceSystem.GetSequence(id);

            seq.Interval(delay).Action(action);
            return(seq);
        }
        private static ActionSequence GetSequence()
        {
            ActionSequence seq = ActionSequence.GetInstance();

            instance.listSequence.Add(seq);
            return(seq);
        }
            internal void Update(float deltaTime)
            {
                //Update Sequence(Auto release)
                bool isSomeSequenceStoped = false;

                for (int i = 0; i < listSequenceAlive.Count; i++)
                {
                    //It's stopped when Update return false and release self
                    isSomeSequenceStoped |= !listSequenceAlive[i].Update(deltaTime);
                }

                //Remove Finshed Sequence(Finshed is Released)
                if (isSomeSequenceStoped)
                {
                    for (int i = 0; i < listSequenceAlive.Count; i++)
                    {
                        ActionSequence actionSequence = listSequenceAlive[i];
                        if (actionSequence.isFinshed)
                        {
                            actionSequence.Release();
                        }
                    }

                    listSequenceAlive.RemoveAll(seq => seq.isFinshed);
                }
            }
        //Start a sequence
        public static ActionSequence GetSequence(Component component)
        {
            ActionSequence seq = ActionSequence.GetInstance(component);

            instance.listSequence.Add(seq);
            return(seq);
        }
        //Get a sequence
        internal static ActionSequence GetSequence(Component component = null)
        {
            ActionSequence seq = ActionSequence.GetInstance(component);

            instance.listSequenceAlive.Add(seq);
            return(seq);
        }
        private static ActionSequence GetSequenceUnscaled(Component component = null)
        {
            CreateCheck();
            ActionSequence seq = ActionSequence.GetInstance(component);

            instance.updaterUnscale.Add(seq);
            return(seq);
        }
Exemple #11
0
            internal void Add(ActionSequence sequence)
            {
                if (listSequenceAlive.Contains(sequence))
                {
                    Debug.LogError("ActionSequence 重复");
                    return;
                }

                listSequenceAlive.Add(sequence);
            }
        public void Play()
        {
            //停止当前的动画
            Stop();
            if (nLength <= 0)
            {
                return;
            }

            //处理播放顺序
            if (playOrder == PlayOrder.Forward)
            {
                nStartFrame = 0;
                nSign       = 1;
            }
            else
            {
                nStartFrame = nLength - 1;
                nSign       = -1;
            }

            //处理循环模式
            switch (loopType)
            {
            case LoopType.Once:
                loopTypeFun = UpdateFrameFuncOnce;
                break;

            case LoopType.Loop:
                loopTypeFun = UpdateFrameFuncLoop;
                break;

            case LoopType.PingPong:
                loopTypeFun = UpdateFrameFuncPingPong;
                break;

            default:
                break;
            }

            float interval = 1 / FPS;

            nCurFrame = nStartFrame;
            isPlaying = true;

            //开启定时器
            //这里使用了ActionSequenceSystem作为Timer,也可以使用DOTween的Sequence,当然您也可以使用您的Timer
#if DOTween
            DOTween.Sequence().SetId(this).SetRecyclable().AppendInterval(interval).AppendCallback(UpdateFrame).SetLoops(-1);
#else
            timer = ActionSequenceSystem.Looper(interval, -1, false, UpdateFrame);
#endif
        }
        internal override bool Update(ActionSequence actionSequence)
        {
            if (null != action)
            {
                action();
            }
            else if (null != actionLoop)
            {
                actionLoop(actionSequence.cycles);
            }

            return(true);
        }
        internal override bool Update(ActionSequence actionSequence, float deltaTime)
        {
            actionSequence.UpdateTimeAxis(deltaTime);
            Behaviour behaviour = actionSequence.id as Behaviour;

            if (behaviour)
            {
                bool final = isToggle ? !behaviour.enabled : isEnable;
                behaviour.enabled = final;
            }

            return(true);
        }
Exemple #15
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            int countAll, countActive;

            GUILayout.Label("ObjectPool State: Active/All", EditorStyles.boldLabel);
            ActionNodeAction.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("ActionNode: {0}/{1}", countActive, countAll));
            ActionNodeInterval.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("IntervalNode: {0}/{1}", countActive, countAll));
            ActionNodeWaitFor.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("ConditionNode: {0}/{1}", countActive, countAll));
            ActionNodeSetActive.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("HideNode: {0}/{1}", countActive, countAll));
            ActionSequence.GetObjectPoolInfo(out countActive, out countAll);
            GUILayout.Label(string.Format("Sequence: {0}/{1}", countActive, countAll));

            //Showing ActionSequences in progress
            ActionSequenceSystem actionSequenceSystem = target as ActionSequenceSystem;

            GUILayout.Label(string.Format("Sequence Count: {0}", actionSequenceSystem.ListSequenceAlive.Count), EditorStyles.boldLabel);
            for (int i = 0; i < actionSequenceSystem.ListSequenceAlive.Count; i++)
            {
                ActionSequence sequence = actionSequenceSystem.ListSequenceAlive[i];

                //if (!sequence.isFinshed)
                //{
                if (sequence.loopTime == 0) //It's a delayer
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})", sequence.id, sequence.timeAxis), "TextArea");
                }
                else if (sequence.loopTime < 0) //It's a infinite looper
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})   Loop({2}/{3})   Node[{4}]", sequence.id, sequence.timeAxis,
                                                sequence.cycles, sequence.loopTime, sequence.nodes.Count), "TextArea");
                }
                else //It's a count looper
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})   Loop({2}/{3})   Node[{4}]", sequence.id, sequence.timeAxis,
                                                sequence.cycles, sequence.loopTime + 1, sequence.nodes.Count), "TextArea");
                }

                //}
            }

            Repaint();
        }
Exemple #16
0
        //直接循环动作
        public static ActionSequence Looper(this Component id, float interval, int loopTime, bool isActionAtStart, Action <int> action)
        {
            ActionSequence seq = ActionSequenceSystem.GetSequence(id);

            if (isActionAtStart)
            {
                seq.Action(action).Interval(interval);
            }
            else
            {
                seq.Interval(interval).Action(action);
            }

            seq.Loop(loopTime);
            return(seq);
        }
        public static ActionSequence Looper(float interval, int loopTime, bool isActionAtStart, Action action)
        {
            ActionSequence seq = GetSequence();

            if (isActionAtStart)
            {
                seq.Action(action).Interval(interval);
            }
            else
            {
                seq.Interval(interval).Action(action);
            }

            seq.Loop(loopTime);
            return(seq);
        }
Exemple #18
0
        internal override bool Update(ActionSequence actionSequence, float deltaTime)
        {
            bool res = false;

            try
            {
                res = condition();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                actionSequence.Stop();
                return(true);
            }

            return(res);
        }
        private static void UpdateInfo(List <ActionSequence> listSequenceAlive)
        {
            for (int i = 0; i < listSequenceAlive.Count; i++)
            {
                ActionSequence sequence = listSequenceAlive[i];

                if (sequence.loopTime == 0) //It's a delayer
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})", sequence.id, sequence.timeAxis), "TextArea");
                }
                else if (sequence.loopTime < 0) //It's a infinite looper
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})   Loop({2}/{3})   Node[{4}]", sequence.id, sequence.timeAxis,
                                                sequence.cycles, sequence.loopTime, sequence.nodesCount), "TextArea");
                }
                else //It's a count looper
                {
                    GUILayout.Box(string.Format("  ID: {0}\n  Time({1:F2})   Loop({2}/{3})   Node[{4}]", sequence.id, sequence.timeAxis,
                                                sequence.cycles, sequence.loopTime + 1, sequence.nodesCount), "TextArea");
                }
            }
        }
Exemple #20
0
        private static void UpdateInfo(List <ActionSequence> listSequenceAlive)
        {
            for (int i = 0; i < listSequenceAlive.Count; i++)
            {
                ActionSequence sequence = listSequenceAlive[i];

                if (sequence.loopTime == 0) //It's a delayer
                {
                    GUILayout.Box($"  ID: {sequence.id}\n  Time({sequence.timeAxis:F2})", "TextArea");
                }
                else if (sequence.loopTime < 0) //It's a infinite looper
                {
                    GUILayout.Box(
                        $"  ID: {sequence.id}\n  Time({sequence.timeAxis:F2})   Loop({sequence.cycles}/{sequence.loopTime})   Node[{sequence.nodesCount}]", "TextArea");
                }
                else //It's a count looper
                {
                    GUILayout.Box(
                        $"  ID: {sequence.id}\n  Time({sequence.timeAxis:F2})   Loop({sequence.cycles}/{sequence.loopTime + 1})   Node[{sequence.nodesCount}]", "TextArea");
                }
            }
        }
 /// <summary>
 /// 是否受时间缩放影响
 /// </summary>
 /// <param name="sequence"></param>
 /// <param name="timeMode"></param>
 /// <returns></returns>
 public static ActionSequence SetTimeMode(this ActionSequence sequence, TimeMode timeMode)
 {
     sequence.timeMode = timeMode;
     return(sequence);
 }
 /// <summary>
 /// 用Component作为ID停止指定的序列
 /// </summary>
 /// <param name="id"></param>
 /// <param name="sequence">停止指定的ActionSequence</param>
 public static void StopSequence(this Component id, ActionSequence sequence)
 {
     sequence?.Stop(id);
 }
        public static ActionSequence Sequence()
        {
            ActionSequence seq = GetSequence();

            return(seq);
        }
Exemple #24
0
        //用Component作为ID开序列
        public static ActionSequence Sequence(this Component id)
        {
            ActionSequence seq = ActionSequenceSystem.GetSequence(id);

            return(seq);
        }
 /// <summary>
 /// 不受时间缩放影响
 /// </summary>
 /// <param name="sequence"></param>
 /// <returns></returns>
 public static ActionSequence Unscaled(this ActionSequence sequence)
 {
     sequence.timeMode = TimeMode.Unscaled;
     return(sequence);
 }
Exemple #26
0
 internal override bool Update(ActionSequence actionSequence)
 {
     return(condition());
 }
 internal void Add(ActionSequence sequence)
 {
     listSequenceAlive.Add(sequence);
 }