Ejemplo n.º 1
0
    public void Set(PokeInfo pokeInfo, UnityAction clickAction)
    {
        _pokeNameText.text =
            pokeInfo.Name +
            UIManager.GetFormattedText("  #" + pokeInfo.Id, TextColorType.GreyLight, false, 12);

        _pokeMaxCpText.text =
            TextManager.GetText(TextType.Element, 0) +
            UIManager.NewLine(1) +
            UIManager.GetFormattedText(TextManager.GetNumericFormat((int)pokeInfo.MaxCp), TextColorType.GreenSmooth,
                                       true, 34);

        _pokeStats.SetStats(pokeInfo.AttackRate, pokeInfo.DefenseRate, pokeInfo.StaminaRate);

        _pokeImage.sprite = pokeInfo.Image;

        foreach (var pokeTypeLabel in _pokeTypeLabels)
        {
            pokeTypeLabel.gameObject.SetActive(false);
        }

        for (int i = 0; i < pokeInfo.Type.Length; i++)
        {
            if (i < _pokeTypeLabels.Length)
            {
                _pokeTypeLabels[i].SetType(pokeInfo.Type[i]);
                _pokeTypeLabels[i].gameObject.SetActive(true);
            }
        }

        _button.onClick.RemoveAllListeners();
        _button.onClick.AddListener(clickAction);
    }
Ejemplo n.º 2
0
    static void LoadPokeInfoFromJson()
    {
        try
        {
            PokeData pokeData = (PokeData)AssetDatabase.LoadAssetAtPath(PokeDataObjPath, typeof(PokeData));

            #region Fill Type Chart
            TextAsset typeChartJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + TypeChartJsonName, typeof(TextAsset));

            PokeTypeChartJson typeChartJson = JsonUtility.FromJson <PokeTypeChartJson>(typeChartJsonString.text);
            TypeChart         typeChart     = pokeData.TypeChart = new TypeChart(typeChartJson.TypeChart.Length);

            for (int i = 0; i < typeChart.TypeParameters.Length; i++)
            {
                TypeParameter typeParam = typeChart.TypeParameters[i] = new TypeParameter();

                typeParam.BaseType = (PokeType)Enum.Parse(typeof(PokeType), typeChartJson.TypeChart[i].Type);

                if (!string.IsNullOrEmpty(typeChartJson.TypeChart[i].Strenghts))
                {
                    string[] strenghtsString = typeChartJson.TypeChart[i].Strenghts.Split(new[] { ", " }, StringSplitOptions.None);
                    typeParam.StrenghtsTypes = new PokeType[strenghtsString.Length];
                    for (int j = 0; j < typeParam.StrenghtsTypes.Length; j++)
                    {
                        typeParam.StrenghtsTypes[j] = (PokeType)Enum.Parse(typeof(PokeType), strenghtsString[j]);
                    }
                }

                if (!string.IsNullOrEmpty(typeChartJson.TypeChart[i].Weaknesses))
                {
                    string[] weaksString = typeChartJson.TypeChart[i].Weaknesses.Split(new[] { ", " }, StringSplitOptions.None);
                    typeParam.WeaknessesTypes = new PokeType[weaksString.Length];
                    for (int j = 0; j < typeParam.WeaknessesTypes.Length; j++)
                    {
                        typeParam.WeaknessesTypes[j] = (PokeType)Enum.Parse(typeof(PokeType), weaksString[j]);
                    }
                }
            }
            #endregion

            #region Load Primary Moves
            TextAsset            primaryMovesJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + PrimaryMovesJsonName, typeof(TextAsset));
            PrimaryMovesDataJson primaryMovesDataJson   = JsonUtility.FromJson <PrimaryMovesDataJson>(primaryMovesJsonString.text);

            pokeData.PrimaryMoves = new PrimaryMove[primaryMovesDataJson.PrimaryMoves.Length];
            for (int i = 0; i < primaryMovesDataJson.PrimaryMoves.Length; i++)
            {
                PrimaryMove      primaryMove      = pokeData.PrimaryMoves[i] = new PrimaryMove();
                PrimaryMovesJson primaryMovesJson = primaryMovesDataJson.PrimaryMoves[i];

                primaryMove.Name       = primaryMovesJson.Name;
                primaryMove.Type       = (PokeType)Enum.Parse(typeof(PokeType), primaryMovesJson.Type);
                primaryMove.Attack     = primaryMovesJson.Atk;
                primaryMove.Cooldown   = primaryMovesJson.Cooldown;
                primaryMove.Dps        = primaryMovesJson.DPS;
                primaryMove.EnergyGain = primaryMovesJson.EnergyGain;

                primaryMove.StrongAgaints = pokeData.TypeChart.GetStrenghts(primaryMove.Type);
                primaryMove.WeakAgains    = pokeData.TypeChart.GetWeaknesses(primaryMove.Type);
            }
            #endregion

            #region Load Secondary Moves
            TextAsset secondaryMovesJsonString            = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + SecondaryMovesJsonName, typeof(TextAsset));
            SecondaryMovesDataJson secondaryMovesDataJson = JsonUtility.FromJson <SecondaryMovesDataJson>(secondaryMovesJsonString.text);

            pokeData.SecondaryMoves = new SecondaryMove[secondaryMovesDataJson.SecondaryMoves.Length];
            for (int i = 0; i < secondaryMovesDataJson.SecondaryMoves.Length; i++)
            {
                SecondaryMove      secMove     = pokeData.SecondaryMoves[i] = new SecondaryMove();
                SecondaryMovesJson secMoveJson = secondaryMovesDataJson.SecondaryMoves[i];

                secMove.Name        = secMoveJson.Name;
                secMove.Type        = (PokeType)Enum.Parse(typeof(PokeType), secMoveJson.Type);
                secMove.ChargeCount = Mathf.Clamp(secMoveJson.ChargeCount, 1, 5);
                secMove.Attack      = secMoveJson.Atk;
                secMove.Cooldown    = secMoveJson.Cooldown;
                secMove.Dps         = secMoveJson.DPS;
                secMove.CritChance  = secMoveJson.CritChance;
                secMove.DidgeWindow = secMoveJson.DodgeWindow;

                secMove.StrongAgaints = pokeData.TypeChart.GetStrenghts(secMove.Type);
                secMove.WeakAgains    = pokeData.TypeChart.GetWeaknesses(secMove.Type);
            }
            #endregion

            #region Load Pokemons
            TextAsset    pokemonsJsonString = (TextAsset)AssetDatabase.LoadAssetAtPath(JsonPath + PokemonsJsonName, typeof(TextAsset));
            PokeDataJson pokeDataJson       = JsonUtility.FromJson <PokeDataJson>(pokemonsJsonString.text);

            pokeData.PokeInfos = new PokeInfo[pokeDataJson.Pokemons.Length];
            for (int i = 0; i < pokeDataJson.Pokemons.Length; i++)
            {
                PokeInfo     pokeInfo     = pokeData.PokeInfos[i] = new PokeInfo();
                PokeInfoJson pokeInfoJson = pokeDataJson.Pokemons[i];
                pokeInfoJson.Name = Regex.Replace(pokeInfoJson.Name, @"\p{Z}", "");

                pokeInfo.Name = pokeInfoJson.Name;
                pokeInfo.Id   = i + 1;

                #region Fill Type
                string[] pokeTypesJson = pokeInfoJson.Type.Split(new[] { ", " }, StringSplitOptions.None);
                pokeInfo.Type = new PokeType[pokeTypesJson.Length];

                for (int j = 0; j < pokeTypesJson.Length; j++)
                {
                    pokeTypesJson[j] = pokeTypesJson[j].Replace(" ", string.Empty);
                    pokeInfo.Type[j] = (PokeType)Enum.Parse(typeof(PokeType), pokeTypesJson[j]);
                }
                #endregion

                pokeInfo.Weight         = pokeInfoJson.Weight;
                pokeInfo.Height         = pokeInfoJson.Height;
                pokeInfo.MaxCp          = pokeInfoJson.MaxCp;
                pokeInfo.CpMultiFromEvo = pokeInfoJson.EvoCpMulti;
                pokeInfo.BaseAttack     = pokeInfoJson.BaseAttack;
                pokeInfo.BaseDefense    = pokeInfoJson.BaseDefense;
                pokeInfo.BaseStamina    = pokeInfoJson.BaseStamina;
                pokeInfo.BaseHp         = pokeInfoJson.BaseHP;
                pokeInfo.Rarity         = pokeInfoJson.Rarity;
                pokeInfo.CaptureRate    = pokeInfoJson.CaptureRate;
                pokeInfo.FleeRate       = pokeInfoJson.FleeRate;
                pokeInfo.Class          = (PokeClass)Enum.Parse(typeof(PokeClass), pokeInfoJson.Class);
                pokeInfo.CandyToEvolve  = pokeInfoJson.CandyToEvolve;

                int eggDistance = 0;
                if (int.TryParse(pokeInfoJson.EggDistanceToHatch.Replace("km", string.Empty), out eggDistance))
                {
                    pokeInfo.EggDistanceType = (EggType)eggDistance;
                }

                #region Fill Primary Moves
                string[] primaryMovesString = pokeInfoJson.PossiblePrimaryMoves.Split(new[] { ", " }, StringSplitOptions.None);

                pokeInfo.PrimaryMovesIds = new int[primaryMovesString.Length];
                for (int j = 0; j < pokeInfo.PrimaryMovesIds.Length; j++)
                {
                    pokeInfo.PrimaryMovesIds[j] = pokeData.GetPrimaryMoveId(primaryMovesString[j]);
                }
                #endregion

                #region Fill Secondary Moves
                string[] secondaryMovesString = pokeInfoJson.PossibleSecondaryMoves.Split(new[] { ", " }, StringSplitOptions.None);

                pokeInfo.SecondaryMovesIds = new int[secondaryMovesString.Length];
                for (int j = 0; j < pokeInfo.SecondaryMovesIds.Length; j++)
                {
                    pokeInfo.SecondaryMovesIds[j] = pokeData.GetSecondaryMoveId(secondaryMovesString[j]);
                }
                #endregion

                pokeInfo.Resistance = pokeData.TypeChart.GetResistance(pokeInfo.Type);
                pokeInfo.Weaknesses = pokeData.TypeChart.GetWeaknesses(pokeInfo.Type);
            }

            #region Fill Evo FromTo
            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo     pokeInfo     = pokeData.PokeInfos[i];
                PokeInfoJson pokeInfoJson = pokeDataJson.Pokemons[i];

                if (!string.IsNullOrEmpty(pokeInfoJson.EvoFrom))
                {
                    pokeInfo.EvoFromId = pokeData.GetPokeInfoIdByName(Regex.Replace(pokeInfoJson.EvoFrom, @"\p{Z}", ""));
                }
                else
                {
                    pokeInfo.EvoFromId = -1;
                }
                if (!string.IsNullOrEmpty(pokeInfoJson.EvoTo))
                {
                    pokeInfo.EvoToId = pokeData.GetPokeInfoIdByName(Regex.Replace(pokeInfoJson.EvoTo, @"\p{Z}", ""));
                }
                else
                {
                    pokeInfo.EvoToId = -1;
                }
            }
            #endregion

            Debug.Log("Loading complete!");
            #endregion

            #region Fill Pokemon stats Rates
            Vector3 maxStatsRates = Vector3.zero; //x-Attack, y-Defense, z-Hp
            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo pInfo = pokeData.PokeInfos[i];
                if (pInfo.BaseAttack > maxStatsRates.x)
                {
                    maxStatsRates.x = pInfo.BaseAttack;
                }
                if (pInfo.BaseDefense > maxStatsRates.y)
                {
                    maxStatsRates.y = pInfo.BaseDefense;
                }
                if (pInfo.BaseStamina > maxStatsRates.z)
                {
                    maxStatsRates.z = pInfo.BaseStamina;
                }
            }

            for (int i = 0; i < pokeData.PokeInfos.Length; i++)
            {
                PokeInfo pInfo = pokeData.PokeInfos[i];
                pInfo.AttackRate  = (float)pInfo.BaseAttack / maxStatsRates.x;
                pInfo.DefenseRate = (float)pInfo.BaseDefense / maxStatsRates.y;
                pInfo.StaminaRate = (float)pInfo.BaseStamina / maxStatsRates.z;
            }
            #endregion

            #region Fill Move stats Rates
            Vector3 maxMoveRates = Vector3.zero; //x-Attack, y-Cooldown, z-DPS

            //Primary
            for (int i = 0; i < pokeData.PrimaryMoves.Length; i++)
            {
                PrimaryMove move = pokeData.PrimaryMoves[i];
                if (move.Attack > maxMoveRates.x)
                {
                    maxMoveRates.x = move.Attack;
                }
                if (move.Cooldown > maxMoveRates.y)
                {
                    maxMoveRates.y = move.Cooldown;
                }
                if (move.Dps > maxMoveRates.z)
                {
                    maxMoveRates.z = move.Dps;
                }
            }

            for (int i = 0; i < pokeData.PrimaryMoves.Length; i++)
            {
                PrimaryMove move = pokeData.PrimaryMoves[i];
                move.AttackRate   = (float)move.Attack / maxMoveRates.x;
                move.CooldownRate = (float)move.Cooldown / maxMoveRates.y;
                move.DpsRate      = (float)move.Dps / maxMoveRates.z;
            }

            //Secondary
            maxMoveRates = Vector3.zero;
            for (int i = 0; i < pokeData.SecondaryMoves.Length; i++)
            {
                SecondaryMove move = pokeData.SecondaryMoves[i];
                if (move.Attack > maxMoveRates.x)
                {
                    maxMoveRates.x = move.Attack;
                }
                if (move.Cooldown > maxMoveRates.y)
                {
                    maxMoveRates.y = move.Cooldown;
                }
                if (move.Dps > maxMoveRates.z)
                {
                    maxMoveRates.z = move.Dps;
                }
            }

            for (int i = 0; i < pokeData.SecondaryMoves.Length; i++)
            {
                SecondaryMove move = pokeData.SecondaryMoves[i];
                move.AttackRate   = (float)move.Attack / maxMoveRates.x;
                move.CooldownRate = (float)move.Cooldown / maxMoveRates.y;
                move.DpsRate      = (float)move.Dps / maxMoveRates.z;
            }
            #endregion

            EditorUtility.SetDirty(pokeData);
            Debug.Log("Loading Poke info complete!");
        }
        catch (Exception)
        {
            Debug.LogError("Error while loading data from json");
            throw;
        }
    }
Ejemplo n.º 3
0
    IEnumerator SetYield(PokeInfo pokeInfo)
    {
        _curPokeInfo = pokeInfo;

        foreach (var o in _curQuickMovesObj)
        {
            Destroy(o);
        }
        foreach (var o in _curChargeMovesObj)
        {
            Destroy(o);
        }

        float nextPanelPosY = 0;

        #region Set labels (0 PANEL)
        _idText.text = "#" + pokeInfo.Id;
        _baseImageLabel.Set(pokeInfo.Image, pokeInfo.Name);

        if (pokeInfo.EvoFromId > -1)
        {
            PokeInfo evoFrom = AppManager.Instance.PokeData.PokeInfos[pokeInfo.EvoFromId];
            _prevImageLabel.Set(evoFrom.Image, evoFrom.Name, evoFrom.CandyToEvolve);
            _prevImageLabel.EnableObj();
        }
        else
        {
            _prevImageLabel.DisableObj();
        }

        if (pokeInfo.EvoToId > -1)
        {
            PokeInfo evoTo = AppManager.Instance.PokeData.PokeInfos[pokeInfo.EvoToId];
            _nextImageLabel.Set(evoTo.Image, evoTo.Name, pokeInfo.CandyToEvolve);
            _nextImageLabel.EnableObj();
        }
        else
        {
            _nextImageLabel.DisableObj();
        }

        if (AppManager.Instance.UserData.FavoritePokemons.Contains(pokeInfo.Id))
        {
            _favoriteButton.Selected = true;
        }
        else
        {
            _favoriteButton.Selected = false;
        }

        nextPanelPosY -= _allPanels[0].sizeDelta.y + PanelSpace;
        #endregion

        #region Set info (1 PANEL)
        foreach (var pokeTypeLabel in _pokeTypeLabels)
        {
            pokeTypeLabel.DisableObj();
        }
        for (int i = 0; i < pokeInfo.Type.Length; i++)
        {
            _pokeTypeLabels[i].SetType(pokeInfo.Type[i]);
            _pokeTypeLabels[i].EnableObj();
        }

        if (pokeInfo.Class == PokeClass.Legendary)
        {
            _classText.text = pokeInfo.Class.ToString().ToUpper();
        }
        else
        {
            _classText.text = "";
        }

        _maxCpWHText.text =
            TextManager.GetText(TextType.Element, 0) +
            UIManager.NewLine(1) +
            UIManager.GetFormattedText(TextManager.GetNumericFormat((int)pokeInfo.MaxCp), TextColorType.GreenSmooth, true, 30) +
            UIManager.NewLine(1) +
            TextManager.GetText(TextType.Element, 2) + ": " + UIManager.GetFormattedText(pokeInfo.Weight.ToString(), TextColorType.BlackLight, true, 16) +
            " " + UIManager.GetFormattedText(TextManager.GetText(TextType.Element, 17), TextColorType.GreyLight, true, 12) +
            UIManager.NewLine(1) +
            TextManager.GetText(TextType.Element, 3) + ": " + UIManager.GetFormattedText(pokeInfo.Height.ToString(), TextColorType.BlackLight, true, 16) +
            " " + UIManager.GetFormattedText(TextManager.GetText(TextType.Element, 18), TextColorType.GreyLight, true, 12);

        _pokeStats.SetStats(pokeInfo.AttackRate, pokeInfo.DefenseRate, pokeInfo.StaminaRate);
        _statsText.text =
            pokeInfo.BaseAttack +
            UIManager.NewLine(1) +
            pokeInfo.BaseDefense +
            UIManager.NewLine(1) +
            pokeInfo.BaseStamina;

        if (pokeInfo.EggDistanceType != EggType.None)
        {
            _eggDistanceText.text  = ((int)pokeInfo.EggDistanceType) + TextManager.GetText(TextType.Element, 23);
            _eggDistanceText.color = UIManager.TextColorsList[TextColorType.GreenSmooth];
            _eggImage.sprite       = UIManager.Instance.UIRes.EggSprites[0];
        }
        else
        {
            _eggDistanceText.text  = TextManager.GetText(TextType.Element, 24);
            _eggDistanceText.color = UIManager.TextColorsList[TextColorType.GreyLight];
            _eggImage.sprite       = UIManager.Instance.UIRes.EggSprites[1];
        }

        nextPanelPosY -= _allPanels[1].sizeDelta.y + (PanelSpace * 2);
        #endregion

        #region Set Resistance & Weaknesses (4 PANEL)
        _typeChart.Set(TypeChartPanelType.Pokemon, _curPokeInfo.Resistance, _curPokeInfo.Weaknesses);

        yield return(new WaitForEndOfFrame());

        _allPanels[4].anchoredPosition = new Vector2(_allPanels[4].anchoredPosition.x, nextPanelPosY);
        nextPanelPosY -= _allPanels[4].sizeDelta.y + PanelSpace;
        #endregion

        #region Set moves (2 PANEL)
        int   movesCount      = Mathf.Max(pokeInfo.PrimaryMovesIds.Length, pokeInfo.SecondaryMovesIds.Length);
        float movePanelHeight = movesCount * (PokeMove.PanelHeight + (PanelSpace));

        _allPanels[2].sizeDelta        = new Vector2(_allPanels[2].sizeDelta.x, movePanelHeight + MoveStartHeightPos);
        _allPanels[2].anchoredPosition = new Vector2(_allPanels[2].anchoredPosition.x, nextPanelPosY);

        _curQuickMovesObj = new GameObject[pokeInfo.PrimaryMovesIds.Length];
        for (int i = 0; i < pokeInfo.PrimaryMovesIds.Length; i++)
        {
            _curQuickMovesObj[i] = Instantiate(QuickMoveTemplate);
            PokeMove move = _curQuickMovesObj[i].GetComponent <PokeMove>();

            move.RectTransform.SetParent(_allPanels[2]);
            move.RectTransform.anchoredPosition = new Vector2(0, -(MoveStartHeightPos + PokeMove.PanelHeight * i) - (PanelSpace * i));
            move.RectTransform.sizeDelta        = new Vector2(0, move.RectTransform.sizeDelta.y);
            move.RectTransform.localScale       = Vector3.one;

            move.Set(AppManager.Instance.PokeData.PrimaryMoves[pokeInfo.PrimaryMovesIds[i]]);
        }

        _curChargeMovesObj = new GameObject[pokeInfo.SecondaryMovesIds.Length];
        for (int i = 0; i < pokeInfo.SecondaryMovesIds.Length; i++)
        {
            _curChargeMovesObj[i] = Instantiate(ChargeMoveTemplate);
            PokeMove move = _curChargeMovesObj[i].GetComponent <PokeMove>();

            move.RectTransform.SetParent(_allPanels[2]);
            move.RectTransform.anchoredPosition = new Vector2(0, -(MoveStartHeightPos + PokeMove.PanelHeight * i) - (PanelSpace * i));
            move.RectTransform.sizeDelta        = new Vector2(0, move.RectTransform.sizeDelta.y);
            move.RectTransform.localScale       = Vector3.one;

            move.Set(AppManager.Instance.PokeData.SecondaryMoves[pokeInfo.SecondaryMovesIds[i]]);
        }

        nextPanelPosY -= _allPanels[2].sizeDelta.y + PanelSpace;
        #endregion

        #region Set Additional Info (3 PANEL)
        //Fill INFO
        string percentFormatted = UIManager.GetFormattedText(" %", TextColorType.GreyLight, false, 12);

        _addInfoText.text =
            TextManager.GetText(TextType.Element, 33) + ":" +
            UIManager.NewLine(1);

        if (_curPokeInfo.CpMultiFromEvo > 0)
        {
            _addInfoText.text +=
                TextManager.GetText(TextType.Element, 34) + ":" +
                UIManager.NewLine(1);
        }

        _addInfoText.text +=
            TextManager.GetText(TextType.Element, 35) + ":" +
            UIManager.NewLine(1) +
            TextManager.GetText(TextType.Element, 36) + ":" +
            UIManager.NewLine(1) +
            TextManager.GetText(TextType.Element, 37) + ":";

        //Fill INFO COUNT
        _addInfoCountText.text =
            _curPokeInfo.BaseHp +
            UIManager.NewLine(1);

        if (_curPokeInfo.CpMultiFromEvo > 0)
        {
            _addInfoCountText.text +=
                _curPokeInfo.CpMultiFromEvo + UIManager.GetFormattedText("x", TextColorType.GreyLight, false, 12) +
                UIManager.NewLine(1);
        }

        _addInfoCountText.text +=
            _curPokeInfo.CaptureRate + percentFormatted +
            UIManager.NewLine(1) +
            _curPokeInfo.FleeRate + percentFormatted +
            UIManager.NewLine(1) +
            _curPokeInfo.Rarity.ToString("F") + percentFormatted;

        yield return(new WaitForEndOfFrame());

        _allPanels[3].anchoredPosition = new Vector2(_allPanels[3].anchoredPosition.x, nextPanelPosY);
        _allPanels[3].sizeDelta        = new Vector2(_allPanels[3].sizeDelta.x, _addInfoText.GetComponent <RectTransform>().sizeDelta.y + (PanelSpace * 2));
        nextPanelPosY -= _allPanels[3].sizeDelta.y + PanelSpace;
        #endregion

        _content.sizeDelta = new Vector2(0, Mathf.Abs(nextPanelPosY) + UIManager.PanelBottomOffset);
    }
Ejemplo n.º 4
0
 public void Set(PokeInfo pokeInfo)
 {
     gameObject.SetActive(true);
     StartCoroutine(SetYield(pokeInfo));
 }
    private IEnumerator GetPokemonAtIndex(string pokemonIndex)
    {
        pokeNameTMP.text  = "Loading. . .";
        pokeIdTMP.text    = "#. . .";
        pokeTypesTMP.text = ". . .";

        searchFieldTMP.text = pokemonIndex;
        // Get Pokemon Info
        // Example URL: https://pokeapi.co/api/v2/pokemon/151

        string pokemonURL = basePokeURL + "pokemon/" + pokemonIndex;


        var www = new UnityWebRequest(pokemonURL)
        {
            // or use var www = UnityWebRequest.Get(pokemonURL); will work 2
            downloadHandler = new DownloadHandlerBuffer()
        };

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            pokeNameTMP.text    = "Error";
            searchFieldTMP.text = "";
            Debug.Log("Error has occur: " + www.error);
            yield break;
        }

        pokeInfo = JsonUtility.FromJson <PokeInfo>(www.downloadHandler.text);
        PokemonDetail(pokeInfo);

        pokeNameTMP.text = char.ToUpper(pokeInfo.name[0]) + pokeInfo.name.Substring(1);

        pokeIdTMP.text    = "#" + pokeInfo.id;
        pokeTypesTMP.text = "";
        foreach (var type in pokeInfo.types)
        {
            pokeTypesTMP.text += type.type.name + "\n";
        }

        UnityWebRequest pokeSpriteRequest1 = UnityWebRequestTexture.GetTexture(pokeInfo.sprites.front_default);

        var asyncOperation = pokeSpriteRequest1.SendWebRequest();

        if (!pokeSpriteRequest1.isNetworkError || !pokeSpriteRequest1.isHttpError)
        {
            while (!pokeSpriteRequest1.isDone)
            {
                Debug.Log(asyncOperation.progress);
                yield return(null);
            }
        }
        else
        {
            Debug.Log("Error has occur: " + pokeSpriteRequest1.error);
            yield break;
        }


        // If Sprite Image, use Sprite.Create(DownloadHandlerTexture.GetContent(pokeSpriteRequest1);
        pokemonImagePlaceholder1.texture            = DownloadHandlerTexture.GetContent(pokeSpriteRequest1);
        pokemonImagePlaceholder1.texture.filterMode = FilterMode.Point;
    }
    public void PokemonDetail(PokeInfo pokeInfo)
    {
        // Name
        Debug.Log($"Poke Name: {pokeInfo.name}");
        // Ability
        foreach (var ability in pokeInfo.abilities)
        {
            Debug.Log($"<color=#ED4C67>Ability Name: {ability.ability.name}, IsHidden: {ability.is_hidden}, Slot: {ability.slot}</color>\n{ability.ability.url}");
        }

        Debug.Log($"<color=#FFC312>Base Experience: {pokeInfo.base_experience}</color>");

        // Form
        foreach (var form in pokeInfo.forms)
        {
            Debug.Log($"<color=#006266>Form: {form.name}</color>\n{form.url}");
        }

        // Game Indice
        foreach (var gameIndice in pokeInfo.game_indices)
        {
            Debug.Log($"<color=#D980FA>Game index: {gameIndice.game_index}, Version Name: {gameIndice.version.name}</color>\n{gameIndice.version.url}");
        }

        // Height
        Debug.Log($"<color=#A3CB38>Height: {pokeInfo.height}</color>");

        // HeldI Item
        foreach (var heldItem in pokeInfo.held_items)
        {
            Debug.Log($"<color=#1B1464>Item name: {heldItem.item.name}</color>\n{heldItem.item.url}");
            foreach (var versionDetail in heldItem.version_details)
            {
                Debug.Log($"<color=#006266>Version Detail Rarity: {versionDetail.rarity}, Version Name: {versionDetail.version.name}</color>\n{versionDetail.version.url}");
            }
        }

        // ID
        Debug.Log($"Poke ID: #{pokeInfo.id}");

        // Is Default
        Debug.Log($"Is Default: {pokeInfo.is_default}");

        // Location Area Encounters
        Debug.Log($"Location Area Encounters: {pokeInfo.location_area_encounters}");

        // Move
        foreach (var move in pokeInfo.moves)
        {
            Debug.Log($"<color=blue>Move {move.move.name}</color>\n{move.move.url}");
            foreach (var versionGroupDetail in move.version_group_details)
            {
                Debug.Log($"Version Group Detail Level learned at: {versionGroupDetail.level_learned_at}");
                Debug.Log($"Move Learn Method Name: {versionGroupDetail.move_learn_method.name}\n{versionGroupDetail.move_learn_method.url}");
                Debug.Log($"Version Group: {versionGroupDetail.version_group.name}\n{versionGroupDetail.version_group.url}");
            }
        }

        // Order
        Debug.Log($"Order: {pokeInfo.order}");

        // Species
        Debug.Log($"Species: {pokeInfo.species.name}\n{pokeInfo.species.url}");

        // Sprites
        Debug.Log($"back_default: {pokeInfo.sprites.back_default}");
        Debug.Log($"back_female: {pokeInfo.sprites.back_female}");
        Debug.Log($"back_shiny: {pokeInfo.sprites.back_shiny}");
        Debug.Log($"back_shiny_female: {pokeInfo.sprites.back_shiny_female}");
        Debug.Log($"front_default: {pokeInfo.sprites.front_default}");
        Debug.Log($"front_shiny: {pokeInfo.sprites.front_shiny}");
        Debug.Log($"front_shiny_female: {pokeInfo.sprites.front_shiny_female}");

        // Stats
        foreach (var stat in pokeInfo.stats)
        {
            Debug.Log($"Stat: {stat.stat.name}, Base stat: {stat.base_stat}, Effort: {stat.effort}\n{stat.stat.url}");
        }

        //
        foreach (var type in pokeInfo.types)
        {
            Debug.Log($"Slot: {type.slot}, Type Name: {type.type.name}\n{type.type.url}");
        }
    }