Esempio n. 1
0
        public void Execute(AICharacter character, IGoal goal)
        {
            List <IInspectable> inspectables = FindInspectablesInView(character);

            inspectables.Sort(delegate(IInspectable x, IInspectable y) {
                return((character.Position - x.Position).magnitude.CompareTo((character.Position - y.Position).magnitude));
            });
            IInspectable inspectable = inspectables.Find(delegate(IInspectable obj) {
                return(!character.Knows(obj));
            });

            if (inspectable == null)
            {
                NavMeshAgent agent = character.gameObject.GetComponent <NavMeshAgent> ();
                NavMeshHit   navHit;

                do
                {
                    NavMesh.SamplePosition(UnityEngine.Random.insideUnitSphere * agent.speed + character.Position, out navHit, agent.speed, -1);
                } while (character.ExploredArea.Contains(navHit.position));

                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new AtPosition(navHit.position)
                }, goal));
            }
            else
            {
                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new Inspected(inspectable)
                }, goal));
            }
        }
Esempio n. 2
0
 public bool IsFullfilled(AICharacter character)
 {
     return(character.Knows(inspectable));
 }