예제 #1
0
        /**
         * @brief Choose the best destiny hidding place and gets its destination coordinates
         * @return The destination coordinates of the desired hidding place
         */
        public Vector3 ChooseNewDestinyHiddingPlace()
        {
            var hiddingPlaces = agent.GetCurrentRoom().GetHiddingPlaces();

            ArtificialIntelligence.HiddingPlace origin = agent.GetCurrentHiddingPlace();

            float   bestHeuristic = float.MaxValue;
            Vector3 destiny       = Vector3.zero;

            foreach (ArtificialIntelligence.HiddingPlace hp in hiddingPlaces)
            {
                if (hp != origin && hp.GetMaxOccupation() > hp.GetCurrentOccupation())
                {
                    changeHiddingPlaceAction.Reset(origin, hp);
                    ChangeDestinationWhenHeuristicImprovement
                    (
                        changeHiddingPlaceAction.CalculateHeuristic(),
                        ref bestHeuristic,
                        changeHiddingPlaceAction.GetDestination(),
                        ref destiny
                    );
                }
            }

            currentAction = ActionTypes.CHANGE_HIDDING_PLACE;
            agent.Unhide();

            return(destiny == Vector3.zero ? ChooseDestinyRoom() : destiny);
        }
예제 #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("HiddingPlace"))
     {
         currentHiddingPlace = other.transform.GetComponent <ArtificialIntelligence.HiddingPlace>();
     }
     else if (other.gameObject.CompareTag("Room"))
     {
         currentRoom = other.transform.GetComponent <ArtificialIntelligence.Room>();
     }
 }
예제 #3
0
        /**
         * @brief Sets the ai agent into a given hidding place
         * @param hiddingPlace The hidding place where hide this agent
         */
        public void SetOnRandomHiddingPlace(ArtificialIntelligence.HiddingPlace hiddingPlace)
        {
            currentHiddingPlace = hiddingPlace;
            currentRoom         = hiddingPlace.GetOwnerRoom();

            var component = locomotor.GetNavMeshAgent();

            component.enabled = false;

            transform.position = hiddingPlace.transform.position;

            component.enabled = true;

            //locomotor.GetNavMeshAgent().Warp(hiddingPlace.transform.position);
            locomotor.SetDestination(transform.position);
            Hide();
            locomotor.Activate();
        }
예제 #4
0
 /**
  * @brief Reset the action with the given params
  * @param destiny The destiny hidding place
  */
 public void Reset(ArtificialIntelligence.HiddingPlace destiny)
 {
     this.destiny = destiny;
 }
예제 #5
0
 public void ResetCurrentHiddingPlace() => currentHiddingPlace = null;
예제 #6
0
 public void SetCurrentHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => currentHiddingPlace = hp;
예제 #7
0
 public void RemoveHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => hiddingPlaces.Remove(hp);
예제 #8
0
 public void AddHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => hiddingPlaces.Add(hp);