Exemple #1
0
 public IBehaviourNode GetState(IBehaviourNode sequence)
 {
     if (!nodeStates.ContainsKey(sequence))
     {
         return(null);
     }
     return(nodeStates[sequence]);
 }
 // Use this for initialization
 void Start()
 {
     _Main = new ConcurrentNode(
         Utils.FirstOrDefault <BehaviourValue>,
         new FixedPriorityNode(
             new BehaviourCoroutine(SomeCoroutine()),
             new BehaviourCoroutine(SomeOtherCoroutine())),
         new BehaviourCoroutine(SomeThirdCoroutine()));
 }
 public PiratePart(EnemyBehaviourFactory behaviourFactory, EnemyBrain brain, IPositionComponent Physical)
 {
     this.behaviourFactory = behaviourFactory;
     this.Brain            = brain;
     this.Physical         = Physical;
     behaviourTree         = CreateBehaviourTree();
     agent = new BehaviourTreeAgent(behaviourTree);
     Brain.LookDistance  = 20;
     Brain.ShootDistance = 5;
     Brain.ShootInterval = 2;
     Brain.GunDamage     = 20;
 }
 public ProximityChaseEnemyPart(EnemyBehaviourFactory behaviourFactory, EnemyBrain brain, IPositionComponent Physical)
 {
     BehaviourFactory    = behaviourFactory;
     behaviourTree       = CreateBehaviourTree();
     agent               = new BehaviourTreeAgent(behaviourTree);
     GunChargedTime      = -1;
     brain.LookDistance  = 20;
     brain.ShootDistance = 5;
     brain.ShootInterval = 2;
     brain.GunDamage     = 20;
     Brain               = brain;
     this.Physical       = Physical;
 }
Exemple #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="node"></param>
 public IfNode(ConditionNode condition, IBehaviourNode node,string name)
     : base(name)
 {
     this.AddNode(condition);
     this.AddNode(node);
 }
Exemple #6
0
 public void AddNode(IBehaviourNode node)
 {
     node.parent = this;
     children.Add(node);
 }
 public While(Func <bool> getWhileCondition, Func <bool> getSuccessCondition, IBehaviourNode child)
 {
     this.getWhileCondition   = getWhileCondition;
     this.getSuccessCondition = getSuccessCondition;
     this.child = child;
 }
Exemple #8
0
 private string GetPath(IBehaviourNode current)
 {
     string re = "/" + current.name + "" + current.status;
     if (current.parent == null)
     {
         return re;
     }
     else
     {
         re += GetPath(current.parent);
         return re;
     }
 }
Exemple #9
0
    private IBehaviourNode Foreach(IBehaviourNode node)
    {
        if (node is CompositeNode)
        {
            CompositeNode a = node as CompositeNode;
            //a.chie
            if (a.status == BehaviourStatus.Running)
            {
                IList<IBehaviourNode> list = a.getChildrens;
                foreach (var IBehav in list)
                {
                    if (IBehav.status == BehaviourStatus.Running)
                        return Foreach(IBehav);
                }
            }
        }
        else if (node.status == BehaviourStatus.Running)
        {
            return node;
        }

        return null;
    }
Exemple #10
0
 public void StoreState(IBehaviourNode sequence, IBehaviourNode state)
 {
     nodeStates[sequence] = state;
 }
Exemple #11
0
 public BehaviourTreeAgent(IBehaviourNode root)
 {
     this.root = root;
 }