Example #1
0
	protected void LateUpdate()
	{
		if(player == null || health == null)
		{
			player = EntityUtils.GetEntityWithTag("Player");

			if(player == null)
			{
				return;
			}

			health = player.GetHealth();

			if(health == null)
			{
				return;
			}
		}

		float current = health.CurrentHealth;
		float max = health.StartingHealth;

		float alpha = 1 - current / max;

		Color color = image.material.color;
		color.a = alpha * 0.65f;
		image.material.color = color;
	}
    // Use this for initialization
    void Start()
    {
        healtBarWidth = (int)healtBarMaxSize;
        myhb = (GameObject)Instantiate(myHealtBar,transform.position,transform.rotation) as GameObject;

        ParentEntityObject = GetComponent<Entity>();

        maxhp = ParentEntityObject.GetHealth();
    }
	protected void Update()
	{
		if(player == null || health == null)
		{
			player = EntityUtils.GetEntityWithTag("Player");

			if(player == null)
			{
				return;
			}

			health = player.GetHealth();
		}

		if(health.CurrentHealth <= (health.StartingHealth / 4))
		{
			if(audioChannel == null || !audioChannel.IsPlaying)
			{
				audioChannel = audioManager.Play(audio);
			}
		}
	}