Beispiel #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;
                }
            }
        }
    }
Beispiel #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);
    }
Beispiel #3
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 + ".");
         }
     }
 }