-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.cs
More file actions
153 lines (109 loc) · 4.77 KB
/
UI.cs
File metadata and controls
153 lines (109 loc) · 4.77 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace monowizard
{
internal class UI
{
public int healthnumb1;
public int healthnumb2;
public Texture2D healthfont;
public Rectangle healthnumb1crop = new Rectangle(0,0,128,128);
public Rectangle healthnumb1pos = new Rectangle(30, 30, 80, 80);
public Rectangle healthnumb2crop = new Rectangle(128, 0, 128, 128);
public Rectangle healthnumb2pos = new Rectangle(100, 30, 80, 80);
public Rectangle scroll1crop = new Rectangle(0, 0, 128, 128);
public Rectangle scroll2pos = new Rectangle(1560, 30, 100, 100);
public Rectangle scroll3pos = new Rectangle(1680, 30, 100, 100);
public Rectangle scroll4pos = new Rectangle(1800, 30, 100, 100);
public Rectangle scroll1pos = new Rectangle(1440, 30, 100, 100);
public Rectangle spell1pos = new Rectangle(1450, 40, 80, 80);
public Rectangle spell2pos = new Rectangle(1570, 40, 80, 80);
public Rectangle spell3pos = new Rectangle(1690, 40, 80, 80);
public Rectangle spell4pos = new Rectangle(1810, 40, 80, 80);
public int mananumb1;
public int mananumb2;
public Texture2D manafont;
public Rectangle mananumb1crop = new Rectangle(0, 0, 128, 128);
public Rectangle mananumb1pos = new Rectangle(300, 30, 80, 80);
public Rectangle mananumb2crop = new Rectangle(128, 0, 128, 128);
public Rectangle mananumb2pos = new Rectangle(370, 30, 80, 80);
public List<UIElement> items = new List<UIElement>();
public Texture2D UIElements;
public Player player;
public UI()
{
setHealth(80);
setMana(5);
}
public void setHealth(int x) {
if (x > 9)
{
int twosplace = x % 10;
int onesplace = x / 10;
healthnumb2crop = new Rectangle((128*twosplace), 0, 128, 128);
healthnumb1crop = new Rectangle((128 * onesplace), 0, 128, 128);
}
else {
healthnumb2crop = new Rectangle(128, 0, 1, 1);
healthnumb1crop = new Rectangle((128 * x), 0, 128, 128);
}
}
public UIString addUINumber(int x, int y, int num)
{
UIString newstring = new UIString(x, y, 80, 80, num, manafont);
items.Add(newstring);
return newstring;
}
public void setMana(int x)
{
if (x > 9)
{
int twosplace = x % 10;
int onesplace = x / 10;
mananumb2crop = new Rectangle((128 * twosplace), 0, 128, 128);
mananumb1crop = new Rectangle((128 * onesplace), 0, 128, 128);
}
else
{
mananumb2crop = new Rectangle(128, 0, 1, 1);
mananumb1crop = new Rectangle((128 * x), 0, 128, 128);
}
}
public void draw(SpriteBatch _spriteBatch) {
_spriteBatch.Draw(healthfont, healthnumb1pos,healthnumb1crop, Color.White);
_spriteBatch.Draw(healthfont, healthnumb2pos, healthnumb2crop, Color.White);
_spriteBatch.Draw(manafont, mananumb1pos, mananumb1crop, Color.White);
_spriteBatch.Draw(manafont, mananumb2pos, mananumb2crop, Color.White);
_spriteBatch.Draw(UIElements, scroll1pos, scroll1crop, Color.White);
if (player.cantrip != null)
{
_spriteBatch.Draw(player.itemManager.magicsymbols, spell1pos, player.cantrip.symbcroprect, Color.White);
}
_spriteBatch.Draw(UIElements, scroll2pos, scroll1crop, Color.White);
if (player.cantrip2 != null)
{
_spriteBatch.Draw(player.itemManager.magicsymbols, spell2pos, player.cantrip2.symbcroprect, Color.White);
}
_spriteBatch.Draw(UIElements, scroll3pos, scroll1crop, Color.White);
if (player.cantrip3 != null)
{
_spriteBatch.Draw(player.itemManager.magicsymbols, spell3pos, player.cantrip3.symbcroprect, Color.White);
}
_spriteBatch.Draw(UIElements, scroll4pos, scroll1crop, Color.White);
if (player.cantrip4 != null)
{
_spriteBatch.Draw(player.itemManager.magicsymbols, spell4pos, player.cantrip4.symbcroprect, Color.White);
}
for (int i = 0; i < items.Count; i++)
{
items[i].draw(_spriteBatch);
}
}
}
}