void GetExperience() { PokemonModel lastPokemon = pokemonGettingExperience; //get pokemon who fought and not died int pokemonsWhoFoughtNotDead = fightManager.pokemonsWhoFought.Where(p => p.CurrentHealth > 0).ToArray().Length; //every player pokemon who fought get experience foreach (PokemonModel pokemon in fightManager.pokemonsWhoFought) { //do only if in player list (when catch pokemon can replace pokemon who fought) if (GameManager.instance.Player.PlayerPokemons.Contains(pokemon) == false) { pokemonsWhoGotExperience.Add(pokemon); continue; } //first get experience the pokemon in arena (if in player list) if (pokemonGettingExperience == null) { pokemonGettingExperience = fightManager.currentPlayerPokemon; pokemonsWhoGotExperience.Add(pokemonGettingExperience); break; } //then all the others else if (pokemonsWhoGotExperience.Contains(pokemon) == false) { pokemonGettingExperience = pokemon; pokemonsWhoGotExperience.Add(pokemon); //update UI fightManager.SetCurrentPlayerPokemon(pokemon); fightManager.FightUIManager.SetPokemonInArena(true); break; } } //if == last pokemon, then there are only pokemon which are no more in player list if (pokemonGettingExperience == lastPokemon) { EndFight(); return; } //set previous exp previousExp = pokemonGettingExperience.CurrentExp; //get experience from every enemy pokemon foreach (PokemonModel enemyPokemon in fightManager.enemyPokemons) { pokemonGettingExperience.GetExperience(true, enemyPokemon, pokemonsWhoFoughtNotDead); } SetDescription(); }