Ejemplo n.º 1
0
        private IEnumerator ExecuteTrade()
        {
            //Animation should be run first as player offered pokemon locator will point to incorrect pokemon otherwise

            tradeAnimationController.Show();
            yield return(StartCoroutine(tradeAnimationController.RunAnimation(PlayerOfferedPokemon, otherUserOfferedPokemon)));

            tradeAnimationController.Hide();

            //Before this point, the pokemon at the locator's position is still the old pokemon

            ExecuteTrade_ChangePokemon();

            //After this point, the pokemon at the locator's position has been changed to the new pokemon

            PokemonInstance recvPmon = ((PlayerData.PokemonLocator)playerOfferedPokemonLocator).Get(Player);

            #region Trade Evolution

            if (recvPmon.heldItem == null || recvPmon.heldItem.id != 229) //Only consider evolving if not holding everstone
            {
                PokemonSpecies.Evolution evol = recvPmon.TryFindEvolution(trading: true);

                //If valid evolution found, perform it
                if (evol != null)
                {
                    EvolutionSceneController.entranceArguments = new EvolutionSceneController.EntranceArguments()
                    {
                        evolution = evol,
                        pokemon   = recvPmon
                    };

                    DisableScene();

                    GameSceneManager.LaunchEvolutionScene();

                    bool continueAfterEvolution = false;

                    GameSceneManager.EvolutionSceneClosed += () => continueAfterEvolution = true;

                    yield return(new WaitUntil(() => continueAfterEvolution));

                    EnableScene();
                }
            }

            #endregion
        }