コード例 #1
0
ファイル: RunAwayAction.cs プロジェクト: nice-shot/AiSeminar
        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
            });
        }
コード例 #2
0
        protected override bool OnDone(GoapAgent agent, WithContext context)
        {
            base.OnDone(agent, context);
            targetPositions[agent].ReturnSelf();

            SightSensor sight = agent.GetComponent <SightSensor>();

            if (sight != null)
            {
                sight.LookAround();
            }
            return(true);
        }
コード例 #3
0
ファイル: DangerSensor.cs プロジェクト: nice-shot/AiSeminar
 void Awake()
 {
     sight = GetComponent <SightSensor>();
 }