public static void EnqueueComand(baseRtsAI unit, aiBehaviorNode cmd) { if (unit != null) { unit.Orders.Clear(); unit.Orders.Enqueue(cmd); } }
/// <summary> /// repeats a child node until it fails then this succeeds /// </summary> public Node_Repeat_Until_Fail(aiBehaviorNode Node) { m_child = Node; }
/// <summary> /// runs child in a sequence until one fails or all have been run /// </summary> public Node_Sequence(aiBehaviorNode[] nodes) { m_children = nodes; }
/// <summary> /// /// DEPRECIATED /// runs child all child node in sequence until one succeeds /// acts wierdly if only 1 child /// </summary> public Node_Selector(aiBehaviorNode[] nodes) { m_children = nodes; }
/// <summary> /// repeats a child node n number of times or infinitively /// fails if child fails once /// succeeds if repeated for n times /// </summary> public Node_Repeat(aiBehaviorNode Node, int times) { m_timesToRepeat = times; m_child = Node; m_curentTime = 0; }
/// repeats a child node n number of times or infinitively /// fails if child fails once /// //if no time specified will repeat infinitively /// </summary> public Node_Repeat(aiBehaviorNode Node) { m_timesToRepeat = -1; m_child = Node; m_curentTime = 0; }
private void getOrder() { // currentOrder = unit.Orders.Dequeue(); if (unit.Orders.Count != 0) { currentOrder = unit.Orders.Peek(); } else { Fail();//fail if no new orders } }
void Start() { Init(); agent = this.gameObject.GetComponent<UnityEngine.AI.NavMeshAgent>(); switch(type){ case AItype.lamb: routine = CreateLamb(); break; case AItype.wolf: routine = CreateWolf(); break; default: routine = CreateDrone(); break; } if (autoStart) { routine.Run(); } }
public override void Act(GameObject ob) { getOrder();//get the latest oder if (currentOrder != null) { switch (currentOrder.GetState()) { case NodeState.Ready: currentOrder.Run(); break; case NodeState.Running: currentOrder.Act(ob); break; case NodeState.Failure: Debug.Log("order failed"); unit.Orders.Dequeue();//remove completed order //Fail(); break; case NodeState.Success: // Debug.Log("sucess"); //Succeed(); currentOrder = null; unit.Orders.Dequeue();//remove completed order break; } } }
public override void Reset() { currentOrder = null; MakeReady(); }
/// <summary> /// runs child all child node each update tick until one fails /// </summary> public Node_Concurent(aiBehaviorNode[] nodes) { m_children = nodes; }
/// <summary> /// makes child node allways succeed /// </summary> public Node_Succeeder(aiBehaviorNode Node) { m_child = Node; }
/// <summary> /// Node invert /// inverts the child node output. /// </summary> public Node_Invert(aiBehaviorNode Node) { m_child = Node; }
public Node_Timer(aiBehaviorNode Node, int timeToWait) { m_timeToWait = timeToWait; m_child = Node; }
// Use this for initialization void Start() { OutToCapturePt = new List<aiBehavior>(); controlGroups = new Dictionary<CtrlGroupsName, List<baseRtsAI>>(); blackBoard = new Dictionary<string, System.Object>(); controlGroups[CtrlGroupsName.all] = new List<baseRtsAI>(); controlGroups[CtrlGroupsName.capture] = new List<baseRtsAI>(); controlGroups[CtrlGroupsName.offence] = new List<baseRtsAI>(); //decide ratio of capturer to offence //add defender later routine = createAdvancedComputerAI(); if (autoStart) { routine.Run(); } }