Beispiel #1
0
    }     // UpdateLives

    public void UpdateHealth(GameObject inPlayer)
    {
        Vector3 defaultPosition = inPlayer.transform.position + (inPlayer.transform.forward * -0.4f) + (inPlayer.transform.up * 2.0f);
        Vector3 offsetPosition  = defaultPosition + new Vector3(healthModelPosition.x, healthModelPosition.y, healthModelPosition.z);

        Player.Player playerScript = inPlayer.GetComponent <Player.Player>();
        Vector3       localScale   = healthIcon.transform.localScale;
        float         healthScale  = (((float)playerScript.GetCurrentHealth()) / ((float)playerScript.health));

        if (null == playerScript)
        {
            General.Logger.LogError("GUIManager", "UpdateHealth", "Could not find player's player script.");
            return;
        }         // if

        General.Logger.LogDetail("GUIManager", "UpdateHealth", "healthScale: " + healthScale + ", playerScript.GetCurrentHealth(): " + playerScript.GetCurrentHealth() + ", playerScript.health: " + playerScript.health + ".");
        healthIcon.transform.position = offsetPosition;
        healthIcon.transform.rotation = inPlayer.transform.rotation * Quaternion.Euler(healthModelRotation);
        localScale.y = healthModelScale * healthScale;
        healthIcon.transform.localScale = localScale;
    }     // UpdateHealth