//unit selection public void addUnit(baseRtsAI unit) { //Debug.Log(mySelection.Count); unit.gameObject.GetComponentInChildren<Projector>().enabled = true; mySelection.Add(unit); // Debug.Log(mySelection.Count); }
public static void EnqueueComand(baseRtsAI unit, aiBehaviorNode cmd) { if (unit != null) { unit.Orders.Clear(); unit.Orders.Enqueue(cmd); } }
// Use this for initialization //later change to use unit interface public static void cloneUnit(baseRtsAI unit) { Transform rabbit = Instantiate(unit.transform, unit.transform.position, unit.transform.rotation) as Transform; baseRtsAI aiComponent = rabbit.gameObject.GetComponent<baseRtsAI>(); aiComponent.stats.setFaction(unit.stats.getFaction()); UnitOrders.giveOrder(aiComponent, UnitOrders.OrderType.move, unit.transform.position); }
/// <summary> /// creates a sub tree that seeks and destroy enemies /// will only run one /// use ether a repeat until fail or as a last branch in a tree /// </summary> /// <param name="unit"></param> /// /// <returns></returns> public static aiBehaviorNode attackSequence(baseRtsAI unit) { return new Node_Sequence( new aiBehaviorNode[] { // new Node_Find_Closest_Target_BB(unit.blackBoard, "Target", unit.detectionRange,unit.typeToChase), new Node_Get_Closest_Enemy(unit.blackBoard, "Target", unit.stats.getSightRange(),unit.stats.getFaction()), new Node_Invert(new Node_IsNull(unit.blackBoard, "Target")), killTarget(unit, "Target") } ); }
public static aiBehaviorNode CapturePoint(baseRtsAI rabbit,PointOfInterest poi) { aiBehaviorNode commande = new Node_Sequence ( new aiBehaviorNode[] { moveComand(rabbit,poi.gameObject.transform.position), new Node_Call_Delegate(poi.CapturePT,rabbit) } ); return commande; }
public void CapturePT(baseRtsAI unit) { ChangeFaction(unit.stats.getFaction()); toggleMat(); for (int i = 0; i < players.Length; i++) { if (players[i].UnitFaction == owningFaction) { currentPlayerIndex = i; break; } } }
public static aiBehaviorNode killTarget(baseRtsAI unit,string TargetKey) { return new Node_Sequence ( new aiBehaviorNode[] { // new Node_Timer( new Node_Seek_Modular_BB(unit.blackBoard, TargetKey, (IMoveToNode)(new Node_MoveTo_With_Astar(unit.gameObject, unit.m_unit, unit.SeekarriveRadius))), //1), new Node_Attack_Activate_Weapon(unit.MainWeapon, unit.stats), new Node_Delay(unit.stats.getAttackSpeed()) } ); }
public static aiBehaviorNode attackMove(baseRtsAI rabbit, Vector3 loc) { return new Node_Repeat_Until_Fail //repeat the selector until it suceeds ( // new Node_Invert(new Node_PrioritySelector // ( new aiBehaviorNode[] { new Node_Invert(new Node_Repeat_Until_Fail //repeat the attackSequence until it fails then succeeds (pierBehaviorsubTrees.attackSequence(rabbit))), new Node_Timer(new Node_MoveTo_With_Astar(rabbit.gameObject, rabbit.m_unit,rabbit.SeekarriveRadius,loc),1) //lets node run for T time then fails it } )) ); }
public static void giveOrder(baseRtsAI unit, OrderType type, Vector3 location) { aiBehaviorNode commande; switch (type) { case OrderType.attackMove: commande = attackMove(unit, location); break; default: commande = moveComand(unit, location); break; } EnqueueComand(unit, commande); }
public static aiBehaviorNode attackTarget(baseRtsAI rabbit, IRtsUnit target) { return new Node_PrioritySelector (new aiBehaviorNode[] {//change to seletor nested ina sequence new Node_Invert(new Node_Succeeder(new Node_SetVariable(rabbit.blackBoard,"Target",target.GetGameObject()))), new Node_Invert ( new Node_Repeat_Until_Fail ( pierBehaviorsubTrees.killTarget(rabbit,"Target") ) ), new Node_MoveTo_With_Astar(rabbit.gameObject, rabbit.m_unit,rabbit.SeekarriveRadius,target.GetGameObject().transform.position) } ); }
// Use this for initialization void Start() { unit = this.gameObject.GetComponent<baseRtsAI>(); }
public Node_Call_Delegate(NodeFunction2 func, baseRtsAI unit) { m_unit = unit; m_function2 = func; }
public void removeUnit(baseRtsAI unit) { if (unit != null) unit.gameObject.GetComponentInChildren<Projector>().enabled = false; // mySelection.Remove(unit); }
void Start() { healthBar = GetComponentInChildren<Slider>(); healthBar.maxValue = getMaxHealth(); ai = gameObject.GetComponent<baseRtsAI>(); currentHealth = maxHealth; }
public static void giveOrder(baseRtsAI unit, OrderType type, IRtsUnit target) { if (unit.stats != target) { EnqueueComand(unit, attackTarget(unit, target)); } }
public static void giveOrder(baseRtsAI unit, OrderType type, PointOfInterest poi) { EnqueueComand(unit, CapturePoint(unit, poi)); }
public static aiBehaviorNode moveComand(baseRtsAI rabbit,Vector3 loc) { IMoveToNode commande = new Node_MoveTo_With_Astar(rabbit.gameObject, rabbit.m_unit, rabbit.SeekarriveRadius,loc); commande.SetArriveRadius(2.5f); return (aiBehaviorNode)commande; }