Example #1
0
        public void OnExecuteNodeChanged(ExecuteNodeItem RootExecuteNode)
        {
            //Clear the Root execute node, then walk through it's connections and add the entries to collection

            DotaActionCollection ActionCollection = RootExecuteNode.ActionCollection;

            ActionCollection.Clear();

            var connection = RootExecuteNode.Connector.Connectors.FirstOrDefault();

            while (connection != null)
            {
                ActionNode node = connection.To.Node as ActionNode;

                if (node == null)
                {
                    break;
                }
                ActionCollection.Add(node.DotaAction);

                connection = node.OutputExecute.Connector.Connectors.FirstOrDefault();
            }

            Console.WriteLine("Complete Collection: " + ActionCollection.ToString());
        }
Example #2
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);
            }
        }
Example #3
0
        private void PlaceEvents()
        {
            GeneratingGraph = true;

            PointF   Position = new PointF(EventColumn, 0);
            Graphics g        = graphControl1.GetLayoutGraphics();


            foreach (DotaActionCollection kvEvents in Ability.ActionList)
            {
                var Event = DotaData.Events.FirstOrDefault(x => x.ClassName == kvEvents.ClassName);

                if (Event.RespectsTargetFlag && Ability.AbilityBehavior.HasFlag(DotaAbility.AbilityBehaviorFlags.DOTA_ABILITY_BEHAVIOR_UNIT_TARGET))
                {
                    //Add the target pin
                    Event.Targets = Event.Targets | DotaEvent.TargetsFlags.TARGET;
                }

                var EventNode = new EventNode(Event, Ability.ActionList.GetActionCollection(Event));
                EventNode.Location = Position;



                EventNode.PerformLayout(g);

                graphControl1.AddNode(EventNode);

                PointF col = Position;
                col.X = EventNode.Bounds.Right + ColumnSpacing; //Move this node to the left of the event node + spacing
                PointF previousCol = col;

                ExecuteNodeItem ExNode = EventNode.OutputExecute;

                float columnHeight = EventNode.Bounds.Height;
                foreach (var kvAction in kvEvents)
                {
                    if (kvAction == null)
                    {
                        continue;
                    }

                    var ActionNode = new ActionNode(kvAction);
                    ActionNode.Location = col;

                    graphControl1.AddNode(ActionNode);
                    ActionNode.PerformLayout(g);

                    //Connect the execute nodes
                    var inputNode = ActionNode.InputExecute;
                    graphControl1.Connect(ExNode, inputNode);
                    ExNode = ActionNode.OutputExecute;

                    ConnectTargets(EventNode, ActionNode);


                    var varRefs = ActionNode.VariableReferences;

                    foreach (var Ref in varRefs)
                    {
                        var pos = previousCol;
                        pos.Y += columnHeight;

                        //Get the data variable for this reference
                        var actionVariable = ability.ActionList.Variables.FirstOrDefault(x => x.Name == Ref.VariableName.Replace("%", ""));
                        if (actionVariable == null)
                        {
                            MessageBox.Show("Found a reference to " + Ref.VariableName + "but could not find it in the variable table!");
                            continue;
                        }

                        //Create the variable node and add it to the graph
                        VariableNode varNode = new VariableNode(actionVariable);
                        varNode.Location = pos;
                        varNode.PerformLayout(g);
                        graphControl1.AddNode(varNode);

                        //Connect it's output to the referenced input pins

                        foreach (var inputPin in Ref.InputPins)
                        {
                            graphControl1.Connect(varNode.OutputPin, inputPin);
                        }

                        columnHeight += varNode.Bounds.Height + VariableSpacing;
                    }


                    //Move the pen right to place the next action node
                    previousCol  = col;
                    col.X        = ActionNode.Bounds.Right + ColumnSpacing;
                    columnHeight = Math.Max(ActionNode.Bounds.Height, columnHeight);
                }


                Position.Y += columnHeight + EventSpacing;
            }

            GeneratingGraph = false;
        }
Example #4
0
 public void AddExecPin()
 {
     OutputExecute = new ExecuteNodeItem("Event", NodeItemType.Output);
     OutputExecute.ActionCollection = ActionCollection; //Assign our action collection, as we are an endpoint
     this.AddItem(OutputExecute);
 }