Beispiel #1
0
 public void setForStoreCompare(bool comparingWithStore)
 {
     if (comparingWithStore)
     {
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(true);
         SCROLL_VIEW.SetActive(false);
         GameObject.Find("InventoryTabs").SetActive(false);
         GameObject.Find("InventoryFilterWidget").SetActive(false);
         GameObject.Find("InventoryCard").SetActive(false);
         if (GameObject.Find("WorkshopPartInfo") != null)
         {
             GameObject.Find("WorkshopPartInfo").SetActive(false);
         }
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("WorkshopMask").gameObject.SetActive(false);
         if (GameObject.Find("MaskedInventoryPartButton") != null)
         {
             GameObject.Find("MaskedInventoryPartButton").SetActive(false);
         }
         MASKED_ROBOT_WIDGET.SetActive(true);
         MASKED_ROBOT_WIDGET.transform.SetParent(GameObject.Find("BuildHubCanvas").transform, true);
     }
     else
     {
         MASKED_ROBOT_WIDGET.transform.SetParent(GameObject.Find("BuildHubCanvas").transform.Find("Workshop"), true);
         MASKED_ROBOT_WIDGET.SetActive(false);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("WorkshopPartInfo").gameObject.SetActive(true);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("WorkshopMask").gameObject.SetActive(false);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("MaskedInventoryPartButton").gameObject.SetActive(false);
         SCROLL_VIEW.SetActive(true);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("InventoryTabs").gameObject.SetActive(true);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("InventoryFilterWidget").gameObject.SetActive(true);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").Find("InventoryCard").gameObject.SetActive(true);
         GameObject.Find("BuildHubCanvas").transform.Find("Workshop").gameObject.SetActive(false);
     }
 }
Beispiel #2
0
    public ConfigurationCard(string robotName, long credits, double durability, double remainingDurability, string[] robotStatStrings, bool maxForceExceeded, Part[] parts, Color colorScheme, bool enableCreditsSpentAnimation)
    {
        this.robotName           = robotName;
        this.credits             = credits;
        this.durability          = durability;
        this.remainingDurability = remainingDurability;
        this.robotStatStrings    = robotStatStrings;
        this.maxForceExceeded    = maxForceExceeded;
        this.parts       = new List <Part>();
        attachments      = new List <Attachment>();
        this.colorScheme = colorScheme;
        this.enableCreditsSpentAnimation = enableCreditsSpentAnimation;
        foreach (Part part in parts)
        {
            if (!(part is Attachment))
            {
                this.parts.Add(part);
            }
            else
            {
                this.attachments.Add((Attachment)part);
            }
        }
        mode = InventoryCard.MODES.VIEW_PART_STATS;
        MASKED_ROBOT_WIDGET = GameObject.Find("Workshop").transform.Find("MaskedRobotWidget").gameObject;
        MASKED_ROBOT_WIDGET.SetActive(false);
        partBeingPreviewed            = null;
        partToEquipt                  = null;
        PERFORMANCE_METRIC_CALCULATOR = new PerformanceMetricCalculator();
        SCROLL_VIEW = GameObject.Find(CONFIGURATION_CARD_NAME);
        GameObject partsContainerGameObject = GameObject.Find(WIDGETS_CONTAINER_NAME);

        WIDGETS_CONTAINER = partsContainerGameObject.GetComponent <RectTransform>();
        SCROLL_RECT       = SCROLL_VIEW.GetComponent <ScrollRect>();
        WIDGETS_PANEL     = GameObject.Find(WIDGETS_PANEL_NAME).GetComponent <RectTransform>();
        SCROLLBAR_OBJECT  = GameObject.Find(WIDGETS_CARD_NAME).transform.Find(CONFIGURATION_SCROLLBAR_NAME).gameObject;
        SCROLLBAR         = SCROLLBAR_OBJECT.GetComponent <Scrollbar>();
        SCROLLBAR_OBJECT.SetActive(false);
        SCROLL_RECT.vertical        = false;
        robotWidget                 = GameObject.Find(CONFIGURATION_CARD_NAME).transform.Find(ROBOT_WIDGET_NAME).gameObject;
        robotWidgetLabel            = robotWidget.transform.Find(ROBOT_WIDGET_LABEL_NAME).gameObject;
        robotWidgetLabelPlaceholder = robotWidgetLabel.transform.Find("Text Area").Find(ROBOT_WIDGET_LABEL_PLACEHOLDER_NAME).gameObject;
        robotWidgetLabelPlaceholder.GetComponent <TextMeshProUGUI>().enabled = false;
        robotWidgetLabelText          = robotWidgetLabel.transform.Find("Text Area").Find(ROBOT_WIDGET_LABEL_TEXT_NAME).gameObject;
        robotWidgetDurabilityBar      = robotWidget.transform.Find(ROBOT_WIDGET_DURABILITY_BAR_NAME).gameObject;
        robotWidgetDurabilityBarLabel = robotWidget.transform.Find(ROBOT_WIDGET_DURABILITY_BAR_LABEL_NAME).gameObject;
        robotWidgetStats = robotWidget.transform.Find(ROBOT_WIDGET_STATS_NAME).gameObject;
        WORKSHOP_CREDIT  = GameObject.Find("WorkshopCredit");
        updateCredits();
        WORKSHOP_CREDITS_SPENT = GameObject.Find("Workshop").transform.Find("WorkshopCreditsSpent").gameObject;
        WORKSHOP_CREDITS_SPENT_HOME_POSITION = WORKSHOP_CREDITS_SPENT.transform.localPosition;
        WORKSHOP_CREDITS_SPENT.SetActive(false);
        WORKSHOP_CREDIT.GetComponent <TextMeshProUGUI>().color = colorScheme;
        initialize();
    }
Beispiel #3
0
    public void setMode(InventoryCard.MODES mode, Part partBeingPreviewed, Part partToEquipt, string[] previewRobotStats)
    {
        this.partBeingPreviewed = partBeingPreviewed;
        this.partToEquipt       = partToEquipt;
        if (mode != this.mode)
        {
            switch (mode)
            {
            case InventoryCard.MODES.VIEW_PART_STATS:
                MASKED_ROBOT_WIDGET.SetActive(false);
                break;

            case InventoryCard.MODES.PREVIEW_PART:
                MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetLabel").gameObject.GetComponent <TextMeshProUGUI>().text              = robotWidgetLabel.GetComponent <TMP_InputField>().text;
                MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetDurabilityBar").gameObject.GetComponent <RectTransform>().localScale  = robotWidgetDurabilityBar.GetComponent <RectTransform>().localScale;
                MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetDurabilityBarLabel").gameObject.GetComponent <TextMeshProUGUI>().text = robotWidgetDurabilityBarLabel.GetComponent <TextMeshProUGUI>().text;
                MASKED_ROBOT_WIDGET.GetComponent <RectTransform>().localScale = Vector3.one;
                MASKED_ROBOT_WIDGET.transform.position = robotWidget.transform.position;
                MASKED_ROBOT_WIDGET.SetActive(true);
                Part   robotPart = null;
                double robotPartRemainingDurability = 0, robotPartDurability = 0;
                for (int partIndex = 0; partIndex < numberOfWidgets; ++partIndex)
                {
                    Part part = (partIndex < parts.Count ? parts[partIndex] : attachments[partIndex - parts.Count]);
                    if (part.GetType() == this.partBeingPreviewed.GetType())
                    {
                        robotPart = part;
                        robotPartRemainingDurability = robotPart.getRemainingDurability();
                        robotPartDurability          = robotPart.getDurability();
                        break;
                    }
                }
                double[] differenceInStats = robotPart != null?robotPart.compareTo(this.partBeingPreviewed) : (new Blaster("", null, 0, null, Shape.SHAPES.CYLINDER, 0, 0, 0, 0, 0, 0)).compareTo(this.partBeingPreviewed);

                double tempRemainingDurability = this.remainingDurability - robotPartRemainingDurability + this.partBeingPreviewed.getRemainingDurability();
                double tempDurability          = this.durability - robotPartDurability + this.partBeingPreviewed.getDurability();
                MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetDurabilityBar").gameObject.GetComponent <RectTransform>().localScale  = new Vector3((float)(tempRemainingDurability / tempDurability), robotWidgetDurabilityBar.GetComponent <RectTransform>().localScale.y, 0);
                MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetDurabilityBarLabel").gameObject.GetComponent <TextMeshProUGUI>().text = ConfigurationCard.DURABILITY_BAR_LABEL_PREFIX + StringTools.formatString(tempRemainingDurability) + " / " + StringTools.formatString(tempDurability) + (differenceInStats != null && differenceInStats.Length > 0 ? " (" + applyStatDifferenceFormatting(differenceInStats[0], false) + " / " + applyStatDifferenceFormatting(differenceInStats[1], false) + ")" : "");
                GameObject maskedRobotWidgetStats = MASKED_ROBOT_WIDGET.transform.Find("MaskedRobotWidgetStats").gameObject;
                foreach (Transform child in maskedRobotWidgetStats.GetComponent <RectTransform>())
                {
                    GameObject.Destroy(child.gameObject);
                }
                for (int robotStatStringIndex = 0; robotStatStringIndex < robotStatStringLabels.Count; ++robotStatStringIndex)
                {
                    robotStatStringLabels[robotStatStringIndex].GetComponent <TextMeshProUGUI>().text = previewRobotStats[robotStatStringIndex];
                    GameObject partStat = GameObject.Instantiate(Resources.Load("Prefabs/PartStat") as GameObject);
                    partStat.GetComponent <TextMeshProUGUI>().text = previewRobotStats[robotStatStringIndex];
                    if (previewRobotStats[robotStatStringIndex].Contains(WEIGHT_STRING) && maxForceExceeded)
                    {
                        partStat.GetComponent <TextMeshProUGUI>().color = BAD_COLOR;
                    }
                    partStat.transform.SetParent(maskedRobotWidgetStats.GetComponent <RectTransform>());
                    partStat.transform.localPosition = new Vector3(partStat.transform.localPosition.x, partStat.transform.localPosition.y, 0);
                }
                break;

            case InventoryCard.MODES.EQUIPT_PART:
                MASKED_ROBOT_WIDGET.SetActive(false);
                for (int robotPartIndex = 0; robotPartIndex < parts.Count + attachments.Count; ++robotPartIndex)
                {
                    if (robotPartIndex < parts.Count && parts[robotPartIndex].GetType() == partToEquipt.GetType())
                    {
                        parts[robotPartIndex] = partToEquipt;
                        break;
                    }
                    else if (robotPartIndex >= parts.Count && attachments[robotPartIndex - parts.Count].GetType() == partToEquipt.GetType())
                    {
                        attachments[robotPartIndex - parts.Count] = (Attachment)partToEquipt;
                        break;
                    }
                    else if (robotPartIndex - parts.Count == attachments.Count - 1)
                    {
                        attachments.Add((Attachment)partToEquipt);
                    }
                }
                initialize();
                break;

            default:
                break;
            }
            this.mode = mode;
        }
    }