-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIController.cs
38 lines (30 loc) · 998 Bytes
/
UIController.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
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Linq;
public class UIController : MonoBehaviour
{
public TMP_Text healthText;
public Image weaponImage;
private void Update(){
// ammo og våben billede
weaponHolder wp = GameObject.Find("WeaponHolder").GetComponent<weaponHolder>();
Weapon currentWeapon = wp.activeWeapon;
if (currentWeapon != null){
weaponImage.gameObject.SetActive(true);
weaponImage.sprite = currentWeapon.sideSprite;
if (wp.canShoot){
weaponImage.color = new Color(1,1,1,1);
}
else{
weaponImage.color = new Color(0.5f,0.5f,0.5f,0.8f);
}
}
else{
weaponImage.sprite = null;
weaponImage.gameObject.SetActive(false);
}
}
}