Exemple #1
0
        override protected void OnExecuteStart(NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            float time = GetParameterValue(Model.time, p_flowData);

            if (time == 0)
            {
                OnExecuteEnd();
                OnExecuteOutput(0, p_flowData);
            }
            else
            {
                DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);

                tween.OnComplete(() =>
                {
                    OnExecuteEnd();
                    OnExecuteOutput(0, p_flowData);
                    _activeTweens.Remove(tween);
                });

                _activeTweens.Add(tween);
                tween.Start();
            }
        }
Exemple #2
0
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            if (p_target == null)
            {
                ExecuteEnd(p_flowData);
                return;
            }

            DashTween tween = Model.preset.Execute(p_target, ParameterResolver, p_flowData);

            if (tween == null)
            {
                ExecuteEnd(p_flowData);
            }
            else
            {
                _activeTweens.Add(tween);
                tween.OnComplete(() => ExecuteEnd(p_flowData, tween)).Start();
            }
        }
Exemple #3
0
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            if (p_target == null)
            {
                ExecuteEnd(p_flowData);
                return;
            }

            DashTween tween = AnimateOnTarget(p_target, p_flowData);

            if (tween == null)
            {
                ExecuteEnd(p_flowData);
            }
            else
            {
                _activeTweens.Add(tween);
                tween.OnComplete(() =>
                {
                    _activeTweens.Remove(tween);
                    ExecuteEnd(p_flowData);
                }).Start();
            }
        }
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            if (p_target == null)
            {
                ExecuteEnd(p_flowData);
                return;
            }

            for (int i = 0; i < p_target.childCount; i++)
            {
                NodeFlowData childData = p_flowData.Clone();
                childData.SetAttribute("target", p_target.GetChild(Model.inReverse ? p_target.childCount - 1 - i : i));

                if (GetParameterValue(Model.onChildDelay, p_flowData) == 0)
                {
                    OnExecuteOutput(0, childData);
                }
                else
                {
                    float     time  = GetParameterValue(Model.onChildDelay, p_flowData) * i;
                    DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);
                    tween.OnComplete(() =>
                    {
                        _activeTweens.Remove(tween);
                        OnExecuteOutput(0, childData);
                    });
                    _activeTweens.Add(tween);
                    tween.Start();
                }
            }

            if (Model.onFinishDelay == 0 && GetParameterValue(Model.onChildDelay, p_flowData) == 0)
            {
                ExecuteEnd(p_flowData);
            }
            else
            {
                float     time  = Model.onFinishDelay + GetParameterValue(Model.onChildDelay, p_flowData) * p_target.childCount;
                DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);
                tween.OnComplete(() =>
                {
                    _activeTweens.Remove(tween);
                    ExecuteEnd(p_flowData);
                });
                _activeTweens.Add(tween);
                tween.Start();
            }
        }
Exemple #5
0
        protected override void OnExecuteStart(NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            int firstIndex = GetParameterValue(Model.firstIndex, p_flowData);
            int lastIndex  = GetParameterValue(Model.lastIndex, p_flowData);

            int length = lastIndex - firstIndex;

            if (length == 0)
            {
                EndLoop(p_flowData);
            }

            for (int i = firstIndex; i != lastIndex; i += Math.Abs(length) / length)
            {
                NodeFlowData data = p_flowData.Clone();

                if (Model.addIndexAttribute)
                {
                    data.SetAttribute(Model.indexAttribute, i);
                }

                if (GetParameterValue(Model.OnIterationDelay, p_flowData) == 0)
                {
                    OnExecuteOutput(0, data);
                }
                else
                {
                    float     time  = GetParameterValue(Model.OnIterationDelay, p_flowData) * i;
                    DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);

                    _activeTweens.Add(tween);
                    tween.OnComplete(() =>
                    {
                        _activeTweens.Remove(tween);
                        OnExecuteOutput(0, data);
                    });

                    tween.Start();
                }
            }

            if (Model.OnFinishedDelay == 0 && GetParameterValue(Model.OnIterationDelay, p_flowData) == 0)
            {
                EndLoop(p_flowData);
            }
            else
            {
                float     time  = Model.OnFinishedDelay + GetParameterValue(Model.OnIterationDelay, p_flowData) * length;
                DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);

                _activeTweens.Add(tween);
                tween.OnComplete(() =>
                {
                    _activeTweens.Remove(tween);
                    EndLoop(p_flowData);
                });

                tween.Start();
            }
        }
Exemple #6
0
        override protected void OnExecuteStart(NodeFlowData p_flowData)
        {
            if (_activeTweens == null)
            {
                _activeTweens = new List <DashTween>();
            }

            List <Transform> transforms = new List <Transform>();
            Transform        transform;

            if (!string.IsNullOrEmpty(Model.target))
            {
                if (!p_flowData.HasAttribute("target") && Model.isChild)
                {
                    Debug.LogWarning("Cannot retarget to a child of null in node " + _model.id);

                    hasErrorsInExecution = true;
                    OnExecuteEnd();

                    return;
                }

                if (Model.isChild)
                {
                    if (Model.findAll)
                    {
                        transforms = Controller.transform.DeepFindAll(Model.target);
                    }
                    else
                    {
                        transform = Controller.transform.DeepFind(Model.target);
                        if (transform != null)
                        {
                            transforms.Add(transform);
                        }
                    }
                }
                else
                {
                    if (Model.findAll)
                    {
                        transforms = Controller.transform.root.DeepFindAll(Model.target);
                    }
                    else
                    {
                        transform = Controller.transform.root.DeepFind(Model.target);
                        if (transform != null)
                        {
                            transforms.Add(transform);
                        }
                    }
                }

                if (transforms.Count == 0)
                {
                    Debug.LogWarning("Zero valid retargets found in node " + _model.id);

                    hasErrorsInExecution = true;
                    OnExecuteEnd();

                    return;
                }

                for (int i = 0; i < transforms.Count; i++)
                {
                    transform = Model.inReverse ? transforms[transforms.Count - i - 1] : transforms[i];
                    NodeFlowData data = p_flowData.Clone();
                    data.SetAttribute("target", transform);

                    if (Model.delay.GetValue(ParameterResolver) == 0)
                    {
                        OnExecuteOutput(0, data);
                    }
                    else
                    {
                        float     time  = Model.delay.GetValue(ParameterResolver) * i;
                        DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);
                        tween.OnComplete(() =>
                        {
                            _activeTweens.Remove(tween);
                            OnExecuteOutput(0, data);
                        });
                        tween.Start();
                        _activeTweens.Add(tween);
                    }
                }

                if (Model.delay.GetValue(ParameterResolver) == 0)
                {
                    OnExecuteEnd();
                }
                else
                {
                    float     time  = Model.delay.GetValue(ParameterResolver) * transforms.Count;
                    DashTween tween = DashTween.To(Graph.Controller, 0, 1, time);
                    tween.OnComplete(() =>
                    {
                        _activeTweens.Remove(tween);
                        OnExecuteEnd();
                    });
                    tween.Start();
                    _activeTweens.Add(tween);
                }
            }
            else
            {
                Debug.LogWarning("Zero valid retargets found in node " + _model.id);

                hasErrorsInExecution = true;
                OnExecuteEnd();
            }
        }