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(); } }
public void Execute(NodeFlowData p_flowData) { ExecutionCount++; #if UNITY_EDITOR if (!_hasDebugOverride) { DashEditorDebug.Debug(new NodeDebugItem(NodeDebugItem.NodeDebugItemType.EXECUTE, Graph.Controller, Graph.GraphPath, _model.id, p_flowData.GetAttribute<Transform>("target"))); } executeTime = 1; #endif OnExecuteStart(p_flowData == null ? new NodeFlowData() : p_flowData.Clone()); }
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(); } }
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(); } }
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); }