Ejemplo n.º 1
0
        private void AddNodeElements()
        {
            Type t = DotaAction.GetType();

            InputExecute = new ExecuteNodeItem("Execute", NodeItemType.Input);
            this.AddItem(InputExecute);

            OutputExecute = new ExecuteNodeItem("Execute", NodeItemType.Output);
            this.AddItem(OutputExecute);

            //Loop through all of this action's properties and add node elements for each property type
            PropertyInfo[] properties = t.GetProperties();

            //Target should always be ordered first
            var target = properties.FirstOrDefault(x => x.Name == "Target");

            if (target != null)
            {
                TargetPin     = new TargetNodeItem(target.Name, NodeItemType.Input);
                TargetPin.Tag = "Target";
                this.AddItem(TargetPin);
            }


            foreach (PropertyInfo prop in properties)
            {
                //Skip DotaDataObject's properties as they don't go into the node
                if (prop.Name == "ClassName")
                {
                    continue;
                }
                if (prop.Name == "KeyValue")
                {
                    continue;
                }
                if (prop.Name == "ObjectInfo")
                {
                    continue;
                }
                if (prop.Name == "Target")
                {
                    continue;                        //Skip target because we handled it already
                }
                NodeItem item = null;
                if (prop.PropertyType == typeof(NumberValue))
                {
                    item = new NumberValueItem(prop.Name, 20, 20, 0, 100, 0, NodeItemType.Input);
                }
                if (prop.PropertyType == typeof(TargetKey))
                {
                    item = new TargetNodeItem(prop.Name, NodeItemType.Input);
                }
                if (prop.PropertyType == typeof(DotaActionCollection))
                {
                    item = new ExecuteNodeItem(prop.Name, NodeItemType.Output);

                    var ex = item as ExecuteNodeItem;
                    ex.ActionCollection = prop.GetMethod.Invoke(DotaAction, new object[] { }) as DotaActionCollection; //Assign this execute node as the end point
                                                                                                                       //for an action collection execute chain
                }

                if (item == null)
                {
                    item = new NodeLabelItem(prop.Name, NodeItemType.Input);
                }

                item.Tag = prop.Name;
                this.AddItem(item);
            }
        }
Ejemplo n.º 2
0
        protected void AddInputPins()
        {
            //We have different pins based on the properties of of the Target, so lets create them!

            TargetKey.ShapeE Shape = Target.Shape;

            var Properties = Target.GetType().GetProperties();

            foreach (var prop in Properties)
            {
                if (prop.Name == "ClassName")
                {
                    continue;
                }
                if (prop.Name == "ObjectInfo")
                {
                    continue;
                }
                if (prop.Name == "KeyValue")
                {
                    continue;                          //Skip the KV property
                }
                if (prop.Name == "Preset")
                {
                    continue;                        //We aren't a preset, skip this property
                }
                if (prop.Name == "IsPreset")
                {
                    continue;                          //Same as preset
                }
                if (prop.Name == "Shape")
                {
                    continue;                         //The title of the node displays this
                }
                if (Shape == TargetKey.ShapeE.CIRCLE) //Skip the Line properties
                {
                    if (prop.Name == "Length")
                    {
                        continue;
                    }
                    if (prop.Name == "Thickness")
                    {
                        continue;
                    }
                }
                if (Shape == TargetKey.ShapeE.LINE) //Skip the circle properties
                {
                    if (prop.Name == "Center")
                    {
                        continue;
                    }
                    if (prop.Name == "Radius")
                    {
                        continue;
                    }
                }

                NodeItem item = null;
                if (prop.PropertyType == typeof(NumberValue))
                {
                    item = new NumberValueItem(prop.Name, 20, 20, 0, 100, 0, NodeItemType.Input);
                }
                if (item == null)
                {
                    item = new NodeLabelItem(prop.Name, NodeItemType.Input);
                }

                item.Tag = prop.Name;

                this.AddItem(item);
            }
        }