Slot Rotation hinzugefügt

This commit is contained in:
NBTEMP\bib
2026-09-07 14:59:02 +02:00
parent abe9867cb1
commit f3d313c914
2 changed files with 45 additions and 11 deletions
+40 -8
View File
@@ -20,8 +20,11 @@ namespace Casino
/// </summary>
public partial class Slots : Window
{
private List<Image> _bilder;
private Random _random = new Random();
Database db = new Database();
private List<Byte[]> AlleBilder;
public Slots()
{
@@ -29,16 +32,26 @@ namespace Casino
LoadCard(8);
_bilder = new List<Image>
{
Bild_11, Bild_12, Bild_13, Bild_14, Bild_15, Bild_16,
Bild_21, Bild_22, Bild_23, Bild_24, Bild_25, Bild_26,
Bild_31, Bild_32, Bild_33, Bild_34, Bild_35, Bild_36
};
AlleBilder = new List<Byte[]>
{
db.GetCardImage(2),db.GetCardImage(3),db.GetCardImage(4),
db.GetCardImage(5),db.GetCardImage(6),db.GetCardImage(7),
db.GetCardImage(8),db.GetCardImage(9),db.GetCardImage(10),
};
}
private void LoadCard(int Bild)
{
Database db = new Database();
byte[] img = db.GetCardImage(Bild);//2-10
Bild_11.Source = ByteArrayToImage(img);
private void LoadCard(Image imageControl, int bildId)
{
byte[] img = AlleBilder.ElementAt(bildId);
imageControl.Source = ByteArrayToImage(img);
}
private BitmapImage ByteArrayToImage(byte[] bytes)
@@ -53,5 +66,24 @@ namespace Casino
}
return image;
}
private async Task Spin()
{
for (int i = 0; i < 50; i++)
{
foreach (var image in _bilder)
{
int randomBild = _random.Next(2, AlleBilder.Count);
LoadCard(image, randomBild);
}
await Task.Delay(70);
}
}
private async void Spin(object sender, RoutedEventArgs e)
{
await Spin();
}
}
}