예제 #1
0
    private void CreateStepLine()
    {
        int textID = GameTextDatabase.INVALID_TEXT_ID;
        GameTextDatabase gameTextDatabase   = null;
        bool             autoClose          = false;
        Vector2          stepLineDimensions = Vector2.zero;

        gameTextDatabase = GameTextDatabase.Instance;
        if ((gameTextDatabase != null) && (symbolDatabase != null) && (stepLineObject == null))
        {
            if (invest)
            {
                textID = GameTextDatabase.TEXT_ID_TRANSACTION_INVEST_UNIT;
            }
            else
            {
                textID = GameTextDatabase.TEXT_ID_TRANSACTION_DRAW_UNIT;
            }
            stepLine       = gameTextDatabase.GetSystemText(textID, ref autoClose);
            stepLine       = stepLine + "  " + currentValueStep;
            stepLineObject = new GameObject("StepLineObject");
            stepLineObject.transform.SetParent(transform, false);
            stepLineObject.transform.localPosition = Vector3.zero;
            stepLineComponent = stepLineObject.AddComponent <SpritedString>();
            stepLineComponent.SetSymbolSource(symbolDatabase);
            stepLineComponent.SetValue(stepLine);
            stepLineDimensions  = stepLineComponent.GetWorldDimensions();
            stepLineArea.width  = stepLineDimensions.x;
            stepLineArea.height = stepLineDimensions.y;
        }
    }
예제 #2
0
    // Controller

    // Dialog
    public string GetGameText(BTLEvent_GameText bEvent)
    {
        if (bEvent.textID != null)
        {
            GameTextData gameTextData = GameTextDatabase.instance.GetGameTextData(bEvent.textID);
            string       baseText     = gameTextData.GetText();
            string       gameText     = GameTextDatabase.ConvertToString(
                baseString: baseText,
                viewPos: teamPos,
                playerID: playerID,
                pokemon: bEvent.pokemon,
                userPokemon: bEvent.userPokemon,
                targetPokemon: bEvent.targetPokemon,
                pokemonList: bEvent.pokemonList,
                trainer: bEvent.trainer,
                targetTeam: bEvent.targetTeam,
                statList: bEvent.statList,
                typeID: bEvent.typeID,
                moveID: bEvent.moveID,
                abilityID: bEvent.abilityID,
                itemID: bEvent.itemID,
                statusID: bEvent.statusID,
                teamStatusID: bEvent.teamStatusID,
                battleStatusID: bEvent.battleStatusID,
                moveIDs: bEvent.moveIDs,
                typeIDs: bEvent.typeIDs,
                battleModel: bEvent.battleModel,

                intArgs: bEvent.intArgs
                );
            return(gameText);
        }
        return(null);
    }
예제 #3
0
 protected override void Awake()
 {
     base.Awake();
     askingToSave      = false;
     askingToOverwrite = false;
     gameTextDatabase  = GameTextDatabase.Instance;
     textBoxManager    = TextBoxManager.Instance;
     delayingQuestion  = false;
     delayDuration     = QUESTION_DELAY;
     delayElapsed      = 0f;
 }
예제 #4
0
 protected override void Awake()
 {
     base.Awake();
     dialogueIndex = -1;
     dialogueID    = GameTextDatabase.INVALID_TEXT_ID;
             #if !UNITY_ANDROID || UNITY_EDITOR
     dialoguePlatform = GameTextDatabase.TextPlatform.PC;
             #else
     dialoguePlatform = GameTextDatabase.TextPlatform.Android;
             #endif
     dialogueCreated  = false;
     dialogueCleared  = false;
     gameTextDatabase = null;
     textBoxManager   = null;
 }
예제 #5
0
    public void ShowDialogue(int dialogueID)
    {
        string           text             = null;
        string           speakerName      = null;
        bool             tryAbove         = false;
        bool             autoClose        = false;
        GameTextDatabase gameTextDatabase = null;
        TextBoxManager   textBoxManager   = null;

        gameTextDatabase = GameTextDatabase.Instance;
        textBoxManager   = TextBoxManager.Instance;
        if ((gameTextDatabase != null) && (textBoxManager != null))
        {
            text = gameTextDatabase.GetDialogueText(dialogueID, ref speakerName, ref tryAbove, ref autoClose);
            textBoxManager.ShowDialogue(speakerName, text, tryAbove, autoClose);
        }
    }
예제 #6
0
 protected override void AbandonInterests()
 {
     base.AbandonInterests();
     gameTextDatabase = null;
     textBoxManager   = null;
 }
예제 #7
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);
        }
예제 #8
0
    public bool DisplayItemInfo(ItemDisplayContext displayContext, ItemData itemData)
    {
        int itemID = ItemData.INVALID_ITEM_ID;
        GameTextDatabase  textDatabase      = null;
        TextBoxUIManager  textBoxUIManager  = null;
        bool              boxCreated        = false;
        bool              displaySuccessful = false;
        ItemDisplayScheme displayScheme     = null;

        ItemDisplayScheme.DisplayProperty[] schemeProperties = null;

        if ((itemData != null) && (itemDisplaySchemes != null) && (itemDisplayContexts != null))
        {
            itemID = itemData.itemID;
            if (itemID != ItemData.INVALID_ITEM_ID)
            {
                textDatabase     = GameTextDatabase.Instance;
                textBoxUIManager = TextBoxUIManager.Instance;
                for (int i = 0; i < itemDisplayContexts.Length; i++)
                {
                    if (itemDisplayContexts[i] == displayContext)
                    {
                        if (itemDisplaySchemes.Length > i)
                        {
                            displayScheme = itemDisplaySchemes[i];
                        }
                    }
                }
                if ((displayScheme != null) && (textDatabase != null) && (textBoxUIManager != null))
                {
                    schemeProperties = displayScheme.properties;
                    if (displayScheme.ConfiguredProperly() && (schemeProperties != null))
                    {
                        string  itemName         = null;
                        string  itemDescription  = null;
                        string  boxText          = null;
                        Sprite  boxPicture       = null;
                        Vector2 boxPositionRates = Vector2.zero;
                        Vector2 boxMaxSizeRates  = Vector2.zero;
                        bool    toDiscard        = false;
                        for (int i = 0; i < schemeProperties.Length; i++)
                        {
                            boxText    = null;
                            boxPicture = null;
                            switch (schemeProperties[i])
                            {
                            case ItemDisplayScheme.DisplayProperty.Name:
                                if (itemName == null)
                                {
                                    itemDescription = textDatabase.GetItemDescription(itemID, ref itemName);
                                }
                                boxText = itemName;
                                break;

                            case ItemDisplayScheme.DisplayProperty.Description:
                                if (itemDescription == null)
                                {
                                    itemDescription = textDatabase.GetItemDescription(itemID, ref itemName);
                                }
                                boxText = itemDescription;
                                break;

                            case ItemDisplayScheme.DisplayProperty.Icon:
                                boxPicture = itemData.itemIcon;
                                break;

                            case ItemDisplayScheme.DisplayProperty.Tutorial:
                                boxText = textDatabase.GetPlatformText(textIDInventoryTutorial, currentPlatform, ref toDiscard);
                                break;
                            }
                            boxPositionRates = displayScheme.positionRates[i];
                            boxMaxSizeRates  = displayScheme.maxSizeRates[i];
                            boxCreated       = textBoxUIManager.ShowDialogue(boxText, 0f, boxPicture, false, boxMaxSizeRates, boxPositionRates, null,
                                                                             itemData);
                            if (!displaySuccessful)
                            {
                                displaySuccessful = boxCreated;
                            }
                        }
                    }
                }
            }
        }
        return(displaySuccessful);
    }
예제 #9
0
    protected virtual bool UpdateStatsDisplay()
    {
        GameTextDatabase textDatabase      = null;
        string           textValue         = null;
        float            statValueOriginal = 0f;
        float            statValueBase     = 0f;
        float            statEquippedSum   = 0f;
        bool             toDiscard         = false;
        Vector2          textDimensions    = Vector2.zero;
        Vector2          textScales        = Vector2.zero;
        Vector2          textPositionRates = Vector2.zero;
        TextAlignment    textAnchor        = TextAlignment.Center;
        bool             skipUpdate        = false;

        textDatabase = GameTextDatabase.Instance;
        if (statsDisplayValid && (interfaceCanvasTrans != null) && (player != null) && (textDatabase != null))
        {
            if (levelObject != null)
            {
                textValue         = textDatabase.GetSystemText(GameTextDatabase.TEXT_ID_PLAYER_LEVEL, ref toDiscard);
                textValue        += " " + player.GetCurrentLevel();
                textScales        = statsDisplay.levelScales;
                textPositionRates = statsDisplay.levelPositionRates;
                textAnchor        = statsDisplay.levelAnchorAlignment;
                UpdateTextDisplayObject(textValue, textScales, textPositionRates, textAnchor, levelTransform, levelText);
            }
            if (statObjects != null)
            {
                textAnchor = statsDisplay.attributeAnchorAlignment;
                textScales = statsDisplay.attributeScales;
                RectTransform[]   oneStatTransforms = null;
                SpritedStringUI[] oneStatTexts      = null;
                int[]             oneStatValues     = null;
                int  percentageBase         = 0;
                int  percentageBaseLimited  = 0;
                int  percentageEquip        = 0;
                int  percentageEquipLimited = 0;
                int  percentageTotal        = 0;
                int  percentageTotalLimited = 0;
                bool percentageBaseReady    = false;
                bool percentageEquipReady   = false;
                int  statValue = -1;
                for (int i = 0; i < stats.Length; i++)
                {
                    oneStatTransforms = statTransforms[i];
                    oneStatTexts      = statTexts[i];
                    oneStatValues     = statValues[i];
                    player.GetStatValueSegments(stats[i], ref statValueOriginal, ref statValueBase, ref statEquippedSum);
                    percentageBaseReady  = false;
                    percentageEquipReady = false;
                    for (int j = 0; j < aspects.Length; j++)
                    {
                        skipUpdate = false;
                        switch (aspects[j])
                        {
                        case AttributeAspect.Name:
                            skipUpdate = true;
                            break;

                        case AttributeAspect.Base:
                            if (!percentageBaseReady)
                            {
                                percentageBase        = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal);
                                statValue             = percentageBase;
                                percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase;
                                percentageBaseReady   = true;
                            }
                            textValue         = percentageBaseLimited.ToString();
                            textPositionRates = statsDisplay.attributeBasePosRates[i];
                            break;

                        case AttributeAspect.Equip:
                            if (!percentageEquipReady)
                            {
                                percentageEquip        = UsefulFunctions.GetPercentage(statEquippedSum);
                                statValue              = percentageEquip;
                                percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip;
                                percentageEquipReady   = true;
                            }
                            textValue         = percentageEquipLimited.ToString();
                            textPositionRates = statsDisplay.attributeEquipPosRates[i];
                            break;

                        case AttributeAspect.Total:
                            if (!percentageBaseReady)
                            {
                                percentageBase        = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal);
                                percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase;
                                percentageBaseReady   = true;
                            }
                            if (!percentageEquipReady)
                            {
                                percentageEquip        = UsefulFunctions.GetPercentage(statEquippedSum);
                                percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip;
                                percentageEquipReady   = true;
                            }
                            percentageTotal        = percentageBase + percentageEquip;
                            statValue              = percentageTotal;
                            percentageTotalLimited = (percentageTotal > percentageLimit) ? percentageLimit : percentageTotal;
                            textValue              = percentageTotalLimited.ToString();
                            textPositionRates      = statsDisplay.attributeTotalPosRates[i];
                            break;
                        }
                        if (!skipUpdate)
                        {
                            UpdateTextDisplayObject(textValue, textScales, textPositionRates, textAnchor, oneStatTransforms[j],
                                                    oneStatTexts[j]);
                            oneStatValues[j] = statValue;
                        }
                    }
                }
            }
            return(true);
        }
        return(false);
    }
예제 #10
0
    protected virtual bool CreateStatsDisplay()
    {
        GameTextDatabase textDatabase     = null;
        int             totalStats        = 0;
        string          statName          = null;
        string          textName          = null;
        string          textValue         = null;
        float           statValueOriginal = 0f;
        float           statValueBase     = 0f;
        float           statEquippedSum   = 0f;
        bool            toDiscard         = false;
        GameObject      textObject        = null;
        RectTransform   textTransform     = null;
        SpritedStringUI textComponent     = null;
        Vector2         textDimensions    = Vector2.zero;
        Vector2         textScales        = Vector2.zero;
        Vector2         textPositionRates = Vector2.zero;
        TextAlignment   textAnchor        = TextAlignment.Center;

        textDatabase = GameTextDatabase.Instance;
        if (statsDisplayValid && (interfaceCanvasTrans != null) && (player != null) && (textDatabase != null))
        {
            if (statsDisplay.displayLevel && (levelObject == null))
            {
                statName          = textDatabase.GetSystemText(GameTextDatabase.TEXT_ID_PLAYER_LEVEL, ref toDiscard);
                statName         += " " + player.GetCurrentLevel();
                textScales        = statsDisplay.levelScales;
                textPositionRates = statsDisplay.levelPositionRates;
                textAnchor        = statsDisplay.levelAnchorAlignment;
                CreateTextDisplayObject("LevelDisplay", statName, textScales, textPositionRates, textAnchor, ref levelObject,
                                        ref levelTransform, ref levelText);
            }
            if (statObjects == null)
            {
                stats = statsDisplay.attributes;
                if (stats != null)
                {
                    totalStats = stats.Length;
                    if (totalStats > 0)
                    {
                        statObjects    = new GameObject[totalStats][];
                        statTransforms = new RectTransform[totalStats][];
                        statTexts      = new SpritedStringUI[totalStats][];
                        statValues     = new int[totalStats][];
                        GameObject[]      newStatObjects    = null;
                        RectTransform[]   newStatTransforms = null;
                        SpritedStringUI[] newStatTexts      = null;
                        int[]             newStatValues     = null;
                        int  statValue              = -1;
                        int  percentageBase         = 0;
                        int  percentageBaseLimited  = 0;
                        int  percentageEquip        = 0;
                        int  percentageEquipLimited = 0;
                        int  percentageTotal        = 0;
                        int  percentageTotalLimited = 0;
                        bool percentageBaseReady    = false;
                        bool percentageEquipReady   = false;
                        textAnchor = statsDisplay.attributeAnchorAlignment;
                        textScales = statsDisplay.attributeScales;
                        for (int i = 0; i < stats.Length; i++)
                        {
                            newStatObjects    = new GameObject[aspects.Length];
                            newStatTransforms = new RectTransform[aspects.Length];
                            newStatTexts      = new SpritedStringUI[aspects.Length];
                            newStatValues     = new int[aspects.Length];
                            statName          = textDatabase.GetEquipAttributeName(stats[i]);
                            player.GetStatValueSegments(stats[i], ref statValueOriginal, ref statValueBase, ref statEquippedSum);
                            percentageBaseReady  = false;
                            percentageEquipReady = false;
                            for (int j = 0; j < aspects.Length; j++)
                            {
                                switch (aspects[j])
                                {
                                case AttributeAspect.Name:
                                    textName          = "StatName" + statName;
                                    textValue         = statName;
                                    textPositionRates = statsDisplay.attributeNamePosRates[i];
                                    statValue         = -1;
                                    break;

                                case AttributeAspect.Base:
                                    textName = "StatBase" + statName;
                                    if (!percentageBaseReady)
                                    {
                                        percentageBase        = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal);
                                        statValue             = percentageBase;
                                        percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase;
                                        percentageBaseReady   = true;
                                    }
                                    textValue         = percentageBaseLimited.ToString();
                                    textPositionRates = statsDisplay.attributeBasePosRates[i];
                                    break;

                                case AttributeAspect.Equip:
                                    textName = "StatEquip" + statName;
                                    if (!percentageEquipReady)
                                    {
                                        percentageEquip        = UsefulFunctions.GetPercentage(statEquippedSum);
                                        statValue              = percentageEquip;
                                        percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip;
                                        percentageEquipReady   = true;
                                    }
                                    textValue         = percentageEquipLimited.ToString();
                                    textPositionRates = statsDisplay.attributeEquipPosRates[i];
                                    break;

                                case AttributeAspect.Total:
                                    textName = "StatTotal" + statName;
                                    if (!percentageBaseReady)
                                    {
                                        percentageBase        = UsefulFunctions.GetPercentage(statValueBase, statValueOriginal);
                                        percentageBaseLimited = (percentageBase > percentageLimit) ? percentageLimit : percentageBase;
                                        percentageBaseReady   = true;
                                    }
                                    if (!percentageEquipReady)
                                    {
                                        percentageEquip        = UsefulFunctions.GetPercentage(statEquippedSum);
                                        percentageEquipLimited = (percentageEquip > percentageLimit) ? percentageLimit : percentageEquip;
                                        percentageEquipReady   = true;
                                    }
                                    percentageTotal        = percentageBase + percentageEquip;
                                    statValue              = percentageTotal;
                                    percentageTotalLimited = (percentageTotal > percentageLimit) ? percentageLimit : percentageTotal;
                                    textValue              = percentageTotalLimited.ToString();
                                    textPositionRates      = statsDisplay.attributeTotalPosRates[i];
                                    break;
                                }
                                CreateTextDisplayObject(textName, textValue, textScales, textPositionRates,
                                                        textAnchor, ref textObject, ref textTransform, ref textComponent);
                                newStatObjects[j]    = textObject;
                                newStatTransforms[j] = textTransform;
                                newStatTexts[j]      = textComponent;
                                newStatValues[j]     = statValue;
                            }
                            statObjects[i]    = newStatObjects;
                            statTransforms[i] = newStatTransforms;
                            statTexts[i]      = newStatTexts;
                            statValues[i]     = newStatValues;
                        }
                    }
                }
            }
            return(true);
        }
        return(false);
    }
예제 #11
0
    protected virtual void BuildOptions()
    {
        if ((interfaceCanvasComponent == null) || (optionsParentTransform == null))
        {
            return;
        }
        SeparateCurrentlyValidOptions();
        if ((currentValidOptionModels == null) || (currentValidOptionChoiceEffects == null))
        {
            return;
        }
        optionObjects     = new GameObject[currentValidModels];
        optionTransforms  = new RectTransform[currentValidModels];
        optionComponents  = new ButtonAnimator[currentValidModels];
        optionEffects     = new ChoiceEffect[currentValidModels];
        optionTextObjects = new GameObject[currentValidModels];
        optionTexts       = new SpritedStringUI[currentValidModels];
        GameObject      optionModel         = null;
        GameObject      newOptionObject     = null;
        RectTransform   newOptionTrans      = null;
        ButtonAnimator  newOptionComponent  = null;
        Vector2         newOptionScale      = Vector2.one;
        ChoiceEffect    newOptionEffect     = ChoiceEffect.None;
        GameObject      newOptionTextObject = null;
        RectTransform   toDiscard           = null;
        SpritedStringUI newOptionText       = null;
        /*halmeida - discover the canvas X coordinate where all options should be placed.*/
        float newAnchoredX = (optionCenterXRate - 0.5f) * interfaceCanvasRect.width;

        /*halmeida - discover the canvas Y coordinate where the top of the first option should be placed.*/
        highestOptionTopY = (highestOptionTopRate - 0.5f) * interfaceCanvasRect.height;
        float newAnchoredY = highestOptionTopY;
        /*halmeida - discover the vertical distance from one option to the next.*/
        float            optionDistance   = optionDistanceRate * interfaceCanvasRect.height;
        float            halfOptionHeight = 0f;
        GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
        string           buttonCaption    = null;

        for (int i = 0; i < currentValidModels; i++)
        {
            optionModel        = currentValidOptionModels[i];
            newOptionObject    = Instantiate(optionModel) as GameObject;
            newOptionTrans     = newOptionObject.GetComponent <RectTransform>();
            newOptionComponent = newOptionObject.GetComponent <ButtonAnimator>();
            newOptionScale     = currentValidOptionScales[i];
            newOptionEffect    = currentValidOptionChoiceEffects[i];
            newOptionTrans.SetParent(optionsParentTransform, false);
            newOptionTrans.localScale = new Vector3(newOptionScale.x, newOptionScale.y, 1f);
            halfOptionHeight          = (newOptionTrans.rect.height / 2f) * newOptionScale.y;
            newAnchoredY -= halfOptionHeight;
            newOptionTrans.anchoredPosition = new Vector2(newAnchoredX, newAnchoredY);
            newAnchoredY       -= halfOptionHeight + optionDistance;
            newOptionTextObject = null;
            newOptionText       = null;
            if (useOptionEffectAsText && (gameTextDatabase != null))
            {
                buttonCaption = gameTextDatabase.GetMenuOptionText(newOptionEffect);
                CreateButtonText(newOptionTrans, buttonCaption, ref newOptionTextObject, ref toDiscard, ref newOptionText, false);
            }
            optionObjects[i]     = newOptionObject;
            optionTransforms[i]  = newOptionTrans;
            optionComponents[i]  = newOptionComponent;
            optionEffects[i]     = newOptionEffect;
            optionTextObjects[i] = newOptionTextObject;
            optionTexts[i]       = newOptionText;
        }
        hiddenOptionHeight = 0f;
        if (newAnchoredY < -interfaceCanvasRect.height / 2f)
        {
            hiddenOptionHeight = -newAnchoredY - interfaceCanvasRect.height / 2f;
        }
    }
예제 #12
0
    public void DrawModel()
    {
        // weather
        // terrain

        /*for (int i = 0; i < battleModel.teams.Count; i++)
         * {
         *  BattleTeam team = battleModel.teams[i];
         *  Debug.Log("===== Team " + team.teamPos + " =====");
         *  for (int k = 0; k < team.trainers.Count; k++)
         *  {
         *      Trainer trainer = team.trainers[k];
         *      Debug.Log("=== Trainer " + trainer.name + " ===");
         *  }
         * }*/

        string text = "";

        for (int i = 0; i < battleModel.pokemonOnField.Count; i++)
        {
            Pokemon pokemon   = battleModel.pokemonOnField[i];
            double  hpPercent = System.Math.Round(battleModel.GetPokemonHPAsPercentage(pokemon), 2);

            string        typeString   = " (Types - ";
            List <string> pokemonTypes = battleModel.PBPGetTypes(pokemon);
            typeString += GameTextDatabase.ConvertTypesToString(pokemonTypes.ToArray());
            typeString += ")";

            string statusString = " (";
            statusString += (pokemon.nonVolatileStatus.statusID == "healthy") ? ""
                : pokemon.nonVolatileStatus.data.conditionName;
            for (int k = 0; k < pokemon.bProps.statusConditions.Count; k++)
            {
                statusString += (string.IsNullOrEmpty(statusString)) ? "" : "/";
                statusString += (pokemon.bProps.statusConditions[k].statusID == "healthy") ? ""
                    : pokemon.bProps.statusConditions[k].data.conditionName;
                if (k != pokemon.bProps.statusConditions.Count - 1)
                {
                    statusString += "/";
                }
            }
            statusString += ")";

            string statModString = " (Stat Stages - "
                                   + pokemon.bProps.ATKStage + "/"
                                   + pokemon.bProps.DEFStage + "/"
                                   + pokemon.bProps.SPAStage + "/"
                                   + pokemon.bProps.SPDStage + "/"
                                   + pokemon.bProps.SPEStage + "/"
                                   + pokemon.bProps.ACCStage + "/"
                                   + pokemon.bProps.EVAStage + ")";

            string statString = " (Stats - "
                                + battleModel.GetPokemonATK(pokemon, false, false) + "/"
                                + battleModel.GetPokemonDEF(pokemon, false, false) + "/"
                                + battleModel.GetPokemonSPA(pokemon, false, false) + "/"
                                + battleModel.GetPokemonSPD(pokemon, false, false) + "/"
                                + battleModel.GetPokemonSPE(pokemon, false, false) + ")";

            string      abilityString = " (Ability: ";
            AbilityData abilityData   = battleModel.PBPGetAbilityData(pokemon);
            if (abilityData == null)
            {
                abilityString += "---";
            }
            else
            {
                abilityString += abilityData.abilityName;
            }
            abilityString += ")";

            string subString = (pokemon.bProps.substituteHP > 0) ? " (Substitute)" : "";

            string itemString = (pokemon.item == null) ? "" : " (Item: " + pokemon.item.data.itemName + ")";

            text += GetPokemonName(pokemon)
                    + subString
                    + " - Lv." + pokemon.level
                    //+ " - " + Debug_GetPokemonHealth(pokemon)
                    + " - " + (hpPercent * 100) + "%"
                    + typeString
                    + statusString
                    + statModString
                    + statString
                    + abilityString
                    + itemString
                    + ((i == battleModel.pokemonOnField.Count - 1)? "" : "\n");
        }
        Debug.Log(text);
    }
예제 #13
0
    private void CreateActionButtons()
    {
        if ((validItems != null) && (actionButtonModel != null) && (interfaceCanvasTrans != null) && (actionButtons == null))
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            int totalActions = 0;
            if (itemActions != null)
            {
                totalActions = itemActions.Length;
            }
            if ((totalActions > 0) && (checkingItemIndex > -1) && (checkingItemIndex < validItems.Count))
            {
                ItemData itemData     = validItems[checkingItemIndex];
                bool     isEquippable = (itemData.equipment != null);
                bool     isEquipped   = player.IsEquippedWith(itemData.itemID);
                bool     isExpendable = itemData.expendable;
                actionButtonObjects    = new GameObject[totalActions];
                actionButtonTransforms = new RectTransform[totalActions];
                actionButtons          = new ButtonAnimator[totalActions];

                /*halmeida - the button objects and the text objects have to be separate objects so that they
                 * can have different scaling.*/
                actionTextObjects = new GameObject[totalActions];
                actionTexts       = new SpritedStringUI[totalActions];
                Vector2         buttonScale         = actionDisplayScheme.buttonElementScale;
                Vector2         buttonPositionRates = Vector2.zero;
                string          actionName          = null;
                Vector2[]       allPositionRates    = actionDisplayScheme.elementPositionRates;
                GameObject      buttonObject        = null;
                RectTransform   buttonTransform     = null;
                ButtonAnimator  buttonAnimator      = null;
                GameObject      buttonTextObject    = null;
                RectTransform   buttonTextTrans     = null;
                SpritedStringUI buttonText          = null;
                for (int i = 0; i < totalActions; i++)
                {
                    if (gameTextDatabase != null)
                    {
                        actionName = gameTextDatabase.GetMenuOptionText(itemActions[i]);
                    }
                    if (allPositionRates != null)
                    {
                        buttonPositionRates = (allPositionRates.Length > i) ? allPositionRates[i] : new Vector2(0.5f, 0.5f);
                    }
                    CreateButtonObject(actionButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                       ref buttonObject, ref buttonTransform, ref buttonAnimator);
                    actionButtonObjects[i]    = buttonObject;
                    actionButtonTransforms[i] = buttonTransform;
                    actionButtons[i]          = buttonAnimator;
                    CreateTextDisplayObject("ActionName", actionName, Vector2.one, buttonPositionRates, TextAlignment.Center,
                                            ref buttonTextObject, ref buttonTextTrans, ref buttonText);
                    actionTextObjects[i] = buttonTextObject;
                    actionTexts[i]       = buttonText;
                    switch (itemActions[i])
                    {
                    case ChoiceEffect.Equip:
                        if (!isEquippable || isEquipped)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;

                    case ChoiceEffect.Unequip:
                        if (!isEquipped)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;

                    case ChoiceEffect.Use:
                        if (!isExpendable)
                        {
                            ChangeButtonState(true, buttonAnimator, buttonText, null);
                        }
                        break;
                    }
                }
            }
        }
    }
예제 #14
0
 private void CreateItemButtons()
 {
     chosenItemIndex   = -1;
     checkingItemIndex = -1;
     if ((validItems != null) && (itemButtonModel != null) && (itemButtons == null))
     {
         if (validItems.Count > 0)
         {
             itemButtonObjects    = new GameObject[validItems.Count];
             itemButtonTransforms = new RectTransform[validItems.Count];
             itemButtons          = new ButtonAnimator[validItems.Count];
             itemTextObjects      = new GameObject[validItems.Count];
             itemTextTransforms   = new RectTransform[validItems.Count];
             itemTexts            = new SpritedStringUI[validItems.Count];
             itemAmountObjects    = new GameObject[validItems.Count];
             itemAmountTransforms = new RectTransform[validItems.Count];
             itemAmountComponents = new SpritedStringUI[validItems.Count];
             Vector2          buttonScale         = itemDisplayScheme.buttonElementScale;
             Vector2[]        allPositionRates    = itemDisplayScheme.elementPositionRates;
             Vector2          buttonPositionRates = Vector2.zero;
             Vector2          textPositionRates   = Vector2.zero;
             GameTextDatabase gameTextDatabase    = GameTextDatabase.Instance;
             ItemData         itemData            = null;
             string           itemName            = null;
             bool             itemHidden          = false;
             GameObject       itemButtonObject    = null;
             RectTransform    itemButtonTrans     = null;
             ButtonAnimator   itemButton          = null;
             GameObject       itemTextObject      = null;
             RectTransform    itemTextTrans       = null;
             SpritedStringUI  itemText            = null;
             GameObject       itemAmountObject    = null;
             RectTransform    itemAmountTransform = null;
             SpritedStringUI  itemAmountComponent = null;
             bool             needsScroll         = false;
             for (int i = 0; i < validItems.Count; i++)
             {
                 itemData            = validItems[i];
                 itemHidden          = true;
                 buttonPositionRates = new Vector2(0.5f, 0.5f);
                 gameTextDatabase.GetItemDescription(itemData.itemID, ref itemName);
                 if (allPositionRates != null)
                 {
                     if (i < allPositionRates.Length)
                     {
                         itemHidden          = false;
                         buttonPositionRates = allPositionRates[i];
                     }
                     else
                     {
                         needsScroll = true;
                     }
                 }
                 CreateButtonObject(itemButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center, ref itemButtonObject,
                                    ref itemButtonTrans, ref itemButton);
                 textPositionRates = buttonPositionRates + itemTextOffsetRates;
                 CreateTextDisplayObject("ItemName", itemName, Vector2.one, textPositionRates, TextAlignment.Left,
                                         ref itemTextObject, ref itemTextTrans, ref itemText);
                 textPositionRates = buttonPositionRates + itemAmountOffsetRates;
                 CreateTextDisplayObject("ItemUnits", validItemUnits[i].ToString(), Vector2.one, textPositionRates,
                                         TextAlignment.Right, ref itemAmountObject, ref itemAmountTransform, ref itemAmountComponent);
                 if (itemHidden)
                 {
                     lastItemIndex = i - 1;
                     itemButtonObject.SetActive(false);
                     itemTextObject.SetActive(false);
                     itemAmountObject.SetActive(false);
                 }
                 else
                 {
                     if (firstItemIndex == -1)
                     {
                         firstItemIndex = i;
                         lastItemIndex  = i;
                     }
                 }
                 itemButtonObjects[i]    = itemButtonObject;
                 itemButtonTransforms[i] = itemButtonTrans;
                 itemButtons[i]          = itemButton;
                 itemTextObjects[i]      = itemTextObject;
                 itemTextTransforms[i]   = itemTextTrans;
                 itemTexts[i]            = itemText;
                 itemAmountObjects[i]    = itemAmountObject;
                 itemAmountTransforms[i] = itemAmountTransform;
                 itemAmountComponents[i] = itemAmountComponent;
                 if ((chosenItemIndex == -1) && (itemButton != null))
                 {
                     if (player.IsEquippedWith(itemData.itemID))
                     {
                         chosenItemIndex = i;
                         ChangeButtonState(true, itemButton, itemText, itemAmountComponent);
                     }
                 }
             }
             if (needsScroll)
             {
                 buttonScale         = itemDisplayScheme.buttonReturnScale;
                 buttonPositionRates = itemDisplayScheme.returnPositionRates;
                 CreateButtonObject(itemReturnButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                    ref itemReturnButtonObject, ref itemReturnButtonTransform, ref itemReturnButton);
                 buttonScale         = itemDisplayScheme.buttonAdvanceScale;
                 buttonPositionRates = itemDisplayScheme.advancePositionRates;
                 CreateButtonObject(itemAdvanceButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                    ref itemAdvanceButtonObject, ref itemAdvanceButtonTransform, ref itemAdvanceButton);
                 if (itemReturnButton != null)
                 {
                     itemReturnButton.SetPressed(true);
                 }
             }
         }
         else
         {
             Debug.Log("Debug : MenuInventory : no items to show in section " + chosenSectionIndex + ".");
         }
     }
 }
예제 #15
0
    private void CreateSectionButtons()
    {
        bool            toDiscard           = false;
        GameObject      buttonObject        = null;
        RectTransform   buttonTransform     = null;
        ButtonAnimator  buttonAnimator      = null;
        GameObject      buttonTextObject    = null;
        RectTransform   buttonTextTrans     = null;
        SpritedStringUI buttonText          = null;
        Vector2         buttonScale         = Vector2.one;
        Vector2         buttonPositionRates = Vector2.zero;

        if ((sectionButtonModel != null) && (interfaceCanvasTrans != null) && (sectionButtons == null))
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            int totalSections = 1;
            if (firstSections != null)
            {
                if (firstSections.Length > 0)
                {
                    totalSections += firstSections.Length;
                }
            }
            sectionButtonObjects    = new GameObject[totalSections];
            sectionButtonTransforms = new RectTransform[totalSections];
            sectionButtons          = new ButtonAnimator[totalSections];

            /*halmeida - the button objects and the text objects have to be separate objects so that they
             * can have different scaling.*/
            sectionTextObjects = new GameObject[totalSections];
            sectionTexts       = new SpritedStringUI[totalSections];
            buttonScale        = sectionDisplayScheme.buttonElementScale;
            string    sectionTitle     = null;
            Vector2[] allPositionRates = sectionDisplayScheme.elementPositionRates;
            for (int i = 0; i < totalSections; i++)
            {
                if (gameTextDatabase != null)
                {
                    if (i == (totalSections - 1))
                    {
                        sectionTitle = gameTextDatabase.GetSystemText(GameTextDatabase.TEXT_ID_NON_EQUIPPABLE_ITEMS, ref toDiscard);
                    }
                    else
                    {
                        sectionTitle = gameTextDatabase.GetEquipBodyPartName(firstSections[i]);
                    }
                }
                if (allPositionRates != null)
                {
                    buttonPositionRates = (allPositionRates.Length > i) ? allPositionRates[i] : new Vector2(0.5f, 0.5f);
                }
                CreateButtonObject(sectionButtonModel, buttonScale, buttonPositionRates, TextAlignment.Center,
                                   ref buttonObject, ref buttonTransform, ref buttonAnimator);
                sectionButtonObjects[i]    = buttonObject;
                sectionButtonTransforms[i] = buttonTransform;
                sectionButtons[i]          = buttonAnimator;
                CreateTextDisplayObject("SectionName", sectionTitle, Vector2.one, buttonPositionRates, TextAlignment.Center,
                                        ref buttonTextObject, ref buttonTextTrans, ref buttonText);
                sectionTextObjects[i] = buttonTextObject;
                sectionTexts[i]       = buttonText;
            }
        }
    }
예제 #16
0
 public override void ExtractInterests(ChallengeStage stage)
 {
     base.ExtractInterests(stage);
     gameTextDatabase = GameTextDatabase.Instance;
     textBoxManager   = TextBoxManager.Instance;
 }
예제 #17
0
    private bool CreateHeader()
    {
        string        buttonCaption    = null;
        RectTransform toDiscard        = null;
        Vector2       anchoredPosition = Vector2.zero;

        if (interfaceCanvasObject != null)
        {
            GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
            if ((titleModel != null) && (titleObject == null))
            {
                titleObject    = Instantiate(titleModel) as GameObject;
                titleTransform = titleObject.GetComponent <RectTransform>();
                titleComponent = titleObject.GetComponent <ButtonAnimator>();
                if ((titleTransform != null) && (titleComponent != null))
                {
                    titleTransform.SetParent(interfaceCanvasTrans, false);
                    anchoredPosition.x = (titlePositionRates.x - 0.5f) * interfaceCanvasRect.width;
                    anchoredPosition.y = (titlePositionRates.y - 0.5f) * interfaceCanvasRect.height;
                    titleTransform.anchoredPosition = anchoredPosition;
                    titleTransform.localScale       = new Vector3(titleScale.x, titleScale.y, 1f);
                    if (gameTextDatabase != null)
                    {
                        buttonCaption = gameTextDatabase.GetMenuOptionText(titleTextEffect);
                        CreateButtonText(titleTransform, buttonCaption, ref titleTextObject, ref toDiscard, ref titleText, true);
                    }
                    titleComponent.SetPressed(true);
                }
                else
                {
                    titleTransform = null;
                    if (titleComponent != null)
                    {
                        titleComponent.Clear();
                        titleComponent = null;
                    }
                    Destroy(titleObject);
                    titleObject = null;
                }
            }
            if (allowQuitOption && (quitModel != null) && (quitObject == null))
            {
                quitObject    = Instantiate(quitModel) as GameObject;
                quitTransform = quitObject.GetComponent <RectTransform>();
                quitComponent = quitObject.GetComponent <ButtonAnimator>();
                if ((quitTransform != null) && (quitComponent != null))
                {
                    quitTransform.SetParent(interfaceCanvasTrans, false);
                    anchoredPosition.x             = (quitPositionRates.x - 0.5f) * interfaceCanvasRect.width;
                    anchoredPosition.y             = (quitPositionRates.y - 0.5f) * interfaceCanvasRect.height;
                    quitTransform.anchoredPosition = anchoredPosition;
                    quitTransform.localScale       = new Vector3(quitScale.x, quitScale.y, 1f);
                    if (gameTextDatabase != null)
                    {
                        buttonCaption = gameTextDatabase.GetMenuOptionText(quitTextEffect);
                        CreateButtonText(quitTransform, buttonCaption, ref quitTextObject, ref toDiscard, ref quitText, true);
                    }
                }
                else
                {
                    quitTransform = null;
                    if (quitComponent != null)
                    {
                        quitComponent.Clear();
                        quitComponent = null;
                    }
                    Destroy(quitObject);
                    quitObject = null;
                }
            }
            return((quitObject != null) || (titleObject != null));
        }
        return(false);
    }