//https://answers.unity.com/questions/947856/how-to-detect-click-outside-ui-panel.html?page=1&pageSize=5&sort=votes
    //Ziplock9000's answer + BluishGreenPro's comment


    public void OpenMenu(HouseplantHealth houseplant)
    {
        if (!_panelEnabled)
        {
            return;
        }
        EventSystem.current.SetSelectedGameObject(gameObject);

        _houseplant        = houseplant;
        transform.position = Input.mousePosition;
        gameObject.SetActive(true);
        GameManager.Instance.UIPanelUp = true;

        UpdateData();
    }
    private IEnumerator BringUpPlantPanel(GameObject plant)
    {
        GameObject       player      = GameObject.Find("Player").gameObject;
        HouseplantHealth plantHealth = plant.GetComponent <HouseplantHealth>();

        while (Vector3.Distance(player.transform.position, plant.transform.position) > GameManager.Instance.AOE ||
               player.GetComponent <NavMeshAgent>().velocity.magnitude != 0)
        {
            yield return(null);
        }

        if (plantHealth.Dead)
        {
            Events.OpenDeadPanel(plantHealth);
            yield break;
        }
        else
        {
            Events.OpenMoistureMeter(plantHealth);
            yield break;
        }
    }
Exemplo n.º 3
0
 public static void OpenDeadPanel(HouseplantHealth houseplant) => OnOpenDeadPanel.Invoke(houseplant);
Exemplo n.º 4
0
 public static void OpenMoistureMeter(HouseplantHealth houseplant) => OnOpenMoistureMeter.Invoke(houseplant);
Exemplo n.º 5
0
 void OpenPanel(HouseplantHealth houseplant)
 {
     _houseplant        = houseplant;
     transform.position = Input.mousePosition;
     gameObject.SetActive(true);
 }