-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoblinShowHealth.cs
More file actions
76 lines (66 loc) · 1.57 KB
/
GoblinShowHealth.cs
File metadata and controls
76 lines (66 loc) · 1.57 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using Player;
using UnityEngine;
using UnityEngine.UI;
namespace Enemy.Goblin
{
public class GoblinShowHealth : MonoBehaviour
{
[Header("Distance")]
[SerializeField] private float _theDistance;
[Header("Canvas Objects")]
[SerializeField] private GameObject monsterText;
[SerializeField] private GameObject healthEnemy;
[SerializeField] private GameObject healthBar;
[Header("Enemy Health")]
private int _healthValue;
[Header("Scripts")]
public GoblinEnemy goblinEnemyScript;
private void Start()
{
goblinEnemyScript = GetComponent<GoblinEnemy>();
}
private void Update()
{
_healthValue = goblinEnemyScript.enemyHealth;
_theDistance = PlayerCasting.distanceFromTarget;
if (PlayerCasting.isUp)
{
monsterText.SetActive(false);
healthEnemy.SetActive(false);
}
}
private void OnMouseOver()
{
if (HealthMonitor.Dead == false)
{
if (goblinEnemyScript.isDead == false)
{
if (PlayerCasting.isUp == false)
{
if (_theDistance <= 10)
{
monsterText.GetComponent<Text> ().text = "Goblin";
healthBar.GetComponent<RectTransform>().sizeDelta = new Vector2((_healthValue * 45), 20);
monsterText.SetActive(true);
healthEnemy.SetActive(true);
}
else
{
monsterText.SetActive(false);
healthEnemy.SetActive(false);
}
}
}
else
{
healthBar.GetComponent<RectTransform>().sizeDelta = new Vector2(0, 20);
}
}
}
private void OnMouseExit()
{
monsterText.SetActive(false);
healthEnemy.SetActive(false);
}
}
}