示例#1
0
        protected override void OnExecuteStart(NodeFlowData p_flowData)
        {
            Transform target = p_flowData.GetAttribute <Transform>(NodeFlowDataReservedAttributes.TARGET);

            if (Model.prefab == null)
            {
                OnExecuteEnd();
                OnExecuteOutput(0, p_flowData);
                return;
            }

            RectTransform spawned = null;

            if (Model.usePooling)
            {
                if (_prefabPool == null)
                {
                    _prefabPool = DashCore.Instance.GetOrCreatePrefabPool(GetParameterValue(Model.poolId, p_flowData), Model.prefab);
                }
                spawned = _prefabPool.Get() as RectTransform;

                if (spawned == null)
                {
                    SetError("Prefab instance is not a RectTransform");
                }
            }
            else
            {
                spawned = GameObject.Instantiate(Model.prefab);
            }

            if (Model.setTargetAsParent)
            {
                spawned.transform.SetParent(target, false);
            }

            spawned.anchoredPosition = GetParameterValue(Model.position, p_flowData);

            if (Model.retargetToSpawned)
            {
                p_flowData.SetAttribute(NodeFlowDataReservedAttributes.TARGET, spawned.transform);
            }
            else if (Model.createSpawnedAttribute)
            {
                if (string.IsNullOrEmpty(Model.spawnedAttributeName))
                {
                    SetError("Attribute name cannot be empty");
                }

                p_flowData.SetAttribute <Transform>(Model.spawnedAttributeName, spawned);
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
示例#2
0
        DashTween ExecuteAs(CanvasGroup p_target, NodeFlowData p_flowData)
        {
            float startAlpha = Model.useFrom
                ? Model.isFromRelative
                    ? p_target.alpha + GetParameterValue(Model.fromAlpha, p_flowData)
                    : GetParameterValue(Model.fromAlpha, p_flowData)
                : p_target.alpha;
            float toAlpha = GetParameterValue(Model.toAlpha, p_flowData);

            float    time     = GetParameterValue(Model.time, p_flowData);
            float    delay    = GetParameterValue(Model.delay, p_flowData);
            EaseType easeType = GetParameterValue(Model.easeType, p_flowData);

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <float>(attribute, p_target.alpha);
            }

            if (time == 0)
            {
                UpdateTween(p_target, 1, p_flowData, startAlpha, toAlpha, easeType);

                return(null);
            }
            else
            {
                return(DashTween.To(p_target, 0, 1, time)
                       .OnUpdate(f => UpdateTween(p_target, f, p_flowData, startAlpha, toAlpha, easeType))
                       .SetDelay(delay));
            }
        }
示例#3
0
        DashTween ExecuteAs(Image p_target, NodeFlowData p_flowData)
        {
            Color startColor = Model.useFrom ? GetParameterValue(Model.fromColor, p_flowData) : p_target.color;
            Color toColor    = GetParameterValue <Color>(Model.toColor, p_flowData);

            float    time     = GetParameterValue(Model.time, p_flowData);
            float    delay    = GetParameterValue(Model.delay, p_flowData);
            EaseType easeType = GetParameterValue(Model.easeType, p_flowData);

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Color>(attribute, p_target.color);
            }

            if (time == 0)
            {
                UpdateTween(p_target, 1, p_flowData, startColor, toColor);

                return(null);
            }
            else
            {
                return(DashTween.To(p_target, 0, 1, time)
                       .OnUpdate(f => UpdateTween(p_target, f, p_flowData, startColor, toColor))
                       .SetDelay(delay).SetEase(easeType));
            }
        }
示例#4
0
        override protected void OnExecuteStart(NodeFlowData p_flowData)
        {
            if (!Model.attributeName.IsNullOrWhitespace() && !Model.expression.IsNullOrWhitespace())
            {
                if (!p_flowData.HasAttribute(Model.attributeName) ||
                    p_flowData.GetAttributeType(Model.attributeName) == Model.attributeType)
                {
                    var value = ExpressionEvaluator.EvaluateTypedExpression(Model.expression, Model.attributeType,
                                                                            ParameterResolver, p_flowData);

                    if (ExpressionEvaluator.hasErrorInEvaluation)
                    {
                        SetError(ExpressionEvaluator.errorMessage);
                        return;
                    }

                    p_flowData.SetAttribute(Model.attributeName, value);
                }
                else
                {
                    Debug.LogWarning("Changing flow data attribute type at runtime not allowed.");
                }
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
示例#5
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            Vector3 fromPosition = GetParameterValue <Vector3>(Model.fromPosition, p_flowData);

            Vector3 startPosition = Model.useFrom
                ? Model.isFromRelative
                    ? p_target.position + fromPosition
                    : fromPosition
                : p_target.position;

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Vector3>(attribute, p_target.position);
            }

            Vector3  finalPosition = GetParameterValue <Vector3>(Model.toPosition, p_flowData);
            EaseType easeType      = GetParameterValue(Model.easeType, p_flowData);

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

            if (time == 0)
            {
                UpdateTween(p_target, 1, p_flowData, startPosition, finalPosition, easeType);
                return(null);
            }

            return(DashTween.To(p_target, 0, 1, time).SetDelay(delay)
                   .OnUpdate(f => UpdateTween(p_target, f, p_flowData, startPosition, finalPosition, easeType)));
        }
示例#6
0
        public void SendEvent(string p_name, Transform p_target)
        {
            NodeFlowData flowData = new NodeFlowData();

            flowData.SetAttribute(NodeFlowDataReservedAttributes.TARGET, p_target);

            SendEvent(p_name, flowData);
        }
示例#7
0
        static public NodeFlowData Create(Transform p_target)
        {
            NodeFlowData nfd = new NodeFlowData();

            nfd.SetAttribute(NodeFlowDataReservedAttributes.TARGET, p_target);

            return(nfd);
        }
示例#8
0
        public void SendEvent(string p_name, NodeFlowData p_flowData)
        {
            if (Graph == null || GetTarget() == null)
            {
                return;
            }

            p_flowData = p_flowData == null?NodeFlowDataFactory.Create(GetTarget()) : p_flowData.Clone();

            if (!p_flowData.HasAttribute(NodeFlowDataReservedAttributes.TARGET))
            {
                p_flowData.SetAttribute(NodeFlowDataReservedAttributes.TARGET, GetTarget());
            }

            p_flowData.SetAttribute(NodeFlowDataReservedAttributes.EVENT, p_name);

            Graph.SendEvent(p_name, p_flowData);
        }
示例#9
0
        protected override void OnExecuteStart(NodeFlowData p_flowData)
        {
            Transform target = p_flowData.GetAttribute <Transform>(NodeFlowDataReservedAttributes.TARGET);

            GameObject spawned = new GameObject();

            spawned.name = Model.spawnedName;
            if (Model.setTargetAsParent)
            {
                spawned.transform.SetParent(target, false);
            }

            Image image = spawned.AddComponent <Image>();

            image.sprite = GetParameterValue(Model.sprite, p_flowData);
            RectTransform rectTransform = image.GetComponent <RectTransform>();

            rectTransform.anchoredPosition = GetParameterValue(Model.position, p_flowData);

            if (GetParameterValue(Model.setNativeSize, p_flowData))
            {
                image.SetNativeSize();
            }

            image.maskable      = GetParameterValue(Model.isMaskable, p_flowData);
            image.raycastTarget = GetParameterValue(Model.isRaycastTarget, p_flowData);

            if (Model.retargetToSpawned)
            {
                p_flowData.SetAttribute(NodeFlowDataReservedAttributes.TARGET, spawned.transform);
            }
            else if (Model.createSpawnedAttribute)
            {
                if (string.IsNullOrEmpty(Model.spawnedAttributeName))
                {
                    SetError("Attribute name cannot be empty");
                }

                p_flowData.SetAttribute <Transform>(Model.spawnedAttributeName, rectTransform);
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
示例#10
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;
            }

            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();
            }
        }
示例#11
0
        protected override void OnExecuteStart(NodeFlowData p_flowData)
        {
            Vector2       mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            RectTransform rect     = Controller.GetComponent <RectTransform>();
            Vector2       point;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, mousePos, Camera.main, out point);
            p_flowData.SetAttribute("mousePosition", point);

            OnExecuteOutput(0, p_flowData);
            OnExecuteEnd();
        }
示例#12
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            Transform targetTransform = p_target.transform;

            if (CheckException(targetTransform, "No RectTransform component found on target"))
            {
                return(null);
            }

            // TODO skip this if not using from rotation
            Vector3 fromRotation = GetParameterValue(Model.fromRotation, p_flowData);

            fromRotation.x = fromRotation.x > 180 ? fromRotation.x - 360 : fromRotation.x;
            fromRotation.y = fromRotation.y > 180 ? fromRotation.y - 360 : fromRotation.y;
            fromRotation.z = fromRotation.z > 180 ? fromRotation.z - 360 : fromRotation.z;

            Quaternion startRotation = Model.useFrom
                ? Model.isFromRelative
                    ? targetTransform.rotation * Quaternion.Euler(fromRotation)
                    : Quaternion.Euler(fromRotation)
                : targetTransform.rotation;

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Quaternion>(attribute, targetTransform.rotation);
            }

            Vector3 toRotation = GetParameterValue <Vector3>(Model.toRotation, p_flowData);

            float    time   = GetParameterValue(Model.time, p_flowData);
            float    delay  = GetParameterValue(Model.delay, p_flowData);
            EaseType easing = GetParameterValue(Model.easeType, p_flowData);

            if (time == 0)
            {
                UpdateTween(targetTransform, 1, p_flowData, startRotation, toRotation, easing);
                return(null);
            }
            else
            {
                // Virtual tween to update from directly
                // Tween tween = DOTween
                //     .To((f) => UpdateTween(targetTransform, f, p_flowData, startRotation, toRotation, easing), 0,
                //         1, time)
                //     .SetDelay(delay)
                //     .SetEase(Ease.Linear);
                return(DashTween.To(targetTransform, 0, 1, time)
                       .SetDelay(delay)
                       .OnUpdate(f => UpdateTween(targetTransform, f, p_flowData, startRotation, toRotation, easing)));
            }
        }
示例#13
0
        public void SendEvent(string p_name, NodeFlowData p_flowData)
        {
            p_flowData.SetAttribute(NodeFlowDataReservedAttributes.EVENT, p_name);

            if (_nodeListeners.ContainsKey(p_name))
            {
                _nodeListeners[p_name].ToList().ForEach(e => e.Invoke(p_flowData));
            }

            if (_callbackListeners.ContainsKey(p_name))
            {
                _callbackListeners[p_name].ToList().ForEach(c => c.Invoke(p_flowData));
            }
        }
示例#14
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            Transform targetTransform = p_target.transform;

            if (CheckException(targetTransform, "No RectTransform component found on target"))
            {
                return(null);
            }

            Vector3 fromScale = GetParameterValue(Model.fromScale, p_flowData);

            Vector3 startScale = Model.useFrom
                ? Model.isFromRelative
                    ? targetTransform.localScale + Model.fromScale.GetValue(ParameterResolver, p_flowData)
                    : fromScale
                : targetTransform.localScale;

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Vector3>(attribute, targetTransform.localScale);
            }

            Vector3 toScale = GetParameterValue(Model.toScale, p_flowData);

            float    time     = GetParameterValue(Model.time, p_flowData);
            float    delay    = GetParameterValue(Model.delay, p_flowData);
            EaseType easeType = GetParameterValue(Model.easeType, p_flowData);

            if (time == 0)
            {
                UpdateTween(targetTransform, 1, p_flowData, startScale, toScale, easeType);

                return(null);
            }
            else
            {
                // Virtual tween to update from directly
                return(DashTween.To(targetTransform, 0, 1, time)
                       .OnUpdate(f => UpdateTween(targetTransform, f, p_flowData, startScale, toScale, easeType))
                       .SetDelay(delay));
            }
        }
示例#15
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            RectTransform rectTransform = p_target.GetComponent <RectTransform>();

            if (CheckException(rectTransform, "Target doesn't contain RectTransform"))
            {
                return(null);
            }

            Vector2 fromSizeDelta = GetParameterValue(Model.fromSizeDelta, p_flowData);

            Vector2 startSizeDelta = Model.useFrom
                ? Model.isFromRelative
                    ? rectTransform.sizeDelta + fromSizeDelta
                    : fromSizeDelta
                : rectTransform.sizeDelta;

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Vector2>(attribute, rectTransform.sizeDelta);
            }

            Vector2 toSizeDelta = GetParameterValue(Model.toSizeDelta, p_flowData);

            float    time     = GetParameterValue(Model.time, p_flowData);
            float    delay    = GetParameterValue(Model.delay, p_flowData);
            EaseType easeType = GetParameterValue(Model.easeType, p_flowData);

            if (time == 0)
            {
                UpdateTween(rectTransform, 1, p_flowData, startSizeDelta, toSizeDelta, easeType);

                return(null);
            }
            else
            {
                // Virtual tween to update from directly
                return(DashTween.To(rectTransform, 0, 1, time).SetDelay(delay)
                       .OnUpdate(f => UpdateTween(rectTransform, f, p_flowData, startSizeDelta, toSizeDelta, easeType)));
            }
        }
示例#16
0
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            bool includeTarget = GetParameterValue(Model.includeTarget, p_flowData);

            Dictionary <Transform, TransformStorageData> storage = new Dictionary <Transform, TransformStorageData>();

            if (includeTarget)
            {
                storage.Add(p_target, new TransformStorageData(p_target.transform, GetStorageFlag()));
            }

            StoreChildren(p_target, storage);

            switch (Model.storageType)
            {
            case StorageType.ATTRIBUTE:
                p_flowData.SetAttribute(Model.storageName, storage);
                break;

            case StorageType.VARIABLE:
                if (Graph.variables.HasVariable(Model.storageName))
                {
                    var variable = Graph.variables.GetVariable(Model.storageName);
                    if (variable.GetVariableType() != typeof(Dictionary <Transform, TransformStorageData>))
                    {
                        SetError("Cannot store data to existing variable of incompatible type " +
                                 variable.GetVariableType());
                        return;
                    }

                    variable.value = storage;
                }
                else
                {
                    Graph.variables.AddVariable(Model.storageName, storage);
                }
                break;
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
示例#17
0
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            Image image = p_target.GetComponent <Image>();

            if (CheckException(image, "Target doesn't contain Image component"))
            {
                return;
            }

            bool storeSpriteToAttribute = GetParameterValue(Model.storeSpriteToAttribute, p_flowData);

            if (storeSpriteToAttribute)
            {
                string attribute = GetParameterValue(Model.storeSpriteAttributeName, p_flowData);
                p_flowData.SetAttribute <Sprite>(attribute, image.sprite);
            }

            if (Model.setSprite)
            {
                image.sprite = GetParameterValue(Model.sprite, p_flowData);
            }

            if (GetParameterValue(Model.setNativeSize, p_flowData))
            {
                image.SetNativeSize();
            }

            if (Model.setIsMaskable)
            {
                image.maskable = GetParameterValue(Model.isMaskable, p_flowData);
            }

            if (Model.setIsRaycastTarget)
            {
                image.raycastTarget = GetParameterValue(Model.isRaycastTarget, p_flowData);
            }

            OnExecuteEnd();
            OnExecuteOutput(0, p_flowData);
        }
示例#18
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            RectTransform rectTransform = p_target.GetComponent <RectTransform>();

            if (CheckException(rectTransform, "No RectTransform component found on target"))
            {
                return(null);
            }

            Vector2 fromPosition = GetParameterValue <Vector2>(Model.fromPosition, p_flowData);

            Vector2 startPosition = Model.useFrom
                ? Model.isFromRelative
                    ? rectTransform.anchoredPosition + fromPosition
                    : fromPosition
                : rectTransform.anchoredPosition;

            if (Model.storeToAttribute)
            {
                string attribute = GetParameterValue(Model.storeAttributeName, p_flowData);
                p_flowData.SetAttribute <Vector2>(attribute, rectTransform.anchoredPosition);
            }

            Vector2  finalPosition = GetParameterValue <Vector2>(Model.toPosition, p_flowData);
            EaseType easeType      = GetParameterValue(Model.easeType, p_flowData);

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

            if (time == 0)
            {
                UpdateTween(rectTransform, 1, p_flowData, startPosition, finalPosition, easeType);
                return(null);
            }

            return(DashTween.To(rectTransform, 0, 1, time).SetDelay(delay)
                   .OnUpdate(f => UpdateTween(rectTransform, f, p_flowData, startPosition, finalPosition, easeType)));
        }
示例#19
0
        protected override DashTween AnimateOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            // Position

            bool    usePosition              = GetParameterValue(Model.usePosition, p_flowData);
            bool    useFromPosition          = GetParameterValue(Model.useFromPosition, p_flowData);
            Vector3 fromPosition             = GetParameterValue(Model.fromPosition, p_flowData);
            bool    isFromPositionRelative   = GetParameterValue(Model.isFromPositionRelative, p_flowData);
            bool    storePositionToAttribute = GetParameterValue(Model.storePositionToAttribute, p_flowData);

            Vector3 startPosition = useFromPosition
                ? isFromPositionRelative
                    ? p_target.position + fromPosition
                    : fromPosition
                : p_target.position;

            if (storePositionToAttribute)
            {
                string attribute = GetParameterValue(Model.storePositionAttributeName, p_flowData);
                p_flowData.SetAttribute(attribute, p_target.position);
            }

            Vector3  finalPosition        = GetParameterValue(Model.toPosition, p_flowData);
            bool     isToPositionRelative = GetParameterValue(Model.isToPositionRelative, p_flowData);
            EaseType easeType             = GetParameterValue(Model.easeType, p_flowData);

            // Rotation
            bool useRotation     = GetParameterValue(Model.useRotation, p_flowData);
            bool useFromRotation = GetParameterValue(Model.useFromRotation, p_flowData);

            Vector3 fromRotation = GetParameterValue(Model.fromRotation, p_flowData);

            fromRotation.x = fromRotation.x > 180 ? fromRotation.x - 360 : fromRotation.x;
            fromRotation.y = fromRotation.y > 180 ? fromRotation.y - 360 : fromRotation.y;
            fromRotation.z = fromRotation.z > 180 ? fromRotation.z - 360 : fromRotation.z;

            bool isFromRotationRelative = GetParameterValue(Model.isFromRotationRelative, p_flowData);

            Quaternion startRotation = useFromPosition
                ? isFromPositionRelative
                    ? p_target.rotation * Quaternion.Euler(fromRotation)
                    : Quaternion.Euler(fromRotation)
                : p_target.rotation;

            bool storeRotationToAttribute = GetParameterValue(Model.storeRotationToAttribute, p_flowData);

            if (storeRotationToAttribute)
            {
                string attribute = GetParameterValue(Model.storeRotationAttributeName, p_flowData);
                p_flowData.SetAttribute <Quaternion>(attribute, p_target.rotation);
            }

            Vector3 toRotation = GetParameterValue <Vector3>(Model.toRotation, p_flowData);

            // Scale
            bool    useScale            = GetParameterValue(Model.useScale, p_flowData);
            bool    useFromScale        = GetParameterValue(Model.useFromScale, p_flowData);
            Vector3 fromScale           = GetParameterValue(Model.fromScale, p_flowData);
            bool    isFromScaleRelative = GetParameterValue(Model.isFromScaleRelative, p_flowData);

            Vector3 startScale = useFromScale
                ? isFromScaleRelative
                    ? p_target.localScale + Model.fromScale.GetValue(ParameterResolver, p_flowData)
                    : fromScale
                : p_target.localScale;

            bool storeScaleToAttribute = GetParameterValue(Model.storeScaleToAttribute, p_flowData);

            if (storeScaleToAttribute)
            {
                string attribute = GetParameterValue(Model.storeScaleAttributeName, p_flowData);
                p_flowData.SetAttribute <Vector3>(attribute, p_target.localScale);
            }

            Vector3 toScale           = GetParameterValue(Model.toScale, p_flowData);
            bool    isToScaleRelative = GetParameterValue(Model.isToScaleRelative, p_flowData);

            // Animation

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

            if (time == 0)
            {
                if (usePosition)
                {
                    UpdatePositionTween(p_target, 1, p_flowData, startPosition, finalPosition, isToPositionRelative, easeType);
                }
                if (useRotation)
                {
                    UpdateRotationTween(p_target, 1, p_flowData, startRotation, toRotation, isToPositionRelative, easeType);
                }
                if (useScale)
                {
                    UpdateScaleTween(p_target, 1, p_flowData, startScale, toScale, isToScaleRelative, easeType);
                }
                return(null);
            }

            return(DashTween.To(p_target, 0, 1, time).SetDelay(delay)
                   .OnUpdate(f =>
            {
                if (usePosition)
                {
                    UpdatePositionTween(p_target, f, p_flowData, startPosition, finalPosition, isToPositionRelative,
                                        easeType);
                }
                if (useRotation)
                {
                    UpdateRotationTween(p_target, f, p_flowData, startRotation, toRotation, isToPositionRelative,
                                        easeType);
                }
                if (useScale)
                {
                    UpdateScaleTween(p_target, f, p_flowData, startScale, toScale, isToScaleRelative, easeType);
                }
            }));
        }
示例#20
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();
            }
        }
示例#21
0
        protected override void ExecuteOnTarget(Transform p_target, NodeFlowData p_flowData)
        {
            p_flowData.SetAttribute("target", p_target);

            ExecuteEnd(p_flowData);
        }
示例#22
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();
            }
        }