public NodeParameterSchema(Node node, NodeParameter nodeParameter) { this.node = node; this.nodeParameter = nodeParameter; this.Id = this.nodeParameter.Id; this.Name = this.nodeParameter.Name; this.Type = this.nodeParameter.ValueType.FullName; if (!nodeParameter.IsDynamic) { if (nodeParameter.ValueType == typeof(Node)) { if (this.nodeParameter.Value != null) { this.Value = (this.nodeParameter.Value as Node).Id; } this.ValueIsReference = true; } else { this.ValueIsReference = false; this.Value = this.nodeParameter.Value; } } this.Assignment = this.nodeParameter.Assignments != null ? this.nodeParameter.Assignments.Id : string.Empty; this.AssignmentNode = this.nodeParameter.Assignments != null?node.Graph.FindParameterNodeById(this.nodeParameter.Assignments.Id).Id : string.Empty; }
public bool AddParameter(List <NodeParameter> parameterList, NodeParameter parameter) { bool result = true; if (string.IsNullOrEmpty(parameter.parameterName)) { string meg = string.Format("条件参数不能为空", parameter.parameterName); TreeNodeWindow.window.ShowNotification(meg); result = false; } for (int i = 0; i < parameterList.Count; ++i) { NodeParameter tempParameter = parameterList[i]; if (tempParameter.parameterName.CompareTo(parameter.parameterName) == 0) { string meg = string.Format("条件参数:{0} 已存在", parameter.parameterName); TreeNodeWindow.window.ShowNotification(meg); result = false; break; } } if (result) { NodeParameter newParameter = parameter.Clone(); parameterList.Add(newParameter); for (int i = 0; i < parameterList.Count; ++i) { parameterList[i].index = i; } } return(result); }
public void DataDelGlobalParameter(NodeParameter parameter) { BehaviorTreeData behaviorTreeData = BehaviorDataController.Instance.BehaviorTreeData; DataParameterHandler dataParameterHandler = new DataParameterHandler(); dataParameterHandler.DelParameter(behaviorTreeData.parameterList, parameter); }
public void Draw(List <NodeParameter> parameterList) { EditorGUILayout.LabelField("运行时变量"); EditorGUILayout.BeginVertical("box", GUILayout.ExpandWidth(true)); { EditorGUILayout.LabelField("条件参数"); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(true)); { GUI.backgroundColor = new Color(0.85f, 0.85f, 0.85f, 1f); for (int i = 0; i < parameterList.Count; ++i) { NodeParameter behaviorParameter = parameterList[i]; EditorGUILayout.BeginVertical("box"); { behaviorParameter = DrawParameter.Draw(behaviorParameter, DrawParameterType.RUNTIME_PARAMETER, null); } EditorGUILayout.EndVertical(); } GUI.backgroundColor = Color.white; } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }
private List <NodeParameter> GetParameterList(JsonData data) { List <NodeParameter> dataList = new List <NodeParameter>(); foreach (JsonData item in data) { NodeParameter parameter = new NodeParameter(); parameter.parameterType = int.Parse(item["parameterType"].ToString()); parameter.parameterName = item["parameterName"].ToString(); if (((IDictionary)item).Contains("CNName")) { parameter.CNName = item["CNName"].ToString(); } parameter.intValue = int.Parse(item["intValue"].ToString()); if (((IDictionary)item).Contains("longValue")) { parameter.longValue = long.Parse(item["longValue"].ToString()); } parameter.floatValue = float.Parse(item["floatValue"].ToString(), System.Globalization.CultureInfo.InvariantCulture); parameter.boolValue = bool.Parse(item["boolValue"].ToString()); parameter.stringValue = item["stringValue"].ToString(); parameter.compare = int.Parse(item["compare"].ToString()); dataList.Add(parameter); } return(dataList); }
/// <summary> /// Add a new generic parameter. /// </summary> /// <typeparam name="T">The type of the generic.</typeparam> /// <param name="keyName">The name of the generic.</param> /// <param name="generics">The target GenericDictionary.</param> private void AddKey <T>(string keyName, GenericDictionary generics) { INodeParameter nodeParameter; var typeT = typeof(T); if (typeT == typeof(string)) { nodeParameter = new NodeParameter(); } else if (typeT == typeof(Texture2D)) { nodeParameter = new NodeParameterTexture(); } else if (typeT == typeof(float)) { nodeParameter = new NodeParameterFloat(); } else if (typeT == typeof(int)) { nodeParameter = new NodeParameterInt(); } else if (typeT == typeof(Vector2)) { nodeParameter = new NodeParameterFloat2(); } else if (typeT == typeof(Vector3)) { nodeParameter = new NodeParameterFloat3(); } else if (typeT == typeof(Vector4)) { nodeParameter = new NodeParameterFloat4(); } else if (typeT == typeof(SamplerState)) { nodeParameter = new NodeParameterSampler(); } else { throw new Exception("Unsupported generic format"); } if (Generics.ContainsKey(keyName)) { var gen = Generics[keyName]; if (gen == null || gen.GetType() != nodeParameter.GetType()) { generics[keyName] = nodeParameter; } else { generics[keyName] = gen; } } else { generics.Add(keyName, nodeParameter); } }
void Add(NodeParameter parameter) { NodeParameterRestoreData data = new NodeParameterRestoreData { parameterReference = parameter, type = parameter.type }; m_nodeParameters.Add(data); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "connection") { return(this); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "count") { return((this.InParameters["csv"].GetValue() as CreateCSVNode).Rows.Count); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "csvOut") { return(this.InParameters["csv"].GetValue()); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "base64") { return(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(this.InParameters["string"].GetValue().ToString()))); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "output") { return(new KeyValuePair <object, object>(this.InParameters["key"].GetValue().ToString(), this.InParameters["value"].GetValue().ToString())); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "json") { return(JsonConvert.SerializeObject(this.InParameters["object"].GetValue())); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "timestamp") { return(DateTimeOffset.Now.ToUnixTimeMilliseconds()); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "hostedAPI") { return(this.HostedAPI); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { return(this.Graph.MemoryVariables[this.InParameters["variableName"].GetValue().ToString()]); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { return(RedisStorage.GetGraphKeyItem(this.Graph, this.InParameters["key"].GetValue().ToString())); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "liveCoinWatch") { return(this); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "element") { var array = this.InParameters["array"].GetValue() as List <object>; return(array[int.Parse(this.InParameters["index"].GetValue().ToString())]); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { var requestContext = this.InParameters["requestContext"].GetValue() as RequestContext; return(requestContext.Context.Request.Query[this.InParameters["key"].GetValue().ToString()].ToString()); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "dateString") { var date = this.InParameters["date"].GetValue() as DateTime?; return(date.Value.ToString(this.InParameters["format"].GetValue().ToString())); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "jsonObject") { var jsonObject = JObject.Parse(this.InParameters["json"].GetValue().ToString()); return(jsonObject); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "size") { var array = this.InParameters["array"].GetValue() as List <object>; return(array.Count); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { var varA = Double.Parse(this.InParameters["a"].GetValue().ToString()); var varB = Double.Parse(this.InParameters["b"].GetValue().ToString()); return(varA - varB); } return(base.ComputeParameterValue(parameter, value)); }
public void NodeAddParameter(int nodeId, NodeParameter parameter) { NodeValue nodeValue = BehaviorDataController.Instance.GetNode(nodeId); if (null != nodeValue) { DataParameterHandler dataParameterHandler = new DataParameterHandler(); dataParameterHandler.AddParameter(nodeValue.parameterList, parameter); } }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { var context = this.Graph.currentCycle.CurrentFunctionContext; var name = this.InParameters["name"].GetValue().ToString(); return(context.CallParameters[name]); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "array") { var json = this.InParameters["json"].GetValue().ToString(); var jsonObject = JsonConvert.DeserializeObject <List <object> >(json); return(jsonObject); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { var number = Double.Parse(this.InParameters["number"].GetValue().ToString()); return(global::System.Math.Floor(number)); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "returnText") { var original = this.InParameters["string"].GetValue().ToString(); var regex = this.InParameters["regex"].GetValue().ToString(); return(Regex.Match(original, regex).Value); } return(base.ComputeParameterValue(parameter, value)); }
public override object ComputeParameterValue(NodeParameter parameter, object value) { if (parameter.Name == "value") { var varA = Double.Parse(this.InParameters["a"].GetValue().ToString()); var varB = Double.Parse(this.InParameters["b"].GetValue().ToString()); return(((varB - varA) / global::System.Math.Abs(varA)) * 100); } return(base.ComputeParameterValue(parameter, value)); }
public void InitNodeFromDescriptor(NodeDescriptor descriptor) { nodeType = descriptor.nodeType; nodeName = descriptor.nodeName; titleBarColor = descriptor.titleBarColor; timePointer = new TimePointer(); timePointer.hasTiming = descriptor.hasTiming; timePointer.InitTimePointer(descriptor.defaultAnimationLength); timePointer.parentNode = this; dragButton = new DragButton(); dragButton.InitDragButton(); parameters = new ParameterDictionary(); foreach (KeyValuePair<string, NodeParameter> pair in descriptor.parameters) { NodeParameter tempParameter = new NodeParameter(); tempParameter.floatParam = pair.Value.floatParam; tempParameter.stringParam = pair.Value.stringParam; tempParameter.vectorParam = new Vector3(pair.Value.vectorParam.x, pair.Value.vectorParam.y, pair.Value.vectorParam.z); tempParameter.type = pair.Value.type; parameters.Add(pair.Key, tempParameter); } for(int i = 0; i < descriptor.numberOfInputs; i++) { nodeInputs.Add(new NodeInput()); } numberOfInputs = descriptor.numberOfInputs; nodeInputsMin = descriptor.minInputs; nodeInputsMax = descriptor.maxInputs; for (int i = 0; i < descriptor.numberOfOutputs; i++) { nodeOutputs.Add(new NodeOutput()); if(nodeType != NodeType.Graph) nodeOutputs[i].outputNode = this; } numberOfOutputs = descriptor.numberOfOutputs; nodeOutputsMin = descriptor.minOutputs; nodeOutputsMax = descriptor.maxOutputs; multiInput = descriptor.isMultiInput; multiOutput = descriptor.isMultiOutput; nodeRect = new Rect(10f, 10f, 150f, 100f); }
private static List<NodeDescriptor> ProcessNodes(XmlNodeList nodes) { List<NodeDescriptor> list = new List<NodeDescriptor>(); NodeDescriptor nodeDescriptor = null; foreach (XmlNode node in nodes) { nodeDescriptor = new NodeDescriptor(); nodeDescriptor.nodeType = (NodeType)Convert.ToInt16(node.Attributes.GetNamedItem("type").Value); nodeDescriptor.nodeName = node.Attributes.GetNamedItem("name").Value; nodeDescriptor.numberOfInputs = Convert.ToInt16(node.SelectSingleNode("numberOfInputs").Attributes.GetNamedItem("default").Value); nodeDescriptor.minInputs = Convert.ToInt16(node.SelectSingleNode("numberOfInputs").Attributes.GetNamedItem("min").Value); nodeDescriptor.maxInputs = Convert.ToInt16(node.SelectSingleNode("numberOfInputs").Attributes.GetNamedItem("max").Value); nodeDescriptor.numberOfOutputs = Convert.ToInt16(node.SelectSingleNode("numberOfOutputs").Attributes.GetNamedItem("default").Value); nodeDescriptor.minOutputs= Convert.ToInt16(node.SelectSingleNode("numberOfOutputs").Attributes.GetNamedItem("min").Value); nodeDescriptor.maxOutputs = Convert.ToInt16(node.SelectSingleNode("numberOfOutputs").Attributes.GetNamedItem("max").Value); nodeDescriptor.titleBarColor = node.SelectSingleNode("color").InnerText; nodeDescriptor.hasTiming = "true" == node.SelectSingleNode("defaultAnimationLength").Attributes.GetNamedItem("hasTiming").Value; nodeDescriptor.isHidden = "true" == node.SelectSingleNode("isHidden").InnerText; if (nodeDescriptor.hasTiming) nodeDescriptor.defaultAnimationLength = Convert.ToSingle(node.SelectSingleNode("defaultAnimationLength").InnerText); nodeDescriptor.isMultiInput = "true" == node.SelectSingleNode("inputType").Attributes.GetNamedItem("multiInput").Value; nodeDescriptor.isMultiOutput = "true" == node.SelectSingleNode("inputType").Attributes.GetNamedItem("multiOutput").Value; nodeDescriptor.parameters = new ParameterDictionary(); //Loop the parameters foreach (XmlNode parameter in node.SelectNodes("parameters/parameter")) { string key = parameter.Attributes.GetNamedItem("key").Value; Type type = Type.GetType(parameter.Attributes.GetNamedItem("type").Value); NodeParameter value = new NodeParameter(); if(type == typeof(float)) { float temp = Convert.ToSingle(parameter.Attributes.GetNamedItem("value").Value); value.floatParam = temp; value.type = parameter.Attributes.GetNamedItem("type").Value; } if(type == typeof(string)) { string temp = parameter.Attributes.GetNamedItem("value").Value; value.stringParam = temp; value.type = parameter.Attributes.GetNamedItem("type").Value; } if (type == typeof(bool)) { value.boolParam = "true" == parameter.Attributes.GetNamedItem("value").Value; value.type = parameter.Attributes.GetNamedItem("type").Value; } if (parameter.Attributes.GetNamedItem("type").Value == "UnityEngine.Vector3") { float x = Convert.ToSingle(parameter.Attributes.GetNamedItem("x").Value); float y = Convert.ToSingle(parameter.Attributes.GetNamedItem("y").Value); float z = Convert.ToSingle(parameter.Attributes.GetNamedItem("z").Value); value.vectorParam = new Vector3(x,y,z); value.type = "UnityEngine.Vector3"; } nodeDescriptor.parameters.Add(key,value); } list.Add(nodeDescriptor); } return list; }