コード例 #1
0
 private void updateFrames()
 {
     for (int i = 0; i < 6; i++)
     {
         OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][i];
         if (selectedPokemon != null)
         {
             if (i == swapPosition)
             {
                 if (i == 0)
                 {
                     if (i == currentPosition)
                     {
                         slot[i].texture = panelRoundSwapSel;
                     }
                     else
                     {
                         slot[i].texture = panelRoundSwap;
                     }
                 }
                 else
                 {
                     if (i == currentPosition)
                     {
                         slot[i].texture = panelRectSwapSel;
                     }
                     else
                     {
                         slot[i].texture = panelRectSwap;
                     }
                 }
             }
             else
             {
                 if (selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) == 0)
                 {
                     if (i == 0)
                     {
                         if (i == currentPosition)
                         {
                             if (switching)
                             {
                                 slot[i].texture = panelRoundSwapSel;
                             }
                             else
                             {
                                 slot[i].texture = panelRoundFaintSel;
                             }
                         }
                         else
                         {
                             slot[i].texture = panelRoundFaint;
                         }
                     }
                     else
                     {
                         if (i == currentPosition)
                         {
                             if (switching)
                             {
                                 slot[i].texture = panelRectSwapSel;
                             }
                             else
                             {
                                 slot[i].texture = panelRectFaintSel;
                             }
                         }
                         else
                         {
                             slot[i].texture = panelRectFaint;
                         }
                     }
                 }
                 else
                 {
                     if (i == 0)
                     {
                         if (i == currentPosition)
                         {
                             if (switching)
                             {
                                 slot[i].texture = panelRoundSwapSel;
                             }
                             else
                             {
                                 slot[i].texture = panelRoundSel;
                             }
                         }
                         else
                         {
                             slot[i].texture = panelRound;
                         }
                     }
                     else
                     {
                         if (i == currentPosition)
                         {
                             if (switching)
                             {
                                 slot[i].texture = panelRectSwapSel;
                             }
                             else
                             {
                                 slot[i].texture = panelRectSel;
                             }
                         }
                         else
                         {
                             slot[i].texture = panelRect;
                         }
                     }
                 }
             }
             if (i == currentPosition)
             {
                 selectBall[i].texture = selectBallOpen;
             }
             else
             {
                 selectBall[i].texture = selectBallClosed;
             }
         }
     }
     if (currentPosition == 6)
     {
         cancel.texture = cancelHighlightTex;
     }
     else
     {
         cancel.texture = cancelTex;
     }
 }
コード例 #2
0
    private void updateParty()
    {
        for (int i = 0; i < 6; i++)
        {
            OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][i];
            if (selectedPokemon == null)
            {
                slot[i].gameObject.SetActive(false);
            }
            else
            {
                slot[i].gameObject.SetActive(true);
                selectBall[i].texture     = selectBallClosed;
                icon[i].texture           = selectedPokemon.GetIcons();
                pokemonName[i].text       = selectedPokemon.GetName();
                pokemonNameShadow[i].text = pokemonName[i].text;
                if (selectedPokemon.Gender == PokemonGender.FEMALE)
                {
                    gender[i].text  = "♀";
                    gender[i].color = new Color(1, 0.2f, 0.2f, 1);
                }
                else if (selectedPokemon.Gender == PokemonGender.MALE)
                {
                    gender[i].text  = "♂";
                    gender[i].color = new Color(0.2f, 0.4f, 1, 1);
                }
                else
                {
                    gender[i].text = null;
                }
                genderShadow[i].text = gender[i].text;
                HPBar[i].pixelInset  = new Rect(HPBar[i].pixelInset.x, HPBar[i].pixelInset.y,
                                                Mathf.FloorToInt(48f * ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) / (float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP))),
                                                HPBar[i].pixelInset.height);

                if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 4f))
                {
                    HPBar[i].color = new Color(1, 0.125f, 0, 1);
                }
                else if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 2f))
                {
                    HPBar[i].color = new Color(1, 0.75f, 0, 1);
                }
                else
                {
                    HPBar[i].color = new Color(0.125f, 1, 0.065f, 1);
                }

                level[i].text           = "" + selectedPokemon.CurrentLevel;
                levelShadow[i].text     = level[i].text;
                currentHP[i].text       = "" + selectedPokemon.GetCurrentStatValue(PokemonStatType.HP);
                currentHPShadow[i].text = currentHP[i].text;
                maxHp[i].text           = "" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP);
                maxHPShadow[i].text     = maxHp[i].text;
                if (selectedPokemon.CurrentStatus != PokemonStatus.NONE)
                {
                    status[i].texture =
                        Resources.Load <Texture>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString());
                }
                else
                {
                    status[i].texture = null;
                }
                if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
                {
                    item[i].enabled = true;
                }
                else
                {
                    item[i].enabled = false;
                }
            }
        }
    }
コード例 #3
0
    private void updateSelection(OwnedPokemon selectedPokemon)
    {
        frame = 0;

        PlayCry(selectedPokemon);

        selectedCaughtBall.sprite = Resources.Load <Sprite>("null");
        selectedCaughtBall.sprite = Resources.Load <Sprite>("PCSprites/summary" + selectedPokemon.MetData.CaughtBall);
        selectedName.text         = selectedPokemon.GetName();
        selectedNameShadow.text   = selectedName.text;
        if (selectedPokemon.Gender == PokemonGender.FEMALE)
        {
            selectedGender.text  = "♀";
            selectedGender.color = new Color(1, 0.2f, 0.2f, 1);
        }
        else if (selectedPokemon.Gender == PokemonGender.MALE)
        {
            selectedGender.text  = "♂";
            selectedGender.color = new Color(0.2f, 0.4f, 1, 1);
        }
        else
        {
            selectedGender.text = null;
        }
        selectedGenderShadow.text = selectedGender.text;
        selectedLevel.text        = "" + selectedPokemon.CurrentLevel;
        selectedLevelShadow.text  = selectedLevel.text;
        selectedSpriteAnimation   = selectedPokemon.GetFrontAnim_();
        if (selectedSpriteAnimation.Length > 0)
        {
            selectedSprite.sprite = selectedSpriteAnimation[0];
        }
        if (string.IsNullOrEmpty(selectedPokemon.getHeldItem()))
        {
            selectedHeldItem.text = "None";
        }
        else
        {
            selectedHeldItem.text = selectedPokemon.getHeldItem();
        }
        selectedHeldItemShadow.text = selectedHeldItem.text;
        if (selectedPokemon.CurrentStatus != PokemonStatus.NONE)
        {
            selectedStatus.sprite = Resources.Load <Sprite>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString());
        }
        else
        {
            selectedStatus.sprite = Resources.Load <Sprite>("null");
        }

        if (selectedPokemon.IsShiny)
        {
            selectedShiny.sprite = Resources.Load <Sprite>("PCSprites/shiny");
        }
        else
        {
            selectedShiny.sprite = Resources.Load <Sprite>("null");
        }

        dexNo.text         = selectedPokemon.Species.GameId;
        dexNoShadow.text   = dexNo.text;
        species.text       = selectedPokemon.Species.Name;
        speciesShadow.text = species.text;

        // ToDo: implement types.
        //string type1string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType1().ToString();
        //string type2string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType2().ToString();
        //type1.sprite = Resources.Load<Sprite>("null");
        //type2.sprite = Resources.Load<Sprite>("null");
        //if (type1string != "NONE")
        //{
        //    type1.sprite = Resources.Load<Sprite>("PCSprites/type" + type1string);
        //    type1.rectTransform.localPosition = new Vector3(71, type1.rectTransform.localPosition.y);
        //}
        //if (type2string != "NONE")
        //{
        //    type2.sprite = Resources.Load<Sprite>("PCSprites/type" + type2string);
        //}
        //else
        //{
        //    //if single type pokemon, center the type icon
        //    type1.rectTransform.localPosition = new Vector3(89, type1.rectTransform.localPosition.y);
        //}

        // ToDo: implement owner.
        //OT.text = selectedPokemon.getOT();
        //OTShadow.text = OT.text;
        //IDNo.text = "" + selectedPokemon.getIDno();
        //IDNoShadow.text = IDNo.text;

        expPoints.text       = "" + selectedPokemon.CurrentExperience;
        expPointsShadow.text = expPoints.text;
        float expCurrentLevel =
            PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate,
                                                                         selectedPokemon.CurrentLevel);
        float expNextlevel =
            PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate,
                                                                         selectedPokemon.CurrentLevel + 1);
        float expAlong    = selectedPokemon.CurrentExperience - expCurrentLevel;
        float expDistance = expAlong / (expNextlevel - expCurrentLevel);

        toNextLevel.text               = "" + (expNextlevel - selectedPokemon.CurrentExperience);
        toNextLevelShadow.text         = toNextLevel.text;
        expBar.rectTransform.sizeDelta = new Vector2(Mathf.Floor(expDistance * 64f), expBar.rectTransform.sizeDelta.y);

        string natureFormatted = PokemonNatureHelper.GetNatureName(selectedPokemon.Nature);

        natureFormatted     = natureFormatted.Substring(0, 1) + natureFormatted.Substring(1).ToLowerInvariant();
        nature.text         = "<color=#F22F>" + natureFormatted + "</color> nature.";
        natureShadow.text   = natureFormatted + " nature.";
        metDate.text        = "Met on " + selectedPokemon.MetData.Date;
        metDateShadow.text  = metDate.text;
        metMap.text         = "<color=#F22F>" + selectedPokemon.MetData.Location + "</color>";
        metMapShadow.text   = selectedPokemon.MetData.Location;
        metLevel.text       = "Met at Level " + selectedPokemon.MetData.Level + ".";
        metLevelShadow.text = metLevel.text;

        string[][] characteristics = new string[][]
        {
            new string[]
            {
                "Loves to eat", "Takes plenty of siestas", "Nods off a lot", "Scatters things often", "Likes to relax"
            },
            new string[]
            {
                "Proud of its power", "Likes to thrash about", "A little quick tempered", "Likes to fight",
                "Quick tempered"
            },
            new string[]
            {
                "Sturdy body", "Capable of taking hits", "Highly persistent", "Good endurance", "Good perseverance"
            },
            new string[]
            {
                "Highly curious", "Mischievous", "Thoroughly cunning", "Often lost in thought", "Very finicky"
            },
            new string[]
            {
                "Strong willed", "Somewhat vain", "Strongly defiant", "Hates to lose", "Somewhat stubborn"
            },
            new string[]
            {
                "Likes to run", "Alert to sounds", "Impetuous and silly", "Somewhat of a clown", "Quick to flee"
            }
        };

        var highestIV = selectedPokemon.GetHighestIV();

        characteristic.text       = characteristics[(int)highestIV][selectedPokemon.GetIV(highestIV) % 5] + ".";
        characteristicShadow.text = characteristic.text;

        float currentHP = selectedPokemon.GetCurrentStatValue(PokemonStatType.HP);
        float maxHP     = selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP);

        HP.text       = currentHP + "/" + maxHP;
        HPShadow.text = HP.text;
        HPBar.rectTransform.sizeDelta = new Vector2(selectedPokemon.getPercentHP() * 48f,
                                                    HPBar.rectTransform.sizeDelta.y);

        if (currentHP < (maxHP / 4f))
        {
            HPBar.color = new Color(1, 0.125f, 0, 1);
        }
        else if (currentHP < (maxHP / 2f))
        {
            HPBar.color = new Color(1, 0.75f, 0, 1);
        }
        else
        {
            HPBar.color = new Color(0.125f, 1, 0.065f, 1);
        }

        //float[] natureMod = new float[]
        //{
        //    NatureDatabase.getNature(selectedPokemon.Nature).getATK(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getDEF(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPA(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPD(),
        //    NatureDatabase.getNature(selectedPokemon.Nature).getSPE()
        //};
        Stats.text =
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Attack) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Defence) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialAttack) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialDefence) + "\n" +
            selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Speed);
        StatsShadow.text = Stats.text;

        //string[] statsLines = new string[] { "Attack", "Defence", "Sp. Atk", "Sp. Def", "Speed" };
        StatsTextShadow.text = "";
        //for (int i = 0; i < 5; i++)
        //{
        //    if (natureMod[i] > 1)
        //    {
        //        StatsTextShadow.text += "<color=#A01010FF>" + statsLines[i] + "</color>\n";
        //    }
        //    else if (natureMod[i] < 1)
        //    {
        //        StatsTextShadow.text += "<color=#0030A2FF>" + statsLines[i] + "</color>\n";
        //    }
        //    else
        //    {
        //        StatsTextShadow.text += statsLines[i] + "\n";
        //    }
        //}


        //abilityName.text = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID().ToString()).getAbility(selectedPokemon.getAbility());
        abilityNameShadow.text = abilityName.text;
        //abilities not yet implemented
        abilityDescription.text       = "";
        abilityDescriptionShadow.text = abilityDescription.text;

        updateSelectionMoveset(selectedPokemon);
    }