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 _mIdRecordDict; private static Dictionary _mIdTypeDict; static UtilID() { _mIdRecordDict = new Dictionary(); foreach (EIdType typeNow in Enum.GetValues(typeof(EIdType))) { _mIdRecordDict[typeNow] = 1; } _mIdTypeDict = new Dictionary(){ {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; } } }