Пример #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));
            }
        }
Пример #2
0
        public void Execute(AICharacter character, IGoal goal)
        {
            Vector3 closestPoint = inspectable.ClosestPoint(character.Position);

            if ((closestPoint - character.Position).magnitude <= 1.0f)
            {
                character.Inspect(inspectable);
            }
            else
            {
                character.AddGoal(new Goal(new List <IRequirement> ()
                {
                    new AtPosition(closestPoint)
                }, goal));
            }
        }