Esempio n. 1
0
    //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);
    }
Esempio n. 2
0
 void OnValidate()
 {
     if (Hidable == null)
     {
         Hidable = GetComponent <Hidable>();
     }
 }
Esempio n. 3
0
    public void Hide()
    {
        Hidingplace = GetClosestHidingPlace();

        if (!Hidingplace)
        {
            return;
        }

        State = CharacterState.Hiding;
    }
 void OnValidate()
 {
     OverlayHidable = GetComponent <Hidable>();
 }
Esempio n. 5
0
 public void ShowPopup(Hidable popupHidable)
 {
     popupHidable.Show();
     popupHidables.AddFirst(popupHidable);
     Overlay.ShowOverlay();
 }