Ejemplo n.º 1
0
    void OnGUI()
    {
        if (tooltipShowing)
        {
            Vector2 mousePosLocked = Event.current.mousePosition;
            Vector2 halfBounds     = tooltipPanel.GetComponent <RectTransform>().rect.size;
            halfBounds      += new Vector2(10, 10);
            halfBounds      *= 0.5f;
            mousePosLocked.x = Mathf.Clamp(mousePosLocked.x + halfBounds.x, halfBounds.x, Camera.main.pixelWidth - halfBounds.x);
            mousePosLocked.y = Mathf.Clamp(Camera.main.pixelHeight - (mousePosLocked.y + halfBounds.y), halfBounds.y, Camera.main.pixelHeight - halfBounds.y);
            Vector3 mouse = new Vector3(mousePosLocked.x, mousePosLocked.y, 0);
            tooltipPanel.transform.position = mouse;

            if (currentTree)
            {
                newHealthValue = currentTree.getHP() / 100.0f;
                if (newHealthValue != oldHealthValue)
                {
                    StopCoroutine("lerpHealthbar");
                    StartCoroutine(lerpHealthbar(oldHealthValue, newHealthValue, 1.0f));
                    oldHealthValue = newHealthValue;
                }

                newInfestation = currentTree.getIntegrity() * leafes.Count;
                if ((int)oldInfestation != (int)newInfestation)
                {
                    paintLeaves();
                }
                oldInfestation = newInfestation;
            }
        }
    }
Ejemplo n.º 2
0
 public void showTooltip(ShroomTree tree)
 {
     currentTree    = tree;
     oldHealthValue = newHealthValue = currentTree.getHP();
     tooltipPanel.SetActive(true);
     tooltipShowing = true;
 }