我有一些代码使用随机数来确定对象是否特殊.我在每个经常重置的4个对象中使用此代码.
Random rand = new Random();
int i = rand.Next(1, 25);
if (i == 1)
{
thiss.typer = "boulder";
thiss.texture = Content.Load<Texture2D>("rock");
}
else if (i == 2)
{
thiss.typer = "ice";
thiss.texture = Content.Load<Texture2D>("ice");
}
else if (i == 3)
{
thiss.typer = "bomb";
thiss.texture = Content.Load<Texture2D>("bomb");
}
else
thiss.typer = "normal";
Run Code Online (Sandbox Code Playgroud)
但每次执行此代码时,当它创建4个对象时,当它使其中一个特殊时,它会因为某些原因使它们全部特殊.这段代码有什么问题,或者我是否需要展示更多代码才能解释它?