Example #1
0
 //unit selection
 public void addUnit(baseRtsAI unit)
 {
     //Debug.Log(mySelection.Count);
     unit.gameObject.GetComponentInChildren<Projector>().enabled = true;
     mySelection.Add(unit);
       //  Debug.Log(mySelection.Count);
 }
Example #2
0
 public static void EnqueueComand(baseRtsAI unit, aiBehaviorNode cmd)
 {
     if (unit != null)
     {
         unit.Orders.Clear();
         unit.Orders.Enqueue(cmd);
     }
 }
Example #3
0
    // 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")
             }
     );
 }
Example #5
0
 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;
 }
Example #6
0
    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())
             }
         );
 }
Example #8
0
    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
                }
            ))
        );
    }
Example #9
0
    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);
    }
Example #10
0
    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)

            }
        );
    }
Example #11
0
 // Use this for initialization
 void Start()
 {
     unit = this.gameObject.GetComponent<baseRtsAI>();
 }
Example #12
0
 public Node_Call_Delegate(NodeFunction2 func, baseRtsAI unit)
 {
     m_unit = unit;
     m_function2 = func;
 }
Example #13
0
 public void removeUnit(baseRtsAI unit)
 {
     if (unit != null)
         unit.gameObject.GetComponentInChildren<Projector>().enabled = false;
     // mySelection.Remove(unit);
 }
Example #14
0
 void Start()
 {
     healthBar = GetComponentInChildren<Slider>();
     healthBar.maxValue = getMaxHealth();
     ai = gameObject.GetComponent<baseRtsAI>();
     currentHealth = maxHealth;
 }
Example #15
0
 public static void giveOrder(baseRtsAI unit, OrderType type, IRtsUnit target)
 {
     if (unit.stats != target)
     {
         EnqueueComand(unit, attackTarget(unit, target));
     }
 }
Example #16
0
 public static void giveOrder(baseRtsAI unit, OrderType type, PointOfInterest poi)
 {
     EnqueueComand(unit, CapturePoint(unit, poi));
 }
Example #17
0
 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;
 }