コード例 #1
0
        public void CleanAllButtons()
        {
            List <Panels.FieldTargetButton> allBtns = GetAllFieldTargetButtons();

            for (int i = 0; i < allBtns.Count; i++)
            {
                Panels.FieldTargetButton curBtn = allBtns[i];
                curBtn.RefreshSelf();
                curBtn.position = null;
            }
        }
コード例 #2
0
        public void CreateFieldTargetBtn(
            BattlePosition position,
            PBS.Battle.View.Model battleModel,
            Panels.FieldTargetButton btn)
        {
            btn.position = position;
            PBS.Battle.View.WifiFriendly.Pokemon pokemon = battleModel.GetPokemonAtPosition(position);

            btn.RefreshSelf(active: pokemon != null);
            if (pokemon != null)
            {
                btn.nameTxt.text = pokemon.nickname;
                PokemonGender gender = pokemon.gender;
                if (gender != PokemonGender.Genderless)
                {
                    btn.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>"
                        : " <color=#FF8080>♀</color>";
                }
                btn.lvlTxt.text = "<color=yellow>Lv</color>" + pokemon.level;

                btn.statusTxt.text = "";
                if (!string.IsNullOrEmpty(pokemon.nonVolatileStatus))
                {
                    StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(pokemon.nonVolatileStatus);
                    btn.statusTxt.text = statusData.shortName;
                }

                float hpPercent = ((float)pokemon.currentHP) / pokemon.maxHP;
                btn.hpBar.fillAmount = hpPercent;

                btn.hpBar.color = (hpPercent > 0.5f) ? btn.hpHigh
                    : (hpPercent > 0.25f) ? btn.hpMed
                    : btn.hpLow;

                // draw icon
                string drawPath = "pokemonSprites/icon/" + PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID).displayID;
                btn.icon.sprite = BattleAssetLoader.instance.nullPokemonIconSprite;
                if (BattleAssetLoader.instance.loadedPokemonSprites.ContainsKey(drawPath))
                {
                    btn.icon.sprite = BattleAssetLoader.instance.loadedPokemonSprites[drawPath];
                }
                else
                {
                    StartCoroutine(BattleAssetLoader.instance.LoadPokemon(
                                       pokemon: pokemon,
                                       useicon: true,
                                       imagePokemon: btn.icon
                                       ));
                }
            }
        }