public IEnumerator wildEncounter(WildPokemonInitialiser.Method encounterLocation) { if (accessedMapSettings.getEncounterList(encounterLocation).Length > 0) { if (Random.value <= accessedMapSettings.getEncounterProbability()) { if (setCheckBusyWith(Scene.main.Battle.gameObject)) { BgmHandler.main.PlayOverlay(Scene.main.Battle.defaultWildBGM, Scene.main.Battle.defaultWildBGMLoopStart); //SceneTransition sceneTransition = Dialog.transform.GetComponent<SceneTransition>(); yield return(StartCoroutine(ScreenFade.main.FadeCutout(false, ScreenFade.slowedSpeed, null))); //yield return new WaitForSeconds(sceneTransition.FadeOut(1f)); Scene.main.Battle.gameObject.SetActive(true); StartCoroutine(Scene.main.Battle.control(accessedMapSettings.getRandomEncounter(encounterLocation))); while (Scene.main.Battle.gameObject.activeSelf) { yield return(null); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); unsetCheckBusyWith(Scene.main.Battle.gameObject); } } } }
public WildPokemonInitialiser[] getEncounterList(WildPokemonInitialiser.Method 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); }
/// <summary> /// Random Wild Pokemon Encounter 2.0 /// </summary> /// <param name="location"></param> /// <returns></returns> public Pokemon getRandomEncounter(WildPokemonInitialiser.Method location, string placeholder) { //Get list of 100 pokemons for given (specific to this) encounter... WildPokemonInitialiser[] list = getEncounterList(location); //From list of 100 pokemons, select 1. int randomPokemon = Random.Range(0, 100); /*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(list[randomPokemon].ID, Pokemon.Gender.CALCULATE, Random.Range(list[randomPokemon].minLevel, list[randomPokemon].maxLevel + 1), null, null, null, -1)); }
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)); }
/// <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); }