public WildPokemonInitialiser[] getEncounterList(WildPokemonInitialiser.Location location) { WildPokemonInitialiser[] list = new WildPokemonInitialiser[encounters.Length]; int listIndex = 0; float time = System.DateTime.Now.Hour + ((float)System.DateTime.Now.Minute / 60f); for (int i = 0; i < encounters.Length; i++) { if (encounters[i].encounterLocation == location) { if (time >= 20 || time < 3.5f) { //night if (encounters[i].encounterNight) { list[listIndex] = encounters[i]; listIndex += 1; } } else if (time < 10f) { //morning if (encounters[i].encounterMorning) { list[listIndex] = encounters[i]; listIndex += 1; } } else { //day if (encounters[i].encounterDay) { list[listIndex] = encounters[i]; listIndex += 1; } } } } WildPokemonInitialiser[] packedList = new WildPokemonInitialiser[listIndex]; for (int i = 0; i < packedList.Length; i++) { packedList[i] = list[i]; } return(packedList); }
public Pokemon getRandomEncounter(WildPokemonInitialiser.Method location) { WildPokemonInitialiser[] list = getEncounterList(location); int totalEncounterLikelihood = 0; //add up the total Likelihood for (int i = 0; i < list.Length; i++) { totalEncounterLikelihood += list[i].encounterLikelihood; } WildPokemonInitialiser[] chanceSplitList = new WildPokemonInitialiser[totalEncounterLikelihood]; int listIndex = 0; for (int i = 0; i < list.Length; i++) { //loop through each position of list for (int i2 = 0; i2 < list[i].encounterLikelihood; i2++) { //add encounter once for every Likelihood chanceSplitList[listIndex] = list[i]; listIndex += 1; } } //randomly pick a number from the list's length int encounterIndex = Random.Range(0, chanceSplitList.Length); #if DEBUG string debugtext = ""; for (int i = 0; i < chanceSplitList.Length; i++) { debugtext += PokemonDatabase.getPokemon(chanceSplitList[i].ID).getName() + ", "; } Debug.Log(encounterIndex + ": " + debugtext + "(" + PokemonDatabase.getPokemon(chanceSplitList[encounterIndex].ID).getName() + ")"); #endif return(new Pokemon(chanceSplitList[encounterIndex].ID, Pokemon.Gender.CALCULATE, Random.Range(chanceSplitList[encounterIndex].minLevel, chanceSplitList[encounterIndex].maxLevel + 1), null, null, null, -1)); }
public OwnedPokemon getRandomEncounter(WildPokemonInitialiser.Location location) { WildPokemonInitialiser[] list = getEncounterList(location); int totalEncounterLikelihood = 0; //add up the total Likelihood for (int i = 0; i < list.Length; i++) { totalEncounterLikelihood += list[i].encounterLikelihood; } WildPokemonInitialiser[] chanceSplitList = new WildPokemonInitialiser[totalEncounterLikelihood]; int listIndex = 0; for (int i = 0; i < list.Length; i++) { //loop through each position of list for (int i2 = 0; i2 < list[i].encounterLikelihood; i2++) { //add encounter once for every Likelihood chanceSplitList[listIndex] = list[i]; listIndex += 1; } } //randomly pick a number from the list's length int encounterIndex = Random.Range(0, chanceSplitList.Length); /*/ DEBug * string debugtext = ""; * for(int i = 0; i < chanceSplitList.Length; i++){ * debugtext += PokemonDatabase.Instance.GetPokemonSpeciesByGameId(chanceSplitList[i].ID).getName() + ", ";} * Debug.Log(encounterIndex+": "+debugtext + "("+PokemonDatabase.Instance.GetPokemonSpeciesByGameId(chanceSplitList[encounterIndex].ID).getName()+")"); * //*/ return(new OwnedPokemon(chanceSplitList[encounterIndex].ID.ToString(), PokemonGender.CALCULATE, Random.Range(chanceSplitList[encounterIndex].minLevel, chanceSplitList[encounterIndex].maxLevel + 1), null, null, null, -1)); }
/// <summary> /// Random Encounter list for Pokemon Encounter 2.0 /// </summary> /// <param name="location"></param> /// <returns></returns> public WildPokemonInitialiser[] getEncounterList(int mapId, WildPokemonInitialiser.Method method, WildPokemonInitialiser.ConditionValue[] condition = null) { WildPokemonInitialiser[] list = new WildPokemonInitialiser[100]; int listIndex = 0; int version = 0; //MapId will play a part of what version int slots = 0; //Maybe an Array, matching Slots to given %chance ratio switch (method) { case WildPokemonInitialiser.Method.WALK: slots = 12; for (int i = 0; i < list.Length; i++) { list[i] = new WildPokemonInitialiser { ID = 0, minLevel = 0, maxLevel = 0 }; } break; case WildPokemonInitialiser.Method.GRASS_SPOTS: //slots = 12; break; case WildPokemonInitialiser.Method.CAVE_SPOTS: //slots = 12; break; case WildPokemonInitialiser.Method.BRIDGE_SPOTS: //slots = 12; break; case WildPokemonInitialiser.Method.DARK_GRASS: //slots = 12; break; case WildPokemonInitialiser.Method.YELLOW_FLOWERS: slots = 12; break; case WildPokemonInitialiser.Method.PURPLE_FLOWERS: slots = 12; break; case WildPokemonInitialiser.Method.RED_FLOWERS: slots = 12; break; case WildPokemonInitialiser.Method.ROUGH_TERRAIN: slots = 12; break; case WildPokemonInitialiser.Method.OLD_ROD: slots = 3; break; case WildPokemonInitialiser.Method.GOOD_ROD: slots = 3; break; case WildPokemonInitialiser.Method.SUPER_ROD: slots = 3; break; case WildPokemonInitialiser.Method.SUPER_ROD_SPOTS: //slots = 5; break; case WildPokemonInitialiser.Method.SURF: if (version == 1 || version == 2) { slots = 10; } else { slots = 5; } break; case WildPokemonInitialiser.Method.SURF_SPOTS: //slots = 5; break; case WildPokemonInitialiser.Method.ROCK_SMASH: if (version == 10) { slots = 2; } else { slots = 5; } break; case WildPokemonInitialiser.Method.HEADBUTT: //slots = 12; break; default: break; } float time = System.DateTime.Now.Hour + ((float)System.DateTime.Now.Minute / 60f); for (int i = 0; i < encounters.Length; i++) { if (encounters[i].encounterLocation == method) { if (time >= 20 || time < 3.5f) { //night if (encounters[i].encounterNight) { list[listIndex] = encounters[i]; listIndex += 1; } } else if (time < 10f) { //morning if (encounters[i].encounterMorning) { list[listIndex] = encounters[i]; listIndex += 1; } } else { //day if (encounters[i].encounterDay) { list[listIndex] = encounters[i]; listIndex += 1; } } } } WildPokemonInitialiser[] packedList = new WildPokemonInitialiser[listIndex]; for (int i = 0; i < packedList.Length; i++) { packedList[i] = list[i]; } return(packedList); }