Beispiel #1
0
 protected virtual bool FindNearestTarget()
 {
     bool[] aiInRange = new bool[0];// TODO: save this value on unit. and only run updates every few frames
     if (AnyAiInRange(transform.position, detectionRange, ref aiInRange))
     {
         Ai targetAi = GlobalAi.ChoseNearest(transform, ai.alliance, "!", aiInRange);
         if (targetAi)
         {
             this.target = targetAi.transform;
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
    public override NodeStatus Tick()
    {
        //if (!data.ContainsKey("target") || (data.ContainsKey("target") && (Transform)data["target"] == null)) {
        Ai objective = GlobalAi.ChoseNearest((Transform)data["transform"], (string)data["alliance"], "!", data.ContainsKey("filtered") == false ? null : (bool[])data["filtered"]);    //GlobalAi.ChoseTargetByPriorityImportance((string)data["alliance"], "!", data.ContainsKey("filtered") == false ? null : (bool[])data["filtered"]);

        data["target"] = null;
        if (objective != null)
        {
            data["target"] = objective.transform;
        }
        //}

        if (((Transform)data["target"]) != null)
        {
            data["targetPos"] = ((Transform)data["target"]).position;
        }

        return(data["target"] == null ? NodeStatus.FAILURE : NodeStatus.SUCCESS);
    }