Ejemplo n.º 1
0
    /// <summary>
    /// Constructs a BehaviorEvent responsible for maintaining a tree
    /// </summary>
    /// <param name="root">The root node of the tree</param>
    /// <param name="priority">The event's priority</param>
    /// <param name="statusChanged">An OnStatusChanged delegate for receiving
    /// status change events</param>
    /// <param name="involvedAgents">The agents involved</param>
    public BehaviorEvent(
        Node root,
        float priority,
        OnStatusChanged statusChanged,
        string name = null,
        params IBehavior[] involved)
    {
        this.treeRoot      = root;
        this.priority      = priority;
        this.statusChanged = statusChanged;
        this.Name          = name;
        this.EventStatus   = Status.Initializing;
        if (BehaviorManager.Instance == null)
        {
            Debug.LogError(this + ": No BehaviorManager!");
        }
        else
        {
            BehaviorManager.RegisterReceiver(this);
        }

        this.involvedAgents = new BehaviorAgent[involved.Length];
        for (int i = 0; i < involvedAgents.Length; i++)
        {
            involvedAgents[i] = involved[i].Agent;
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a new BehaviorAgent responsible for taking care of a tree
 /// </summary>
 /// <param name="root">The root node of the tree</param>
 /// <param name="statusChanged">An OnStatusChanged delegate for receiving
 /// status change events</param>
 public BehaviorAgent(Node root, OnStatusChanged statusChanged)
 {
     this.treeRoot      = root;
     this.pendingEvent  = null;
     this.statusChanged = statusChanged;
     this.AgentStatus   = Status.Idle;
     if (BehaviorManager.Instance == null)
     {
         Debug.LogError(this + ": No BehaviorManager!");
     }
     else
     {
         BehaviorManager.RegisterReceiver(this);
     }
 }