Esempio n. 1
0
        public static string GetPrefix(
            PBS.Battle.View.WifiFriendly.Pokemon pokemon,
            PBS.Battle.View.Model myModel,
            int teamPerspectiveID = -1,
            int myPlayerID        = 0,
            bool capitalize       = true)
        {
            string text = "";

            PBS.Battle.View.WifiFriendly.Trainer trainer = myModel.GetTrainer(pokemon);
            if (pokemon.teamPos != teamPerspectiveID)
            {
                text = "The opposing ";
            }
            else
            {
                if (myPlayerID != 0)
                {
                    if (trainer.playerID != myPlayerID)
                    {
                        text = "The ally ";
                    }
                }
            }
            if (!capitalize)
            {
                text = text.ToLower();
                text = " " + text;
            }
            return(text);
        }
Esempio n. 2
0
        public Panels.FieldTargetButton GetFieldTargetButton(
            BattlePosition position,
            int teamPerspective,
            PBS.Battle.View.Model battleModel)
        {
            PBS.Battle.View.WifiFriendly.Team team = battleModel.GetMatchingTeam(position.teamPos);
            bool isAlly = (teamPerspective == position.teamPos);

            Panels.FieldTargetButton curBtn =

                // singles battle
                (team.teamMode == TeamMode.Single) ? (isAlly ? targetBtnNearSingle : targetBtnFarSingle)

                // doubles battle
                : (team.teamMode == TeamMode.Double) ?
                (isAlly ?
                 ((position.battlePos == 0) ? targetBtnNearDouble0 : targetBtnNearDouble1)
                        : ((position.battlePos == 0) ? targetBtnFarDouble0 : targetBtnFarDouble1))

                // triples battle
                : (team.teamMode == TeamMode.Triple) ?
                (isAlly ?
                 ((position.battlePos == 0) ? targetBtnNearTriple0
                            : (position.battlePos == 1) ? targetBtnNearTriple1 : targetBtnNearTriple2)
                        : ((position.battlePos == 0) ? targetBtnFarTriple0
                            : (position.battlePos == 1) ? targetBtnFarTriple1 : targetBtnFarTriple2))
                : null;
            return(curBtn);
        }
Esempio n. 3
0
        public void SetFieldTargets(
            int teamPos,
            PBS.Battle.View.Model battleModel)
        {
            activeTargetBtns = new List <Panels.FieldTargetButton>();
            HideAllButtons();
            CleanAllButtons();

            List <BattlePosition> allPositions = battleModel.GetAllBattlePositions();

            for (int i = 0; i < allPositions.Count; i++)
            {
                BattlePosition curPos = allPositions[i];
                PBS.Battle.View.WifiFriendly.Team team = battleModel.GetMatchingTeam(curPos.teamPos);
                bool isAlly = (teamPos == curPos.teamPos);

                Panels.FieldTargetButton curBtn = GetFieldTargetButton(
                    position: curPos,
                    teamPerspective: teamPos,
                    battleModel: battleModel);

                if (curBtn != null)
                {
                    CreateFieldTargetBtn(curPos, battleModel, curBtn);
                    activeTargetBtns.Add(curBtn);
                    curBtn.gameObject.SetActive(true);
                }
            }
        }
Esempio n. 4
0
        public static string RenderMessageTrainer(
            int playerID,
            PBS.Battle.View.Model myModel,
            int teamPerspectiveID = -1,
            string baseString     = "",
            int myPlayerID        = 0,
            PBS.Battle.View.WifiFriendly.Trainer myTrainer      = null,
            PBS.Battle.View.WifiFriendly.Team myTeamPerspective = null)
        {
            if (teamPerspectiveID == -1)
            {
                teamPerspectiveID = myTeamPerspective.teamID;
            }
            PBS.Battle.View.WifiFriendly.Trainer trainer = myModel.GetMatchingTrainer(playerID);
            GameTextData textData =
                (trainer.teamPos != teamPerspectiveID)? GameTextDatabase.instance.GetGameTextData("trainer-perspective-opposing")
                : (myTrainer == null)? GameTextDatabase.instance.GetGameTextData("trainer-perspective-ally")
                : GameTextDatabase.instance.GetGameTextData("trainer-perspective-player");

            string replaceString = textData.languageDict[GameSettings.language];

            if (replaceString == "{{-trainer-}}")
            {
                replaceString = trainer.name;
            }
            string replaceStringPoss = replaceString;

            if (!string.IsNullOrEmpty(baseString))
            {
                if (GameSettings.language == GameLanguages.English)
                {
                    if (myPlayerID == playerID)
                    {
                        replaceStringPoss = "Your";
                        if (!baseString.StartsWith("{{-trainer-"))
                        {
                            replaceString     = replaceString.ToLower();
                            replaceStringPoss = replaceStringPoss.ToLower();
                        }
                    }
                    else
                    {
                        replaceStringPoss += "'s";
                    }
                }
            }

            string newString = baseString;

            newString = newString.Replace("{{-trainer-}}", replaceString);
            newString = newString.Replace("{{-trainer-poss-}}", replaceStringPoss);

            return(newString);
        }
Esempio n. 5
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
                                       ));
                }
            }
        }
Esempio n. 6
0
        public void SwitchSelectedMoveTargetsTo(
            PBS.Battle.View.Model model,
            BattlePosition userPos,
            int chooseIndex,
            List <List <BattlePosition> > choices)
        {
            List <BattlePosition> choice = choices[chooseIndex];

            if (choice == null)
            {
                fieldTargetPanel.HighlightBackButton();
            }
            else
            {
                fieldTargetPanel.HighlightFieldTargets(userPos, choice);
            }
        }
Esempio n. 7
0
        public static string GetPrefix(
            PBS.Battle.View.Enums.ViewPerspective viewPerspective,
            PBS.Battle.View.Model myModel,
            int teamPerspectiveID = -1,
            int myPlayerID        = 0,
            bool lowercase        = false)
        {
            string prefix = (viewPerspective == PBS.Battle.View.Enums.ViewPerspective.Ally) ? "The ally "
                : (viewPerspective == PBS.Battle.View.Enums.ViewPerspective.Enemy) ?
                            (myModel.settings.isWildBattle? "The wild " : "The foe's ")
                : "";

            if (lowercase)
            {
                prefix = prefix.ToLower();
            }

            return(prefix);
        }
Esempio n. 8
0
 public static PBS.Battle.View.Enums.ViewPerspective GetPerspective(
     PBS.Battle.View.WifiFriendly.Pokemon pokemon,
     PBS.Battle.View.Model myModel,
     int teamPerspectiveID = -1,
     int myPlayerID        = 0)
 {
     PBS.Battle.View.WifiFriendly.Trainer trainer = myModel.GetTrainer(pokemon);
     PBS.Battle.View.WifiFriendly.Team    team    = myModel.GetTeamOfTrainer(trainer);
     if (team.teamID != teamPerspectiveID)
     {
         return(PBS.Battle.View.Enums.ViewPerspective.Enemy);
     }
     else
     {
         if (myPlayerID == 0)
         {
             return(PBS.Battle.View.Enums.ViewPerspective.Ally);
         }
         return(PBS.Battle.View.Enums.ViewPerspective.Player);
     }
 }
Esempio n. 9
0
        public static List <PBS.Battle.View.WifiFriendly.Pokemon> FilterPokemonByPerspective(
            List <PBS.Battle.View.WifiFriendly.Pokemon> pokemon,
            PBS.Battle.View.Enums.ViewPerspective viewPerspective,
            PBS.Battle.View.Model myModel,
            int teamPerspectiveID = -1,
            int myPlayerID        = 0
            )
        {
            List <PBS.Battle.View.WifiFriendly.Pokemon> filteredPokemon = new List <PBS.Battle.View.WifiFriendly.Pokemon>();

            for (int i = 0; i < pokemon.Count; i++)
            {
                PBS.Battle.View.Enums.ViewPerspective perspective = GetPerspective(
                    pokemon: pokemon[i],
                    myModel: myModel,
                    teamPerspectiveID: teamPerspectiveID,
                    myPlayerID: myPlayerID);
                if (perspective == viewPerspective)
                {
                    filteredPokemon.Add(pokemon[i]);
                }
            }
            return(filteredPokemon);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public static string GetTrainerNames(List <PBS.Battle.View.WifiFriendly.Trainer> trainers, PBS.Battle.View.Model myModel)
        {
            string text = "";

            for (int i = 0; i < trainers.Count; i++)
            {
                text += (i == 0)? trainers[i].name : " and " + trainers[i].name;
            }
            return(text);
        }
Esempio n. 12
0
        public static string GetPokemonNames(List <PBS.Battle.View.WifiFriendly.Pokemon> pokemonList, PBS.Battle.View.Model myModel, bool orConjunct = false)
        {
            string conjunct = (orConjunct) ? "or" : "and";

            string names = "";

            if (pokemonList.Count == 1)
            {
                return(pokemonList[0].nickname);
            }
            else if (pokemonList.Count == 2)
            {
                return(pokemonList[0].nickname + " " + conjunct + " " + pokemonList[1].nickname);
            }
            else
            {
                for (int i = 0; i < pokemonList.Count; i++)
                {
                    names += (i == pokemonList.Count - 1) ?
                             conjunct + " " + pokemonList[i].nickname :
                             pokemonList[i].nickname + ", ";
                }
            }
            return(names);
        }
Esempio n. 13
0
 // Message Rendering
 public static string GetPokemonName(PBS.Battle.View.WifiFriendly.Pokemon pokemon, PBS.Battle.View.Model myModel)
 {
     return(GetPokemonNames(new List <PBS.Battle.View.WifiFriendly.Pokemon> {
         pokemon
     }, myModel));
 }
Esempio n. 14
0
 // Field Targeting Panel
 public void SetFieldTargets(PBS.Battle.View.Model model, int teamPos)
 {
     fieldTargetPanel.SetFieldTargets(teamPos: teamPos, battleModel: model);
 }