Пример #1
0
        public async Task <IActionResult> Index(string name)
        {
            if (name != null)
            {
                PokemonClass pokemon = await GetPokemonInfo(name);

                return(View(pokemon));
            }
            return(View());
        }
Пример #2
0
 public void showPokemon()
 {
     SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer> ();
             if (this.CompareTag ("Player")) {
                     myPokemon = party[numOfPokemon];
                     spriteRenderer.sprite = myPokemon.myStats.backPic;
             } else {
                     myPokemon = party[numOfPokemon];
                     spriteRenderer.sprite = myPokemon.myStats.frontPic;
             }
             name = myPokemon.myStats.name;
             this.renderer.enabled = true;
             ownHealth.fainted = false;
 }
Пример #3
0
        public async Task <PokemonClass> GetPokemonInfo(string targetPokemon)
        {
            PokemonClass pokemon = new PokemonClass();

            string location = await client.GetStringAsync("https://pokeapi.co/api/v2/pokemon/" + targetPokemon + "/encounters");

            string sprite = await client.GetStringAsync("https://pokeapi.co/api/v2/pokemon-form/" + targetPokemon);

            var pokemonLocations = JsonConvert.DeserializeObject <dynamic>(location);
            var pokemonImage     = JsonConvert.DeserializeObject <dynamic>(sprite);

            foreach (var pokemonLocation in pokemonLocations)
            {
                pokemon.Locations.Add(pokemonLocation.location_area.name.ToString());
            }

            pokemon.SpriteUrl = pokemonImage.sprites.front_default.ToString();
            return(pokemon);
        }
    void addToPokemon(string input, int lineNum)
    {
        int whereToPlace = lineNum % maxDataPer;

                switch (whereToPlace) {
                case 0:
                        pokein = new PokemonClass();
                        pokein.myStats.currMoves = new move[4];
                        pokein.myStats.pokedexNum = int.Parse (input);
                        pokein.myStats.backPic = pokeBacks[pokein.myStats.pokedexNum-1];
                        pokein.myStats.frontPic = pokeFronts[pokein.myStats.pokedexNum-1];
                        pokeDexNums[counter] = pokein.myStats.pokedexNum;
                        counter++;
                        break;
                case 1:
                        pokein.myStats.name = input;
                        break;

                case 2:
                        pokein.myStats.level = int.Parse(input);
                        break;
                case 3:
                        pokein.myStats.maxHP = int.Parse (input);
                        break;
                case 4:
                        pokein.myStats.attack = int.Parse (input);
                        break;
                case 5:
                        pokein.myStats.defense = int.Parse (input);
                        break;
                case 6:
                        pokein.myStats.spAttack = int.Parse (input);
                        break;
                case 7:
                        pokein.myStats.spDefense = int.Parse (input);
                        break;
                case 8:
                        pokein.myStats.speed = int.Parse (input);
                        break;
                case 9:
                        pokein.numMoves = int.Parse (input);
                        break;
                case 10:
                        pokein.myStats.currMoves [0].name = input;
                        break;
                case 11:
                        pokein.myStats.currMoves [0].pp = int.Parse (input);
                        break;
                case 12:
                        pokein.myStats.currMoves [0].power = int.Parse (input);
                        break;
                case 13:
                        pokein.myStats.currMoves [0].accuracy = int.Parse (input);
                        break;
                case 14:
                        pokein.myStats.currMoves [1].name = input;
                        break;
                case 15:
                        pokein.myStats.currMoves [1].pp = int.Parse (input);
                        break;
                case 16:
                        pokein.myStats.currMoves [1].power = int.Parse (input);
                        break;
                case 17:
                    pokein.myStats.currMoves [1].accuracy = int.Parse (input);
                    break;
                case 18:
                    pokein.myStats.currMoves [2].name = input;
                    break;
                case 19:
                    pokein.myStats.currMoves [2].pp = int.Parse (input);
                    break;
                case 20:
                    pokein.myStats.currMoves [2].power = int.Parse (input);
                    break;
                case 21:
                    pokein.myStats.currMoves [2].accuracy = int.Parse (input);
                    break;
                case 22:
                    pokein.myStats.currMoves [3].name = input;
                    break;
                case 23:
                    pokein.myStats.currMoves [3].pp = int.Parse (input);
                    break;
                case 24:
                    pokein.myStats.currMoves [3].power = int.Parse (input);
                    break;
                case 25:
                    pokein.myStats.currMoves [3].accuracy = int.Parse (input);
                    allPokemon.Add(pokein.myStats.pokedexNum, pokein);
                    break;
                }
    }
    void Start()
    {
        allPokemon = new Dictionary<int, PokemonClass> ();
        pokein = new PokemonClass ();
        pokein.myStats.currMoves = new move[4];
        pokeDexNums = new int[16];
        pokeBacks = Resources.LoadAll<Sprite> ("pokemon backs");
        pokeFronts = Resources.LoadAll<Sprite> ("Game Boy - Pokemon RedBlue - Pokemon Color");

        sourceFile = (TextAsset)Resources.Load ("POKEMON", typeof(TextAsset));
        foreach(string s in sourceFile.text.Split('\n')){
            x=s;
            addToPokemon(s, line);
            line++;
        }
        x = pokein.myStats.name;
    }