예제 #1
0
    private void OnEnable()
    {
        PlayerManager.Instance.onInventoryChange += UpdateRecipe;
        UpdateRecipe();

        Book.ShowPage(currentType);
    }
예제 #2
0
    protected virtual void OnEnable()
    {
        for (int i = 0; i < buttons.Count; i++)
        {
            buttons[i].gameObject.SetActive(false);
        }

        PlacableData[] allData = DataManager.Instance.GetAllData(PlacableDataType);
        Button         button;

        for (int i = 0; i < allData.Length; i++)
        {
            PlacableData itemData = allData[i];
            if (i < buttons.Count)
            {
                button = buttons[i];
                button.gameObject.SetActive(true);
            }
            else
            {
                GameObject obj = Instantiate(ButtonPrefab);
                obj.transform.SetParent(Content, false);
                (obj.transform as RectTransform).anchoredPosition = new Vector2(175 + (i % 3) * 250, -125 - (i / 3) * 250);
                button = obj.GetComponent <Button>();
                buttons.Add(button);
            }
            PlacableButton image = button.GetComponent <PlacableButton>();
            image.SetPlacable(itemData);
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(new UnityEngine.Events.UnityAction(() => { ShowItem(itemData); }));
        }

        if ((HelpManager.Instance.CurrentStep == TutorialStep.CraftToy || HelpManager.Instance.CurrentStep == TutorialStep.PlaceToy) && PlacableDataType != PlacableDataType.Toy)
        {
            if (buttonFlash == null)
            {
                Destroy(buttonFlash);
            }
            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].interactable = false;
            }
            Book.FlashTab(PlacableDataType.Toy);
        }
        else if (HelpManager.Instance.CurrentStep == TutorialStep.PlaceTreat || HelpManager.Instance.CurrentStep == TutorialStep.CraftToy || HelpManager.Instance.CurrentStep == TutorialStep.PlaceToy)
        {
            if (buttonFlash == null)
            {
                buttonFlash = Instantiate(uiManager.flashPrefab);
            }
            buttonFlash.GetComponent <FlashUI>().SetTarget(buttons[0].targetGraphic as Image);
            buttons[0].interactable = true;
            for (int i = 1; i < buttons.Count; i++)
            {
                buttons[i].interactable = false;
            }
            Book.SetInteractable(false);
        }
        else
        {
            if (buttonFlash != null)
            {
                Destroy(buttonFlash);
            }
            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].interactable = true;
            }
            Book.SetInteractable(true);
        }

        Book.ShowPage(PlacableDataType);
    }