Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (target != null)
        {
            if (!customHealthBar)
            {
                fillRect.sizeDelta = new Vector2(((float)target.GetHealth() / target.GetMaxHealth()) * _initialWidth, _rect.height);
            }
            else
            {
                fillRect.sizeDelta = new Vector2((customValueToCheck) * _initialWidth, _rect.height);
            }

            Color newColor = healthBarGradient.Evaluate(fillRect.sizeDelta.magnitude / _initialWidth);
            newColor.a    = barFill.color.a;
            barFill.color = newColor;

            _self.position = _mainCamera.WorldToScreenPoint(target.GetHeadPosition() + new Vector3(0f, heightOffset + customDeltaPosition, 0f));
            if (target.GetHealth() <= 0)
            {
                ToggleHealthBar(false);
            }
        }
    }
Esempio n. 2
0
 private void UpdateDunkReadyPanel()
 {
     if (CanDunk() && currentDunkReadyPanel != null)
     {
         if (!currentDunkReadyPanel.activeSelf)
         {
             if (enableDunkReadyPanel)
             {
                 currentDunkReadyPanel.SetActive(true);
             }
         }
         if (currentDunkReadyFX == null)
         {
             currentDunkReadyFX = FeedbackManager.SendFeedback("event.DunkReady", this, pawnController.GetCenterPosition(), Vector3.up, Vector3.up, !isPlayer).GetVFX();
         }
         currentDunkReadyPanel.transform.position = GameManager.mainCamera.WorldToScreenPoint(pawnController.GetHeadPosition());
     }
     else
     {
         if (currentDunkReadyFX != null)
         {
             Destroy(currentDunkReadyFX);
         }
         if (currentDunkReadyPanel.activeSelf)
         {
             currentDunkReadyPanel.SetActive(false);
         }
     }
 }