2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
namespace Game
{
public enum EIdGenType
{
Intiger, //+1
Code, //<<1
}
public enum EIdType
{
Entity,
SkillCast,
}
public static class UtilID
{
private static Dictionary<EIdType, int> _mIdRecordDict;
private static Dictionary<EIdType, EIdGenType> _mIdTypeDict;
static UtilID()
{
_mIdRecordDict = new Dictionary<EIdType, int>();
foreach (EIdType typeNow in Enum.GetValues(typeof(EIdType)))
{
_mIdRecordDict[typeNow] = 1;
}
_mIdTypeDict = new Dictionary<EIdType, EIdGenType>(){
{EIdType.Entity,EIdGenType.Intiger},
{EIdType.SkillCast,EIdGenType.Intiger},
};
}
public static int GetID(EIdType idType)
{
int ret = _mIdRecordDict[idType];
switch ((int)_mIdTypeDict[idType])
{
case (int)EIdGenType.Intiger:
_mIdRecordDict[idType] += 1;
break;
case (int)EIdGenType.Code:
_mIdRecordDict[idType] = _mIdRecordDict[idType] << 1;
break;
default:
_mIdRecordDict[idType] += 1;
break;
}
return ret;
}
}
}