using Assets.Scripts.Network;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class player_health : MonoBehaviour
{

    public Text textBox;
    public float playerHealth = 100;
    public Image barImg;
    public Image rayImg;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (World.currentWorld != null && World.currentWorld.Me != null)
        {
            playerHealth = World.currentWorld.Me.FlashLight.Level / World.currentWorld.Me.FlashLight.Capacity * 100;            
                 
        }
        textBox.text = playerHealth.ToString("##");
       // barImg.fillAmount = playerHealth / 100;


        float opacity = playerHealth * 2.55f;
        Color32 currColor = new Color32(255, 255, 255, (byte)opacity);
        rayImg.color = currColor;
    }
}
