-
Notifications
You must be signed in to change notification settings - Fork 0
/
InventoryDisplay.cs
92 lines (70 loc) · 2.38 KB
/
InventoryDisplay.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InventoryDisplay : MonoBehaviour {
public Button Inv;
public AudioSource clickSFX;
public GameObject Panel;
public GameObject Item01;
public GameObject Item02;
public GameObject Item03;
public GameObject Item04;
public GameObject Item05;
public GameObject Item06;
public Text StatsTxt;
void Start()
{
CheckItemOwnership ();
Panel.SetActive (false);
StatsTxt.text = "Name: "+GameState.currentPlayer.GetName()+
"\nOccupation: "+GameState.currentPlayer.Occupation+
"\nLevel: "+GameState.currentPlayer.Level+
"\nExperience: "+GameState.currentPlayer.Experience+"/"+GameState.currentPlayer.MaxExperience+
"\nHealth: "+GameState.currentPlayer.Health+"/"+GameState.currentPlayer.MaxHealth+
"\nStrength: "+GameState.currentPlayer.Strength+
"\nArmor: "+GameState.currentPlayer.Armor+
"\nMoney: "+GameState.currentPlayer.Money;
}
void Update(){
if (Panel.activeInHierarchy) {
Inv.onClick.AddListener(delegate {ClosePanel(); });
} else {
Inv.onClick.AddListener(delegate {OpenPanel(); });
}
}
void CheckItemOwnership(){
bool item01 = false, item02 = false, item03 = false, item04 = false, item05 = false, item06 = false;
foreach (InventoryItem item in GameState.currentPlayer.Inventory) {
if (item.ItemName.CompareTo ("Little Dagger") == 0)
item01 = true;
if (item.ItemName.CompareTo ("Longsword") == 0)
item02 = true;
if (item.ItemName.CompareTo ("Cutlass") == 0)
item03 = true;
if (item.ItemName.CompareTo ("Royal Guard Longsword") == 0)
item04 = true;
if (item.ItemName.CompareTo ("Sleeping Dragon") == 0)
item05 = true;
if (item.ItemName.CompareTo ("Bearded Axe") == 0)
item06 = true;
}
if(item01){Item01.SetActive (true);}else{Item01.SetActive (false);}
if(item02){Item02.SetActive (true);}else{Item02.SetActive (false);}
if(item03){Item03.SetActive (true);}else{Item03.SetActive (false);}
if(item04){Item04.SetActive (true);}else{Item04.SetActive (false);}
if(item05){Item05.SetActive (true);}else{Item05.SetActive (false);}
if(item06){Item06.SetActive (true);}else{Item06.SetActive (false);}
}
void OpenPanel()
{
Panel.SetActive (true);
clickSFX.pitch = 1f;
clickSFX.Play ();
}
void ClosePanel(){
Panel.SetActive (false);
clickSFX.pitch = 0.75f;
clickSFX.Play ();
}
}