public void SetupActionPanel(ActionManager.DispensaryAction action)
    {
        if (buttons.Count > 0)
        {
            foreach (DispensaryActionRoundButton button in buttons)
            {
                Destroy(button.gameObject);
            }
            buttons.Clear();
        }
        if (toInstantiate.Count > 0)
        {
            toInstantiate.Clear();
        }
        if (action.NeedsTitlePanel())
        {
            titlePanel.gameObject.SetActive(true);
            Text[] text = titlePanel.gameObject.GetComponentsInChildren <Text>();
            text[0].text = action.actionName;
        }
        else
        {
            titlePanel.gameObject.SetActive(false);
        }
        switch (action.GetType())
        {
        case ActionManager.ActionType.expandDispensaryComponent:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            toInstantiate.Add(new ToInstantiate(selectExpansionEdgeButtonPrefab, "Select Expansion Edge"));
            toInstantiate.Add(new ToInstantiate(selectCustomExpansionEdgeButtonPrefab, "Select Custom Expansion Edge"));
            break;

        case ActionManager.ActionType.moveDispensaryComponent:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            toInstantiate.Add(new ToInstantiate(moveSingleComponentButtonPrefab, "Move Single Component"));
            toInstantiate.Add(new ToInstantiate(moveMultipleComponentsButtonPrefab, "Move Multiple Components"));
            break;

        case ActionManager.ActionType.changeStoreObject:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            toInstantiate.Add(new ToInstantiate(modifyShelvesButtonPrefab, "Modify Shelving"));
            break;

        case ActionManager.ActionType.addStoreObject:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            break;

        case ActionManager.ActionType.addDoorway:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            break;

        case ActionManager.ActionType.addWindow:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            toInstantiate.Add(new ToInstantiate(singleWindowButtonPrefab, "Create One Window"));
            toInstantiate.Add(new ToInstantiate(multipleWindowsButtonPrefab, "Create Multiple Windows"));
            break;

        case ActionManager.ActionType.expandBuildableZone:
            toInstantiate.Add(new ToInstantiate(undoButtonPrefab, "Revert Changes"));
            break;
        }
        CreateActionButtons();
        ActionPanelOnScreen();
    }
Ejemplo n.º 2
0
    public void CreateModelsList() // panel 1
    {
        foreach (Image img in currentModelsList)
        {
            Destroy(img.gameObject);
        }
        currentModelsList.Clear();
        List <StoreObjectReference> siblingModels = new List <StoreObjectReference>();
        int  ID              = storeObject.objectID;
        int  subID           = 0;
        int  originalSubID   = storeObject.subID;
        bool gettingSiblings = true;

        while (gettingSiblings)
        {
            StoreObjectReference newReference = storeObject.dm.database.GetStoreObject(ID, subID);
            if (newReference != null)
            {
                siblingModels.Add(newReference);
            }
            else
            {
                gettingSiblings = false;
                break;
            }
            subID++;
        }
        RectTransform rectTransform      = panel1Content.GetComponent <RectTransform>();
        float         prefabHeight       = subModelPrefab.gameObject.GetComponent <RectTransform>().rect.height;
        float         contentPanelHeight = siblingModels.Count * prefabHeight;

        rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, contentPanelHeight);
        for (int i = 0; i < siblingModels.Count; i++)
        {
            StoreObjectReference reference = siblingModels[i];
            int     quantity      = storeObject.modifierHandler.GetAddonsModifier().inventory.GetQuantityOwned(reference.objectID, reference.subID);
            Image   newSubModelGO = Instantiate(subModelPrefab);
            Image[] imgComponents = newSubModelGO.GetComponentsInChildren <Image>();
            imgComponents[1].sprite = reference.objectScreenshot;
            Button[] buttonComponents = newSubModelGO.GetComponentsInChildren <Button>();
            buttonComponents[0].onClick.AddListener(() => OnSubModelClick(reference));
            Text[] textComponents = newSubModelGO.GetComponentsInChildren <Text>();
            textComponents[0].text = reference.ToString();
            string quantityText = string.Empty;
            ActionManager.DispensaryAction currentAction = objectSelectionPanel.actionManager.currentAction;
            if (currentAction != null)
            {
                if (currentAction.GetType() == ActionManager.ActionType.changeStoreObject)
                {
                    ActionManager.ChangeStoreObjectModel action = (ActionManager.ChangeStoreObjectModel)objectSelectionPanel.actionManager.currentAction;
                    StoreObject originalStoreObject             = action.originalStoreObject;
                    StoreObject newStoreObject = action.newStoreObject;
                    if (reference.subID == originalStoreObject.subID)
                    {
                        quantityText = "Current Model";
                    }
                    else if (reference.subID == newStoreObject.subID)
                    {
                        quantityText = "Currently Previewing";
                    }
                    else
                    {
                        quantityText = quantity.ToString() + " Owned";
                    }
                }
                else
                {
                    print("unknown error - ModifierPanel.cs : CreateModelsList()");
                }
            }
            else
            {
                if (reference.subID == originalSubID)
                {
                    quantityText = "Current Model";
                }
                else
                {
                    quantityText = quantity.ToString() + " Owned";
                }
            }
            textComponents[1].text = quantityText;
            textComponents[2].text = "$" + reference.price.ToString();
            newSubModelGO.transform.SetParent(panel1Content.transform.parent, false);
            newSubModelGO.gameObject.SetActive(true);
            newSubModelGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i);
            currentModelsList.Add(newSubModelGO);
            newSubModelGO.transform.SetParent(panel1Content.transform);

            // Event Triggers
            float        yPos    = newSubModelGO.transform.position.y;
            EventTrigger trigger = imgComponents[1].GetComponent <EventTrigger>();
            SetupMouseEnterScreenshotTrigger(trigger, reference, yPos);
            SetupMouseExitScreenshotTrigger(trigger);
        }
    }