public static GameEvent GetGameEvent() { if (NextId == -1) { inSeries = false; } if (inSeries) { CurrentEvent = SerialGameEvents[NextId]; return(SerialGameEvents[NextId]); } else { if (Random.Range(0f, 1f) > SerialEventRate) { ////生成普通事件 //int i = Random.Range(0, EventCount); //int tryCount = 0; //while (isEventUsed[i] && tryCount<=EventCount) //{ // i++; // i %= EventCount; // tryCount++; //} //isEventUsed[i] = true; //return GameEvents[i]; return(GetNormalEvent()); } else { ////生成系列事件 //int i = Random.Range(0, SerialEventCount); //int tryCount = 0; //while (isSerialEventUsed[i] && tryCount <= SerialEventCount || SerialGameEvents[i].IsBegin ==false) //{ // i++; // i %= SerialEventCount; // tryCount++; //} //isSerialEventUsed[i] = true; //inSeries = true; //CurrentEvent = SerialGameEvents[i]; //return SerialGameEvents[i]; return(GetSerialEvent()); } } }
static GameEvent GetSerialEvent() { //生成系列事件 int i = Random.Range(0, SerialEventCount); int tryCount = 0; while (isSerialEventUsed[i] && tryCount <= SerialEventCount || SerialGameEvents[i].IsBegin == false) { i++; i %= SerialEventCount; tryCount++; if (tryCount > SerialEventCount) { return(GetNormalEvent()); } } isSerialEventUsed[i] = true; inSeries = true; CurrentEvent = SerialGameEvents[i]; return(SerialGameEvents[i]); }