这是我的第一篇文章,我真的需要帮助。匹配的值箱的图片框
我的问题是我创建一个使用C#的老虎机游戏,除了值之外,我已经完成了所有工作。我的想法是,我需要匹配的图片与它的价值,可以说(图片小丑= 100分)。无论如何要使用一个函数来做到这一点,所以我可以在整个程序中稍后调用它。
我曾尝试使用这种功能:
void ImageValues (int RollResult)
{
switch (RollResult)
{
case 0 :
TempTotal += 100;
break;
case 1 :
TempTotal += 225;
break;
case 2 :
TempTotal += 550;
break;
case 3 :
TempTotal += 775;
break;
case 4 :
TempTotal += 1000;
break;
}
}
但是当我调用该函数我定义我想要使用的情况。没有办法,我可以预先设定一个画面时的价值,我的朋友告诉我要尝试匹配索引,如图片的指数从:到pictureboxes阵列
int[] PictureValues = new int[]{100, 225, 550, 775, 1000};
:
PictureBox[] PictureboxArray = new PictureBox[5];
有没有办法做到这一点?谢谢您的帮助。
编辑1,图像通常这样分配
PictureboxArray[0] = pbxK;
PictureboxArray[1] = pbxQueen;
PictureboxArray[2] = pbxKing;
PictureboxArray[3] = pbxJoker;
PictureboxArray[4] = pbxAce;
Rollimage[0] = Properties.Resources.K;
Rollimage[1] = Properties.Resources.Queen;
Rollimage[2] = Properties.Resources.King;
Rollimage[3] = Properties.Resources.Joker;
Rollimage[4] = Properties.Resources.Ace;
pbxK.Image = Rollimage[0];
pbxQueen.Image = Rollimage[1];
pbxKing.Image = Rollimage[2];
pbxJoker.Image = Rollimage[3];
pbxAce.Image = Rollimage[4];
如何判断图片是否是小丑? – Gnqz
我有5个pictureboxes,每个pictureboxes随机5张图片,所以我使用的case语句说,如果任何pictureboxes有小丑,然后添加到temptotal这种价值 – ZainHikary
张贴您的检查代码,如果picturebox是一个小丑。 – Gnqz