//TODO: make generic methods for this and other getclosests private Hidable GetClosestHidingPlace() { //get these from a game or fight controller instead for maintenance //GameObject[] gos; //gos = GameObject.FindGameObjectsWithTag("Hidable"); Hidable closest = null; float distance = Mathf.Infinity; Vector3 position = transform.position; foreach (Hidable go in InArea.Hidables)//.Where(h=> h.GetComponent<Hidable>().Area = InArea)) { if (!go) { Debug.LogError("Hidable object does not have hidable script"); } if (go.OccupiedBy != null) { continue; } Vector3 diff = go.transform.position - position; float curDistance = diff.sqrMagnitude; if (curDistance < distance) { closest = go; distance = curDistance; } } if (!closest) { return(null); } return(closest); }
void OnValidate() { if (Hidable == null) { Hidable = GetComponent <Hidable>(); } }
public void Hide() { Hidingplace = GetClosestHidingPlace(); if (!Hidingplace) { return; } State = CharacterState.Hiding; }
void OnValidate() { OverlayHidable = GetComponent <Hidable>(); }
public void ShowPopup(Hidable popupHidable) { popupHidable.Show(); popupHidables.AddFirst(popupHidable); Overlay.ShowOverlay(); }