Ejemplo n.º 1
0
        protected override NodeState DoTick(InputParam input, OutputParam output)
        {
            NodeState ret = NodeState.Finish;
            if (m_behaviorState == BehaviorState.Ready)
            {
                DoEnter(input);
                m_behaviorState = BehaviorState.Running;
            }

            if (m_behaviorState == BehaviorState.Running)
            {
                ret = DoExecute(input, output);
                SetActiveNode(this);
                if (ret == NodeState.Finish)
                    m_behaviorState = BehaviorState.Finish;
            }

            if (m_behaviorState == BehaviorState.Finish)
            {
                DoExit(input);
                m_behaviorState = BehaviorState.Ready;
                SetActiveNode(null);
            }
            return ret;
        }
Ejemplo n.º 2
0
		// Use this for early referencing
		private void Awake()
		{
			GameObject.DontDestroyOnLoad(this);
			behaviorState = new BehaviorState();

			
			var parser = new DefinitionParser();
			parser.ParseTestFile();
		
		}
Ejemplo n.º 3
0
		protected override void InitializeBehaviorTree(BehaviorState bState)
		{
			if (bState.IsTreeDefined(TREE_SQUAD) == false)
			{
				_behaviorTreeEntry = bState.AddTree(TREE_SQUAD,

				new EntryNode(
					new StubNode("GHello, I'm a squad")
				)


				);
			}
			else
			{
				_behaviorTreeEntry = bState.GetTree(TREE_SQUAD);
			}
		}
Ejemplo n.º 4
0
		protected virtual void InitializeBehaviorTree(BehaviorState bState)
		{
			if (bState.IsTreeDefined(TREE_BASE_UNIT) == false)
			{
				_behaviorTreeEntry = bState.AddTree(TREE_BASE_UNIT,

				new EntryNode(
					new PrintNode("No behavior tree defined")
				)


				);
			}
			else
			{
				_behaviorTreeEntry = bState.GetTree(TREE_BASE_UNIT);
			}
		}
Ejemplo n.º 5
0
 protected override void DoReset(InputParam input)
 {
     DoExit(input);
     m_behaviorState = BehaviorState.Ready;
 }
Ejemplo n.º 6
0
		protected override void InitializeBehaviorTree(BehaviorState bState)
		{
			if (bState.IsTreeDefined(TREE_UNIT) == false)
			{
				_behaviorTreeEntry = bState.AddTree(TREE_UNIT,

				new EntryNode(
					// What's our top level action?
					new SelectorCompositeNode(
						// Chasing clues
						new SequenceCompositeNode(
							//Get a clue to chase
							new EditorRegionDecoratorNode(
							new SelectorCompositeNode(
								// do we have an active clue?
									new SequenceCompositeNode(
										new InverterDecoratorNode(
											new IsNullNode(C_ACTIVE)
										),
										new IsClueWorthInvestigating(C_ACTIVE),
										new CanReach(U_SUBJECT, C_ACTIVE)
										// Yes, we got one, so return
									),
								// if not, empty the clue var
								new FailerDecoratorNode(
									new SetToNullNode(C_ACTIVE)
								),
								// Move on to investigating the environment
								new SequenceCompositeNode(
									new ClearStack(STACK_POTENTIAL_CLUES),
									new FindVisualClues(U_SUBJECT, STACK_POTENTIAL_CLUES),

									// Loop through the stack
									new RepeatUntilFailDecoratorNode(
										new SequenceCompositeNode(

											new PopFromStack(STACK_POTENTIAL_CLUES, C_POTENTIAL),

											// We're just content with the first worthy clue we find
											new InverterDecoratorNode(
												new SequenceCompositeNode(
													new IsClueWorthInvestigating(C_POTENTIAL),
													new CanReach(U_SUBJECT, C_POTENTIAL),

													new PrintNode("What is that!"),
													new TimerNode(1f),
													
													// Passed all the checks, it's promoted to target now
													new SetVarTo<ContextIndex	>(C_ACTIVE, C_POTENTIAL)
												)
											),



											new SetToNullNode(C_POTENTIAL)

										)
									)
								),

								new InverterDecoratorNode(
									new IsNullNode(C_ACTIVE)
								)

							),
							Color.blue, "Find A Target", false
							),
							// If we got here, we are chasing

							new StubNode("Is the clue noteworthy enough for us to build our anxiety?"),

							new StubNode("Are we close enough to the clue"),
								new StubNode("Examine the clue"),
								new StubNode("Examine the clue"),


							new StubNode("Are we moving too far away from the squad, so that we should notify it/"),

							//Move towards the current clue
							new MoveTo(U_SUBJECT, C_ACTIVE)

	
							//new StubNode("GhellO")

						),
						// Follow squad
						new FollowSquadNode(U_SUBJECT)
					)

				)


				);
			}
			else
			{
				_behaviorTreeEntry = bState.GetTree(TREE_UNIT);
			}
		}