示例#1
0
    protected abstract void _SetDecoration(string decoID, bool isPlacedFromDecoMode);       // set the deco to this node

    void Start()
    {
        DecoModeUIManager.Instance.OnManagerOpen     += ShowDecoZones;
        InventoryTokenDragElement.OnDecoItemPickedUp += OnDecorationPickedUp;
        InventoryTokenDragElement.OnDecoItemDropped  += OnDecorationDropped;

        spriteIcon.sprite = SpriteCacheManager.GetDecoIconSprite(nodeType);
        nodeID            = transform.parent.name;
        CheckSaveData();
    }
示例#2
0
    /// <summary>
    /// Creates the sub category items with string.
    /// </summary>
    /// <param name="page">Page.</param>
    private void CreateSubCategoryItemsWithString(string page, StoreShortcutType shortcutType = StoreShortcutType.None)
    {
        if (page != "Items" && page != "Food" && page != "Decorations")
        {
            Debug.LogError("Illegal store sub category: " + page);
            return;
        }

        currentPage = page;

        // Reset the grid and scrolling
        scrollRect.StopMovement();
        Vector2 auxPosition = grid.GetComponent <RectTransform>().anchoredPosition;

        grid.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f, auxPosition.y);

        //create the tabs for those sub category
        if (currentPage == "Food")
        {
            InventoryUIManager.Instance.ShowPanel(true);
            DecoInventoryUIManager.Instance.HidePanel();

            foreach (Transform tab in tabArea.transform)
            {
                ToggleTab(tab, false);
            }

            CreateSubCategoryItemsTab("foodDefaultTab", shortcutType);
        }
        else if (currentPage == "Items")
        {
            InventoryUIManager.Instance.ShowPanel(true);
            DecoInventoryUIManager.Instance.HidePanel();

            foreach (Transform tab in tabArea.transform)
            {
                ToggleTab(tab, false);
            }

            CreateSubCategoryItemsTab("itemsDefaultTab", shortcutType);
        }
        else if (currentPage == "Decorations")
        {
            InventoryUIManager.Instance.HidePanel();
            DecoInventoryUIManager.Instance.ShowPanel();

            //Get a list of decoration types from Enum
            string[] decorationEnums = Enum.GetNames(typeof(DecorationTypes));
            int      counter         = 0;

            // Set the default category
            string defaultTabName = "Carpet";
            if (SceneUtils.CurrentScene == SceneUtils.YARD)
            {
                defaultTabName = "SmallPlant";
            }

            List <string> unlockedDecoList = PartitionManager.Instance.GetAllowedDecoTypeFromLatestPartition();

            //Rename the tab to reflect the sub category name
            foreach (Transform tab in tabArea.transform)                        // TODO-s CHANGE THIS TO FIT TABS
            {
                if (counter < decorationEnums.Length)
                {
                    tab.name = decorationEnums[counter];
                    if (tab.name == defaultTabName)
                    {
                        tab.GetComponent <Image>().sprite = SpriteCacheManager.GetSprite("buttonCategoryActive");
                    }
                    Image imageSprite = tab.FindChild("TabImage").gameObject.GetComponent <Image>();
                    imageSprite.sprite = SpriteCacheManager.GetDecoIconSprite((DecorationTypes)Enum.Parse(typeof(DecorationTypes), tab.name));

                    //Debug.Log(tabParent.name);
                    // If the gate xml has the deco type allowed, enable button
                    if (unlockedDecoList.Contains(tab.name))
                    {
                        ToggleTab(tab, true);
                    }
                    // Else disable button
                    else
                    {
                        ToggleTab(tab, false);
                    }
                }
                else
                {
                    tab.name = "";
                    ToggleTab(tab, false);
                }
                counter++;
            }

            //After tabs have been set up create items for the first/default tab
            CreateSubCategoryItemsTab(defaultTabName, shortcutType);
        }
        ShowStoreSubPanel();
    }