Example #1
0
        public override List <IStateful> GetAllTargets(GoapAgent agent)
        {
            if (!agentPositions.ContainsKey(agent))
            {
                agentPositions[agent] = wanderPool.Borrow <WanderPosition>();
            }

            WanderPosition wanderPos = agentPositions[agent];

            DangerSensor     dangerSensor = agent.GetComponent <DangerSensor>();
            SightSensor      sightSensor  = agent.GetComponent <SightSensor>();
            List <IStateful> threats      = dangerSensor.GetThreats();

            //Vector3 targetPosition = Vector3.zero;

            //foreach (IStateful threat in threats) {
            //    Component threatComp = threat as Component;
            //    targetPosition = targetPosition + (agent.transform.position - threatComp.transform.position);
            //}

            //targetPosition = (agent.transform.position + targetPosition) * runAwayDistance;
            //wanderPos.transform.position = sightSensor.GetRandomPosition(runAwayDistance, targetPosition);
            wanderPos.transform.position = sightSensor.GetRandomPosition(runAwayDistance, agent.transform.position);

            return(new List <IStateful> {
                wanderPos
            });
        }
Example #2
0
 void Awake()
 {
     navAgent     = GetComponent <NavMeshAgent>();
     dangerSensor = GetComponent <DangerSensor>();
 }