void Start()
    {
        InventoryInteraction = InventoryInteraction.GetInstance();

        ItemInstance    = GetComponent <ItemInstance>();
        inventoryHolder = InventoryInteraction.inventoryHolder;
        platform        = InventoryInteraction.platform;
        AudioHost       = AudioHost.GetInstance();
    }
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
Пример #3
0
    /// <summary>
    /// Session start
    /// </summary>
    private void SubInitialiseSessionStart()
    {
        //inventory interaction & tooltip arrays set up
        int numOfOptions = arrayOfInventoryOptions.Length;

        Debug.AssertFormat(numOfOptions == GameManager.i.guiScript.maxInventoryOptions, "Mismatch on Option numbers (is {0}, should be {1})", numOfOptions, GameManager.i.guiScript.maxInventoryOptions);
        //cancel button event
        buttonInteraction = buttonCancel.GetComponent <ButtonInteraction>();
        if (buttonInteraction != null)
        {
            buttonInteraction.SetButton(EventType.InventoryCloseUI);
        }
        else
        {
            Debug.LogError("Invalid buttonInteraction Cancel (Null)");
        }
        //help button
        help = buttonHelp.GetComponent <GenericHelpTooltipUI>();
        if (help == null)
        {
            Debug.LogError("Invalid help script (Null)");
        }
        //initialise arrays
        arrayOfInteractions          = new InventoryInteraction[numOfOptions];
        arrayOfTooltipsSprites       = new GenericTooltipUI[numOfOptions];
        arrayOfTooltipsStars         = new GenericTooltipUI[numOfOptions];
        arrayOfTooltipsCompatibility = new GenericTooltipUI[numOfOptions];
        arrayOfTooltipsTexts         = new GenericTooltipUI[numOfOptions];
        for (int i = 0; i < numOfOptions; i++)
        {
            if (arrayOfInventoryOptions[i] != null)
            {
                //interaction
                InventoryInteraction interaction = arrayOfInventoryOptions[i].GetComponent <InventoryInteraction>();
                if (interaction != null)
                {
                    arrayOfInteractions[i] = interaction;
                    //tooltip -> sprite (attached to game object to prevent tooltip component masking gameobject interaction component which is needed for click detection for menu's)
                    GenericTooltipUI tooltipSprite = arrayOfInventoryOptions[i].GetComponent <GenericTooltipUI>();
                    if (tooltipSprite != null)
                    {
                        arrayOfTooltipsSprites[i] = tooltipSprite;
                    }
                    else
                    {
                        Debug.LogErrorFormat("Invalid GenericTooltipUI for arrayOfInventoryOptions[{0}] (Null)", i);
                    }
                    //tooltip -> stars (bottomText, optional)
                    GenericTooltipUI tooltipStars = interaction.tooltipStars.GetComponent <GenericTooltipUI>();
                    if (tooltipStars != null)
                    {
                        arrayOfTooltipsStars[i] = tooltipStars;
                    }
                    else
                    {
                        Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipStars \"{0}\" (Null)", i);
                    }
                    //tooltip -> compatibility (topText, optional)
                    GenericTooltipUI tooltipCompatibility = interaction.tooltipCompatibility.GetComponent <GenericTooltipUI>();
                    if (tooltipCompatibility != null)
                    {
                        arrayOfTooltipsCompatibility[i] = tooltipCompatibility;
                    }
                    else
                    {
                        Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipCompatibility \"{0}\" (Null)", i);
                    }
                    //tooltip -> texts (upperText, optional)
                    GenericTooltipUI tooltipText = interaction.tooltipText.GetComponent <GenericTooltipUI>();
                    if (tooltipText != null)
                    {
                        arrayOfTooltipsTexts[i] = tooltipText;
                    }
                    else
                    {
                        Debug.LogErrorFormat("Invalid GenericTooltipUI for interaction.tooltipText \"{0}\" (Null)", i);
                    }
                }
                else
                {
                    Debug.LogErrorFormat("Invalid InventoryInteraction for arrayOfInventoryOptions[{0}] (Null)", i);
                }
            }
            else
            {
                Debug.LogErrorFormat("Invalid arrayOfInventoryOptions[{0}] (Null)", i);
            }
        }
        //toggle main objects
        inventoryCanvas.gameObject.SetActive(false);
        modalPanelObject.SetActive(true);
        modalInventoryObject.SetActive(true);
        modalHeaderObject.SetActive(true);
    }
Пример #4
0
 void Start()
 {
     InventoryInteraction = InventoryInteraction.GetInstance();
 }