forked from powerfun/udpservice
Random初始化只取一次
This commit is contained in:
parent
b07be239fd
commit
c3a9437fc8
@ -36,30 +36,31 @@ namespace OnlineUserPool.Hander
|
||||
UpdateVirtualTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private Random rand = new Random();
|
||||
|
||||
//根据当前时段计算虚拟总人数
|
||||
private int ComputeTop()
|
||||
{
|
||||
var rand = new Random();
|
||||
var hour = DateTime.Now.Hour;//当前点数
|
||||
int offset = 1;//少:1 中:3 多:10
|
||||
int top = 1;//少:1 中:3 多:10
|
||||
if (hour <= 6)
|
||||
{
|
||||
offset = rand.Next((int)(0.8 * START), (int)(1.2 * START));
|
||||
top = rand.Next((int)(0.8 * START), (int)(1.2 * START));
|
||||
}
|
||||
if (hour > 6 && hour <= 18)
|
||||
{
|
||||
offset = rand.Next((int)(0.8 * OFFSET), (int)(1.2 * MEDIUM));
|
||||
top = rand.Next((int)(0.8 * OFFSET), (int)(1.2 * MEDIUM));
|
||||
}
|
||||
if (hour >= 18 && hour <= 22)
|
||||
{
|
||||
offset = rand.Next((int)(0.8 * LARGE), (int)(1.2 * LARGE));
|
||||
top = rand.Next((int)(0.8 * LARGE), (int)(1.2 * LARGE));
|
||||
}
|
||||
if (hour > 22 && hour <= 24)
|
||||
{
|
||||
offset = rand.Next((int)(0.8 * SMALL), (int)(1.2 * SMALL));
|
||||
top = rand.Next((int)(0.8 * SMALL), (int)(1.2 * SMALL));
|
||||
}
|
||||
return offset;
|
||||
return top;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user