예제 #1
0
        /**
         * @brief Get the distance between two rooms
         * @param origin The origin room
         * @param destiny The destiny room
         * @return The distance
         */
        public float GetDistanceBetween(ArtificialIntelligence.Room origin, ArtificialIntelligence.Room destiny)
        {
            if (origin != destiny)
            {
                int originIndex  = 0;
                int destinyIndex = 0;

                int iterator = 0;

                // Search the index of each room
                foreach (ArtificialIntelligence.Room r in rooms)
                {
                    if (r == origin)
                    {
                        originIndex = iterator;
                    }
                    else if (r == destiny)
                    {
                        destinyIndex = iterator;
                    }
                    ++iterator;
                }

                return(distanceMatrix[originIndex][destinyIndex]);
            }

            return(0.0f);
        }
예제 #2
0
        /**
         * @brief Choose the best destiny room and gets its destination coordinates
         * @return The destination coordinates of the desired room
         */
        public Vector3 ChooseDestinyRoom()
        {
            var rooms = RoomManager.singletonInstance.GetRooms();

            ArtificialIntelligence.Room origin = agent.GetCurrentRoom();

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

            foreach (ArtificialIntelligence.Room r in rooms)
            {
                if (r != origin)
                {
                    changeRoomAction.Reset(origin, r);
                    ChangeDestinationWhenHeuristicImprovement
                    (
                        changeRoomAction.CalculateHeuristic(),
                        ref bestHeuristic,
                        changeRoomAction.GetDestination(),
                        ref destiny
                    );
                }
            }

            currentAction = ActionTypes.CHANGE_ROOM;

            return(destiny == Vector3.zero ? changeRoomAction.GetDestination() : destiny);
        }
예제 #3
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>();
     }
 }
예제 #4
0
        public ArtificialIntelligence.Room GetSuspicionLocation()
        {
            if (!suspicionLocation)
            {
                var rooms   = ArtificialIntelligence.RoomManager.singletonInstance.GetRooms();
                int maxRoom = rooms.Count;

                int roomIndex = Random.Range(0, maxRoom);
                suspicionLocation = rooms[roomIndex];
            }

            return(suspicionLocation);
        }
예제 #5
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();
        }
예제 #6
0
 /**
  * @brief Reset the action with the given params
  * @param origin The origin room
  * @param destiny The destiny room
  */
 public void Reset(ArtificialIntelligence.Room origin, ArtificialIntelligence.Room destiny)
 {
     this.origin  = origin;
     this.destiny = destiny;
 }
예제 #7
0
 public void SetCurrentRoom(ArtificialIntelligence.Room room) => currentRoom = room;
예제 #8
0
 public void SetSuspicionLocation(ArtificialIntelligence.Room room) => suspicionLocation = room;
예제 #9
0
 public void AddRoom(ArtificialIntelligence.Room room) => rooms.Add(room);