/** * @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); }
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>(); } }
/** * @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 destiny The destiny hidding place */ public void Reset(ArtificialIntelligence.HiddingPlace destiny) { this.destiny = destiny; }
public void ResetCurrentHiddingPlace() => currentHiddingPlace = null;
public void SetCurrentHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => currentHiddingPlace = hp;
public void RemoveHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => hiddingPlaces.Remove(hp);
public void AddHiddingPlace(ArtificialIntelligence.HiddingPlace hp) => hiddingPlaces.Add(hp);