public bool IsABaseID(string tryBaseID)
 {
     if (baseID == tryBaseID)
     {
         return(baseID != null);
     }
     if (baseID != null)
     {
         StatusPKData baseData = StatusPKDatabase.instance.GetStatusData(baseID);
         return(baseData.IsABaseID(tryBaseID));
     }
     return(false);
 }
Exemple #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
                                       ));
                }
            }
        }
    // Clone
    public StatusPKData Clone()
    {
        StatusPKData cloneData = new StatusPKData(
            ID: ID,
            baseID: baseID,
            conditionName: conditionName,
            shortName: shortName,
            inflictTextID: inflictTextID,
            alreadyTextID: alreadyTextID,
            healTextID: healTextID,
            failTextID: failTextID,

            defaultTurns: defaultTurns,

            statusTags: statusTags,
            conditionEffects: conditionEffects,

            combineBaseEffects: combineBaseEffects,
            effectsNew: effectsNew.ToArray()
            );

        return(cloneData);
    }
Exemple #4
0
        public void UpdatePokemonHUD(
            PBS.Battle.View.WifiFriendly.Pokemon pokemon,
            string nickname            = "",
            PokemonGender gender       = PokemonGender.Genderless,
            int level                  = 1,
            string nonVolatileStatusID = null,
            int currentHP              = 1,
            int maxHP                  = 1)
        {
            HUD.PokemonHUD pokemonHUD = GetPokemonHUD(pokemon);
            if (pokemonHUD != null)
            {
                pokemonHUD.nameTxt.text = nickname;
                if (gender != PokemonGender.Genderless)
                {
                    pokemonHUD.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>"
                        : " <color=#FF8080>♀</color>";
                }

                pokemonHUD.lvlTxt.text    = "<color=yellow>Lv</color>" + level;
                pokemonHUD.statusTxt.text = "";
                if (!string.IsNullOrEmpty(nonVolatileStatusID))
                {
                    StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(nonVolatileStatusID);
                    pokemonHUD.statusTxt.text = statusData.shortName;
                }

                pokemonHUD.hpTxt.text = currentHP + " / " + maxHP;

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

                pokemonHUD.hpBar.color = (hpPercent > 0.5f) ? pokemonHUD.hpHigh
                    : (hpPercent > 0.25f) ? pokemonHUD.hpMed
                    : pokemonHUD.hpLow;
            }
        }
Exemple #5
0
        public static string RenderMessage(
            PBS.Battle.View.Events.MessageParameterized message,
            PBS.Battle.View.Model myModel,
            int myPlayerID = 0,
            PBS.Battle.View.WifiFriendly.Trainer myTrainer      = null,
            PBS.Battle.View.WifiFriendly.Team myTeamPerspective = null)
        {
            GameTextData textData = GameTextDatabase.instance.GetGameTextData(message.messageCode);

            if (textData == null)
            {
                return("");
            }
            string baseString = textData.languageDict[GameSettings.language];
            string newString  = baseString;

            PBS.Battle.View.WifiFriendly.Trainer trainerPerspective =
                (myTrainer == null)? myModel.GetMatchingTrainer(message.playerPerspectiveID)
                : myTrainer;
            PBS.Battle.View.WifiFriendly.Team teamPerspective =
                (myTeamPerspective == null)? myModel.GetMatchingTeam(message.teamPerspectiveID)
                : myTeamPerspective;

            // player
            newString = newString.Replace("{{-player-name-}}", PlayerSave.instance.name);

            if (!string.IsNullOrEmpty(message.pokemonID))
            {
                PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonID);
                PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID);
                newString = newString.Replace("{{-pokemon-}}", pokemon.nickname);
                newString = newString.Replace("{{-pokemon-form-}}", pokemonData.formName);
                newString = newString.Replace("{{-pokemon-poss-}}", pokemon.nickname
                                              + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s")
                                              );
            }
            if (!string.IsNullOrEmpty(message.pokemonUserID))
            {
                PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonUserID);
                PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID);
                newString = newString.Replace("{{-user-pokemon-}}", pokemon.nickname);
                newString = newString.Replace("{{-user-pokemon-form-}}", pokemonData.formName);
                newString = newString.Replace("{{-user-pokemon-poss-}}", pokemon.nickname
                                              + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s")
                                              );
            }
            if (!string.IsNullOrEmpty(message.pokemonTargetID))
            {
                PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonTargetID);
                PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID);
                newString = newString.Replace("{{-target-pokemon-}}", pokemon.nickname);
                newString = newString.Replace("{{-target-pokemon-form-}}", pokemonData.formName);
                newString = newString.Replace("{{-target-pokemon-poss-}}", pokemon.nickname
                                              + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s")
                                              );
            }
            if (message.pokemonListIDs.Count > 0)
            {
                List <PBS.Battle.View.WifiFriendly.Pokemon> pokemonList = new List <Battle.View.WifiFriendly.Pokemon>();
                for (int i = 0; i < message.pokemonListIDs.Count; i++)
                {
                    pokemonList.Add(myModel.GetMatchingPokemon(message.pokemonListIDs[i]));
                }
                string pokemonNameList = GetPokemonNames(pokemonList, myModel);
                newString = newString.Replace("{{-pokemon-list-}}", pokemonNameList);
            }

            if (message.trainerID != 0)
            {
                newString = RenderMessageTrainer(
                    message.trainerID,
                    myModel,
                    teamPerspective.teamID,
                    newString,

                    myPlayerID: myPlayerID,
                    myTrainer: myTrainer,
                    myTeamPerspective: myTeamPerspective);
            }

            if (message.teamID != 0)
            {
                newString = RenderMessageTeam(
                    teamID: message.teamID,
                    teamPerspectiveID: teamPerspective.teamID,
                    baseString: newString,

                    myPlayerID: myPlayerID,
                    myTrainer: myTrainer,
                    myTeamPerspective: myTeamPerspective);
            }

            if (!string.IsNullOrEmpty(message.typeID))
            {
                TypeData typeData = TypeDatabase.instance.GetTypeData(message.typeID);
                newString = newString.Replace("{{-type-name-}}", typeData.typeName + "-type");
            }
            if (message.typeIDs.Count > 0)
            {
                newString = newString.Replace("{{-type-list-}}", GameTextDatabase.ConvertTypesToString(message.typeIDs.ToArray()));
            }

            if (!string.IsNullOrEmpty(message.moveID))
            {
                MoveData moveData = MoveDatabase.instance.GetMoveData(message.moveID);
                newString = newString.Replace("{{-move-name-}}", moveData.moveName);
            }
            if (message.moveIDs.Count > 0)
            {
                for (int i = 0; i < message.moveIDs.Count; i++)
                {
                    MoveData moveXData     = MoveDatabase.instance.GetMoveData(message.moveIDs[i]);
                    string   partToReplace = "{{-move-name-" + i + "-}}";
                    newString = newString.Replace(partToReplace, moveXData.moveName);
                }
            }

            if (!string.IsNullOrEmpty(message.abilityID))
            {
                AbilityData abilityData = AbilityDatabase.instance.GetAbilityData(message.abilityID);
                newString = newString.Replace("{{-ability-name-}}", abilityData.abilityName);
            }
            if (message.abilityIDs.Count > 0)
            {
                for (int i = 0; i < message.abilityIDs.Count; i++)
                {
                    AbilityData abilityXData  = AbilityDatabase.instance.GetAbilityData(message.abilityIDs[i]);
                    string      partToReplace = "{{-ability-name-" + i + "-}}";
                    newString = newString.Replace(partToReplace, abilityXData.abilityName);
                }
            }

            if (!string.IsNullOrEmpty(message.itemID))
            {
                ItemData itemData = ItemDatabase.instance.GetItemData(message.itemID);
                newString = newString.Replace("{{-item-name-}}", itemData.itemName);
            }

            if (!string.IsNullOrEmpty(message.statusID))
            {
                StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(message.statusID);
                newString = newString.Replace("{{-status-name-}}", statusData.conditionName);
            }
            if (!string.IsNullOrEmpty(message.statusTeamID))
            {
                StatusTEData statusData = StatusTEDatabase.instance.GetStatusData(message.statusTeamID);
                newString = newString.Replace("{{-team-status-name-}}", statusData.conditionName);
            }
            if (!string.IsNullOrEmpty(message.statusEnvironmentID))
            {
                StatusBTLData statusData = StatusBTLDatabase.instance.GetStatusData(message.statusEnvironmentID);
                newString = newString.Replace("{{-battle-status-name-}}", statusData.conditionName);
            }

            // swapping substrings
            for (int i = 0; i < message.intArgs.Count; i++)
            {
                string partToReplace = "{{-int-" + i + "-}}";
                newString = newString.Replace(partToReplace, message.intArgs[i].ToString());
            }

            if (message.statList.Count > 0)
            {
                newString = newString.Replace("{{-stat-types-}}", ConvertStatsToString(message.statList.ToArray()));
                if (GameSettings.language == GameLanguages.English)
                {
                    newString = newString.Replace("{{-stat-types-was-}}", (message.statList.Count == 1)? "was" : "were");
                }
                else
                {
                    newString = newString.Replace("{{-stat-types-was-}}", "");
                }
                newString = newString.Replace("{{-stat-types-LC-}}", ConvertStatsToString(message.statList.ToArray(), false));
            }

            return(newString);
        }