mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
56 lines
1.1 KiB
C#
56 lines
1.1 KiB
C#
|
using System;
|
|||
|
using JNGame.Math;
|
|||
|
using JNGame.Sync.System;
|
|||
|
using Plugins.JNGame.Util;
|
|||
|
|
|||
|
namespace JNGame.Sync.Frame.Service
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 随机数
|
|||
|
/// </summary>
|
|||
|
public class JNRandomSystem : SLogicSystem
|
|||
|
{
|
|||
|
|
|||
|
//随机数
|
|||
|
private Func<LFloat,LFloat,LFloat> nRandomFloat;
|
|||
|
private Func<int,int,int> nRandomInt;
|
|||
|
|
|||
|
//Id
|
|||
|
private long _id = 0;
|
|||
|
|
|||
|
public JNRandomSystem(int seed)
|
|||
|
{
|
|||
|
nRandomFloat = RandomUtil.SyncRandomFloat(seed);
|
|||
|
nRandomInt = RandomUtil.SyncRandomInt(seed);
|
|||
|
}
|
|||
|
|
|||
|
public LFloat Float()
|
|||
|
{
|
|||
|
return Float(0,1);
|
|||
|
}
|
|||
|
|
|||
|
public LFloat Float(LFloat min,LFloat max)
|
|||
|
{
|
|||
|
return nRandomFloat(min,max);
|
|||
|
}
|
|||
|
|
|||
|
public int Int(int max,int min)
|
|||
|
{
|
|||
|
return nRandomInt(max,min);
|
|||
|
}
|
|||
|
|
|||
|
public long NextId()
|
|||
|
{
|
|||
|
return ++_id;
|
|||
|
}
|
|||
|
|
|||
|
public void SetIdValue(long id)
|
|||
|
{
|
|||
|
if (_id < id)
|
|||
|
{
|
|||
|
_id = id;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|