-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIString.cs
More file actions
86 lines (65 loc) · 2.26 KB
/
UIString.cs
File metadata and controls
86 lines (65 loc) · 2.26 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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace monowizard
{
internal class UIString : UIElement
{
public List<int> digits = new List<int>();
public List<Rectangle> cropboxes = new List<Rectangle>();
public List<Rectangle> posboxes = new List<Rectangle>();
public Texture2D manafont;
public UIString(int x, int y, int width, int height, int num, Texture2D manafont)
{
// int numdigits = num.ToString().Length;
string strnum = num.ToString();
int numdigits = strnum.Length;
// int cnt = 0;
int bar;
foreach (char c in strnum)
{
bar = c - '0';
digits.Add(bar);
}
for (int i = 0; i < numdigits; i++)
{
cropboxes.Add(new Rectangle(128 * digits[i], 0, 128, 128));
posboxes.Add(new Rectangle(x + (width * i), y, width, height));
}
this.manafont = manafont;
}
public int Relocate(int x, int y, int width, int height)
{
for (int i = 0; i < digits.Count; i++)
{
posboxes[i] = new Rectangle(x + (width * i), y, width, height);
}
return 0;
}
public int ReverseNumber(int num)
{
// Convert the number to a string
string numStr = num.ToString();
// Reverse the string
char[] charArray = numStr.ToCharArray();
Array.Reverse(charArray);
string reversedStr = new string(charArray);
// Convert the reversed string back to an integer
int reversedNum = int.Parse(reversedStr);
//bad it removes the 0
return reversedNum;
}
public override void draw(SpriteBatch _spriteBatch)
{
for(int i = 0; i < digits.Count; i++)
{
_spriteBatch.Draw(manafont, posboxes[i], cropboxes[i], Color.White);
}
}
}
}