Пример #1
0
    protected override void PerformAction(float timeStep)
    {
        string text        = null;
        string speakerName = null;
        bool   tryAbove    = false;
        bool   autoClose   = false;

        base.PerformAction(timeStep);
        if (!dialogueCreated)
        {
            if ((gameTextDatabase != null) && (textBoxManager != null))
            {
                switch (dialogueType)
                {
                case GameTextDatabase.TextType.Platform:
                    text            = gameTextDatabase.GetPlatformText(dialogueID, dialoguePlatform, ref autoClose);
                    dialogueCreated = textBoxManager.ShowDialogue(null, text, false, autoClose, this);
                    break;

                case GameTextDatabase.TextType.System:
                    text            = gameTextDatabase.GetSystemText(dialogueID, ref autoClose);
                    dialogueCreated = textBoxManager.ShowDialogue(null, text, false, autoClose, this);
                    break;

                case GameTextDatabase.TextType.Dialogue:
                    text            = gameTextDatabase.GetDialogueText(dialogueID, ref speakerName, ref tryAbove, ref autoClose);
                    dialogueCreated = textBoxManager.ShowDialogue(speakerName, text, tryAbove, autoClose, this);
                    break;

                case GameTextDatabase.TextType.Item:
                    text            = gameTextDatabase.GetItemDescription(dialogueID, ref speakerName);
                    dialogueCreated = textBoxManager.ShowDialogue(speakerName, text, false, false, this);
                    break;
                }
            }
        }
    }
Пример #2
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);
    }