private void InitializeBlackboards(BTAgent agent) { agent.AddBlackboard(new TestBlackboard { AgentName = this.gameObject.name, TestInt = 100 }); }
public void Start(BehaviourTree tree, BTAgent agent) { /*m_instances.Add(new BTInstance * { * Tree = tree, * Agent = agent, * ExecutionContext = new WaitCallback(tree.Tick) * });*/ int slotsPerChunk = 30; if (m_currentChunk == null || m_currentChunk.m_freeSlots <= 0) { m_currentChunk = new ThreadChunk { Instances = new BTInstance[slotsPerChunk], m_freeSlots = slotsPerChunk }; m_chunks.Add(m_currentChunk); } int index = slotsPerChunk - m_currentChunk.m_freeSlots; m_currentChunk.Instances[index] = new BTInstance { Tree = tree, Agent = agent }; m_currentChunk.m_freeSlots--; }
public override BTNode TryAction(BTAgent behavier) { BTNode[] nodeList = new BTNode[actionList.Length]; for (int i = 0; i < actionList.Length; i++) { ActionBase _action = (ActionBase)actionList[i]; nodeList[i] = _action.TryAction(behavier); } selfAction = BT.RandomSequence(weights).OpenBranch(nodeList); return(base.TryAction(behavier)); }
private void InitializeBlackboards(BTAgent agent) { Debug.Log("Initializing Blackboards"); m_time = agent.AddBlackboard(new TimeBlackboard { DeltaTime = Time.deltaTime, UnscaledDeltaTime = Time.unscaledDeltaTime }); m_transform = agent.AddBlackboard(new TransformBlackboard { Position = transform.position, Rotation = transform.rotation, Scale = transform.lossyScale }); }
public override BTNode TryAction(BTAgent behavier) { _sleep_node_list = new BTNode[sleepActionList.Length]; for (int i = 0; i < sleepActionList.Length; i++) { ActionBase _action = sleepActionList[i]; _sleep_node_list[i] = _action.TryAction(behavier); } _patrol_node_list = new BTNode[patrolActionList.Length]; for (int i = 0; i < patrolActionList.Length; i++) { ActionBase _action = patrolActionList[i]; _patrol_node_list[i] = _action.TryAction(behavier); } _battle_node_list = new BTNode[battleActionList.Length]; for (int i = 0; i < battleActionList.Length; i++) { ActionBase _action = battleActionList[i]; _battle_node_list[i] = _action.TryAction(behavier); } selfAction = BT.Root().OpenBranch( BT.If(() => { return(behavier.m_AIState == AIState.sleep); }).OpenBranch( _sleep_node_list ), BT.If(() => { return(behavier.m_AIState == AIState.patrol); }).OpenBranch( _patrol_node_list ), BT.If(() => { return(behavier.m_AIState == AIState.battle); }).OpenBranch( _battle_node_list ) ); return(base.TryAction(behavier)); }
public override BTNode TryAction(BTAgent behavier) { BTNode[] nodeList = new BTNode[actionList.Length]; selfAction = BT.Repeat(Times).OpenBranch(nodeList); return(base.TryAction(behavier)); }
void Awake() { m_btAgent = new BTAgent(new QueueScheduler()); }
public void Stop(BTAgent agent) { }