Beispiel #1
0
    // TEMP - Until player gets pokemon by story script
    private void Start()
    {
        Pokemon pokemon = Pokemon.CreateInstance <Pokemon> ();

        pokemon.GeneratePokemon(6, 20);
        pokemonTeam.Add(pokemon);
    }
Beispiel #2
0
    //-----------------------------------------------------------------------------------------------------------
    bool LookForRandomEncounter()
    {
        if (Random.Range(0, 101) < Config.ENCOUNTER_PROBA)
        {
            //get current area wild pokemons
            GameObject currentMapObject = GameObject.FindWithTag("CurrentMap");
            if (currentMapObject)
            {
                List <MapDatabase.MapWildPokemon> listPoke = MapDatabase.GetListOfWildPokemons(currentMapObject.name);
                if (listPoke != null && listPoke.Count > 0)
                {
                    //random to choose which pokemon is encountered
                    int randValue   = Random.Range(0, 101);
                    int proba       = 0;               //listPoke [0].m_proba;
                    int indexChoice = -1;
                    for (int i = 0; i < listPoke.Count && indexChoice == -1; i++)
                    {
                        proba += listPoke [i].m_proba;
                        if (randValue < proba)                          //we found the pokemon
                        {
                            indexChoice = i;
                        }
                    }

                    //In case the proba in DB were not equal to 100, there may not be a pokemon found
                    Assert.AreNotEqual(indexChoice, -1);
                    if (indexChoice != -1)
                    {
                        Pokemon wildPokemon = Pokemon.CreateInstance <Pokemon> ();
                        wildPokemon.GeneratePokemon(listPoke[indexChoice].m_pokemonId, listPoke[indexChoice].m_minLvl, listPoke[indexChoice].m_maxLvl);

                        BattleManager battleManager = FindObjectOfType <BattleManager> ();
                        if (battleManager)
                        {
                            //At least one pokemon available, block Player action before fight
                            playerActionComp.m_playerBlocked = true;
                            m_animator.SetBool("isWalking", false);

                            //TODO: Anim transition
                            //start anim
                            //while anim, generate pokemon

                            //TODO
                            //display fight UI
                            //StartEncounter ();
                            battleManager.StartFight(wildPokemon);

                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }