root/src/BRAINSFramework/Behaviors/PathFinding/CyclicPathBehavior.cs

1322
17
    /// A list of AIBehaviourGoto instances is being build and added to local 
17
    /// A list of AIBehaviourGoto instances is being build and added to local 
18
    /// subbehaviours container.
18
    /// subbehaviours container.
19
    /// </summary>
19
    /// </summary>
20
    public class CyclicPathBehavior : BehaviorBase,IActionBehavior
20
    public class CyclicPathBehavior : CompositeBehavior,IActionBehavior
21
    {
21
    {
22
22
23
        protected List<GridCell> nodesToVisit;
23
        protected List<GridCell> nodesToVisit;
...
...
79
                if (Owner != null)
79
                if (Owner != null)
80
                {
80
                {
81
                    // 1 add goto behaviour from character position to first node
81
                    // 1 add goto behaviour from character position to first node
82
                    BehaviorBase newBehaviour = new GoToBehavior();
82
                    CompositeBehavior newBehaviour = new GoToBehavior();
83
                    newBehaviour.SetOwner(this.Owner);
83
                    newBehaviour.SetOwner(this.Owner);
84
                    //newBehaviour.gr= this.Map;
84
                    //newBehaviour.gr= this.Map;
85
85
86
                    // loop
86
                    // loop
87
                    for (int index = 0; index < nodesToVisit.Count - 1; index++)
87
                    for (int index = 0; index < nodesToVisit.Count - 1; index++)
88
                    {
88
                    {
89
                        BehaviorBase newIBehaviour = new GoToBehavior();
89
                        CompositeBehavior newIBehaviour = new GoToBehavior();
90
                        newIBehaviour.SetOwner(this.Owner);
90
                        newIBehaviour.SetOwner(this.Owner);
91
                        ((GoToBehavior)(newIBehaviour)).StartNode = nodesToVisit[index];
91
                        ((GoToBehavior)(newIBehaviour)).StartNode = nodesToVisit[index];
92
                        ((GoToBehavior)(newIBehaviour)).EndNode = nodesToVisit[index + 1];
92
                        ((GoToBehavior)(newIBehaviour)).EndNode = nodesToVisit[index + 1];