-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealthGUI.cs
36 lines (31 loc) · 1.37 KB
/
HealthGUI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using UnityEngine;
using System.Collections;
namespace Assets.Scripts
{
class HealthGUI : MonoBehaviour
{
public Texture playerHealth;
public Texture enemyHealth;
public Texture barOutLine;
private Player.Player player;
void Start()
{
player = FindObjectOfType<Player.Player>();
}
void OnGUI()
{
if (!Data.PlayerDead)
{
GUI.DrawTexture(new Rect(Screen.width * .05f, Screen.height * (.05f + (.3f / (float)player.MAX_HEALTH) * (player.MAX_HEALTH - player.Health)),
Screen.width * .05f, Screen.height * ((.3f / (float)player.MAX_HEALTH) * player.Health)), playerHealth);
GUI.DrawTexture(new Rect(Screen.width * .05f, Screen.height * .05f, Screen.width * .05f, Screen.height * .3f), barOutLine);
}
if (Data.Enemy!=null)
{
GUI.DrawTexture(new Rect(Screen.width * .9f, Screen.height * (.05f + (.3f / (float)Data.Enemy.maxHealth) * (Data.Enemy.maxHealth - Data.Enemy.Health)),
Screen.width * .05f, Screen.height * ((.3f / (float)Data.Enemy.maxHealth) * Data.Enemy.Health)), enemyHealth);
GUI.DrawTexture(new Rect(Screen.width * .9f, Screen.height * .05f, Screen.width * .05f, Screen.height * .3f), barOutLine);
}
}
}
}