/** * @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); }
/** * @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); }
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>(); } }
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); }
/** * @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(); }
/** * @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; }
public void SetCurrentRoom(ArtificialIntelligence.Room room) => currentRoom = room;
public void SetSuspicionLocation(ArtificialIntelligence.Room room) => suspicionLocation = room;
public void AddRoom(ArtificialIntelligence.Room room) => rooms.Add(room);