public void update(long credits, Part[] humanParts, Part[] robotParts, Color colorScheme, bool enableCreditsSpentAnimation) { this.credits = credits; this.humanParts = humanParts; this.robotParts = robotParts; this.colorScheme = colorScheme; this.enableCreditsSpentAnimation = enableCreditsSpentAnimation; if (STORE_CREDIT.GetComponent <TextMeshProUGUI>().color != this.colorScheme) { STORE_CREDIT.GetComponent <TextMeshProUGUI>().color = this.colorScheme; } if (base.enabled) { if (BUY_PART_BUTTON.activeSelf && BUY_PART_BUTTON.GetComponent <ButtonListener>().isClicked() && PERFORMANCE_METRIC_CALCULATOR.calculateCost(partBeingPreviewed) <= credits) { BUY_PART_BUTTON.GetComponent <ButtonListener>().resetClick(); mode = MODES.BUY_PART; partBeingBought = partBeingPreviewed; partBeingPreviewed = null; BUY_PART_BUTTON.SetActive(false); credits -= PERFORMANCE_METRIC_CALCULATOR.calculateCost(partBeingBought); updateCredits(); if (enableCreditsSpentAnimation) { STORE_CREDITS_SPENT.SetActive(true); STORE_CREDITS_SPENT.transform.localPosition = STORE_CREDITS_SPENT_HOME_POSITION; Color storeCreditsSpentColor = STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color; STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color = new Color(storeCreditsSpentColor.r, storeCreditsSpentColor.g, storeCreditsSpentColor.b, 1); STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().text = "-" + PERFORMANCE_METRIC_CALCULATOR.calculateCost(partBeingBought).ToString(); } } if (Input.GetMouseButton(0) && mode == MODES.PREVIEW_PART && !BUY_PART_BUTTON.GetComponent <ButtonListener>().isMouseOver()) { mode = MODES.VIEW_PART_STATS; partBeingPreviewed = null; partBeingBought = null; BUY_PART_BUTTON.SetActive(false); } if ((STORE_PANEL.offsetMax.y - STORE_PANEL.offsetMin.y) > (STORE_CONTAINER.offsetMax.y - STORE_CONTAINER.offsetMin.y)) { SCROLLBAR.SetActive(true); SCROLL_RECT.vertical = true; } else { SCROLLBAR.SetActive(false); SCROLL_RECT.vertical = false; } for (int storeButtonIndex = 0; storeButtonIndex < storeButtons.Count; ++storeButtonIndex) { ButtonListener buttonListener = storeButtons[storeButtonIndex].GetComponent <ButtonListener>(); if ((buttonListener.isClicked()) && mode != MODES.PREVIEW_PART) { bool ignoreClick = false; foreach (Part part in humanParts) { if (storeParts[storeButtonIndex].getID() == part.getID()) { ignoreClick = true; break; } } if (!ignoreClick) { if (buttonListener.isClicked()) { mode = MODES.PREVIEW_PART; partInfo.SetActive(false); partBeingPreviewed = storeParts[storeButtonIndex]; BUY_PART_BUTTON.SetActive(true); BUY_PART_BUTTON.GetComponent <UnityEngine.UI.Image>().color = (PERFORMANCE_METRIC_CALCULATOR.calculateCost(partBeingPreviewed) <= credits ? colorScheme : UNAFFORDABLE_COLOR); } buttonListener.resetClick(); break; } buttonListener.resetClick(); } if (buttonListener.isMouseOver() && mode != MODES.PREVIEW_PART) { Part robotPart = null; foreach (Part part in robotParts) { if (part.GetType() == storeParts[storeButtonIndex].GetType()) { robotPart = part; break; } } Vector2 position; RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("BuildHubCanvas").GetComponent <RectTransform>(), Input.mousePosition, Camera.main, out position); position.x += partInfo.GetComponent <RectTransform>().sizeDelta.x / 2; partInfo.transform.localPosition = position; partType.GetComponent <TextMeshProUGUI>().text = storeParts[storeButtonIndex].GetType().ToString(); double[] differenceInStats = robotPart != null?robotPart.compareTo(storeParts[storeButtonIndex]) : (new Blaster("", null, 0, null, Shape.SHAPES.CYLINDER, 0, 0, 0, 0, 0, 0)).compareTo(storeParts[storeButtonIndex]); foreach (GameObject partStat in partStatsList) { GameObject.Destroy(partStat); } partStatsList.Clear(); GameObject durabilityPartStat = GameObject.Instantiate(Resources.Load("Prefabs/PartStat") as GameObject); durabilityPartStat.GetComponent <TextMeshProUGUI>().text = "Durability: " + StringTools.formatString(storeParts[storeButtonIndex].getDurability()) + (differenceInStats.Length > 0 ? " (" + applyStatDifferenceFormatting(differenceInStats[1], false) + ")": ""); durabilityPartStat.transform.SetParent(partStats.GetComponent <RectTransform>()); durabilityPartStat.transform.localPosition = new Vector3(durabilityPartStat.transform.localPosition.x, durabilityPartStat.transform.localPosition.y, 0); partStatsList.Add(durabilityPartStat); string[] partStatStrings = storeParts[storeButtonIndex].getStatStrings(); for (int partStatIndex = 0; partStatIndex < partStatStrings.Length; ++partStatIndex) { GameObject partStat = GameObject.Instantiate(Resources.Load("Prefabs/PartStat") as GameObject); string differenceInStatString = ""; int differenceInStatsIndex = partStatIndex + 2; if (!(storeParts[storeButtonIndex] is Attachment)) { differenceInStatString = applyStatDifferenceFormatting(differenceInStats[differenceInStatsIndex], differenceInStatsIndex == 2); } else if (differenceInStats != null && differenceInStats.Length > 0) { if (differenceInStatsIndex == 3 || (differenceInStatsIndex >= 8 && differenceInStatsIndex < 11)) { differenceInStatsIndex = -1; } else if (differenceInStatsIndex > 3 && differenceInStatsIndex < 8) { differenceInStatsIndex -= 1; } else if (differenceInStatsIndex == 11) { differenceInStatsIndex -= 4; } if (differenceInStatsIndex != -1) { if (differenceInStatsIndex >= 3 && differenceInStatsIndex <= 6) { differenceInStats[differenceInStatsIndex] /= 1000; } differenceInStatString = applyStatDifferenceFormatting(differenceInStats[differenceInStatsIndex], differenceInStatsIndex == 2 || differenceInStatsIndex == 3 || differenceInStatsIndex == 4 || differenceInStatsIndex == 6); } } partStat.GetComponent <TextMeshProUGUI>().text = partStatStrings[partStatIndex] + (differenceInStatString != "" ? " (" + differenceInStatString + ")" : ""); partStat.transform.SetParent(partStats.GetComponent <RectTransform>()); partStat.transform.localPosition = new Vector3(partStat.transform.localPosition.x, partStat.transform.localPosition.y, 0); partStatsList.Add(partStat); } partInfo.SetActive(true); break; } else { partInfo.SetActive(false); } } bool switchTabs = false; foreach (GameObject tab in STORE_TABS) { if (tab.GetComponent <ButtonListener>().isClicked() && currentPartFilter != tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text) { switchTabs = true; filterParts(tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text); updateSorting(); break; } else { tab.GetComponent <ButtonListener>().resetClick(); } } foreach (GameObject featuredPartsRow in FEATURED_PARTS_ROWS) { if (featuredPartsRow.GetComponent <ButtonListener>().isClicked()) { switchTabs = true; string allPartsButtonLabelText = featuredPartsRow.transform.Find("AllParts").Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text; foreach (GameObject tab in STORE_TABS) { if (allPartsButtonLabelText.Contains(tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text)) { tab.GetComponent <ButtonListener>().click(); break; } } featuredPartsRow.GetComponent <ButtonListener>().resetClick(); filterParts(allPartsButtonLabelText.Substring(allPartsButtonLabelText.IndexOf(" ") + 1, allPartsButtonLabelText.LastIndexOf(" ") - (allPartsButtonLabelText.IndexOf(" ") + 1) - 1)); updateSorting(); break; } else { featuredPartsRow.GetComponent <ButtonListener>().resetClick(); } } if (switchTabs) { foreach (GameObject tab in STORE_TABS) { if (tab.GetComponent <ButtonListener>().isClicked()) { tab.GetComponent <ButtonListener>().resetClick(); tab.GetComponent <UnityEngine.UI.Image>().color = ACTIVE_TAB_COLOR; } else { tab.GetComponent <UnityEngine.UI.Image>().color = INACTIVE_TAB_COLOR; } } } if (currentSort != STORE_SORT.GetComponent <TMP_Dropdown>().value) { currentSort = STORE_SORT.GetComponent <TMP_Dropdown>().value; applySorting(); } if (enableCreditsSpentAnimation && STORE_CREDITS_SPENT.activeSelf) { Vector3 position = STORE_CREDITS_SPENT.transform.localPosition; STORE_CREDITS_SPENT.transform.localPosition = new Vector3(position.x, position.y + STORE_CREDITS_SPENT_ANIMATION_POSITION_SPEED, position.z); Color storeCreditsSpentColor = STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color; STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color = new Color(storeCreditsSpentColor.r, storeCreditsSpentColor.g, storeCreditsSpentColor.b, storeCreditsSpentColor.a - STORE_CREDITS_SPENT_ANIMATION_COLOR_SPEED); if (STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color.a <= 0) { STORE_CREDITS_SPENT.SetActive(false); } } else { if (STORE_CREDITS_SPENT.transform.localPosition != STORE_CREDITS_SPENT_HOME_POSITION) { STORE_CREDITS_SPENT.transform.localPosition = STORE_CREDITS_SPENT_HOME_POSITION; } Color storeCreditsSpentColor = STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color; if (STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color.a != 1) { STORE_CREDITS_SPENT.GetComponent <TextMeshProUGUI>().color = new Color(storeCreditsSpentColor.r, storeCreditsSpentColor.g, storeCreditsSpentColor.b, 1); } if (STORE_CREDITS_SPENT.activeInHierarchy) { STORE_CREDITS_SPENT.SetActive(false); } } } }
public void update(Robot[] myRobots, Part[] humanRobotParts, long credits, Color colorScheme) { this.credits = credits; if (this.colorScheme != colorScheme) { this.colorScheme = colorScheme; NEW_ROBOT_BUTTON.GetComponent <UnityEngine.UI.Image>().color = this.colorScheme; MY_ROBOTS_CREDIT.GetComponent <TextMeshProUGUI>().color = this.colorScheme; } if (this.myRobots.Count != myRobots.Length) { this.myRobots.Clear(); this.myRobots.AddRange(myRobots); } if (this.humanRobotParts.Count != humanRobotParts.Length) { this.humanRobotParts.Clear(); this.humanRobotParts.AddRange(humanRobotParts); } if (base.enabled) { if ((mode != MODES.NEW_ROBOT && (myRobots == null || myRobots.Length == 0)) || (NEW_ROBOT_BUTTON.activeSelf && NEW_ROBOT_BUTTON.GetComponent <ButtonListener>().isClicked())) { NEW_ROBOT_BUTTON.GetComponent <ButtonListener>().resetClick(); mode = MODES.NEW_ROBOT; Part[] parts = null; if (myRobots != null && myRobots.Length > 0) { parts = myRobots[0].getParts(); } else { List <Part> defaultParts = new List <Part>(); defaultParts.Add(findFirstPartOfType(this.humanRobotParts, typeof(Head))); defaultParts.Add(findFirstPartOfType(this.humanRobotParts, typeof(Body))); defaultParts.Add(findFirstPartOfType(this.humanRobotParts, typeof(Mobility))); defaultParts.Add(findFirstPartOfType(this.humanRobotParts, typeof(Blaster))); parts = defaultParts.ToArray(); } List <Part> newParts = new List <Part>(); foreach (Part part in parts) { newParts.Add(part.clone(true)); } newRobot = new Robot("", true, true, newParts.ToArray()); robotBeingPreviewed = null; } else if (CANCEL_REMOVE_ROBOTS_BUTTON.GetComponent <ButtonListener>().isClicked()) { mode = MODES.VIEW_MY_ROBOTS_STATS; CANCEL_REMOVE_ROBOTS_BUTTON.GetComponent <ButtonListener>().resetClick(); REMOVE_ROBOTS_BUTTON.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text = REMOVE_ROBOTS_TEXT; CANCEL_REMOVE_ROBOTS_BUTTON.SetActive(false); robotsToRemove = new List <Robot>(); selectedRobotIndicesToRemove = new List <int>(); foreach (GameObject robotButton in myRobotsButtons) { robotButton.transform.Find("SelectionIndicator").gameObject.SetActive(false); } } else if (REMOVE_ROBOTS_BUTTON.GetComponent <ButtonListener>().isClicked()) { REMOVE_ROBOTS_BUTTON.GetComponent <ButtonListener>().resetClick(); switch (mode) { case MODES.REMOVE_ROBOTS: if (selectedRobotIndicesToRemove.Count > 0) { mode = MODES.VIEW_MY_ROBOTS_STATS; REMOVE_ROBOTS_BUTTON.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text = REMOVE_ROBOTS_TEXT; CANCEL_REMOVE_ROBOTS_BUTTON.SetActive(false); robotsToRemove = new List <Robot>(); foreach (int robotIndex in selectedRobotIndicesToRemove) { robotsToRemove.Add(this.myRobots[robotIndex]); this.myRobots.RemoveAt(robotIndex); GameObject.Destroy(myRobotsButtons[robotIndex]); myRobotsButtons.RemoveAt(robotIndex); } selectedRobotIndicesToRemove = new List <int>(); } break; default: mode = MODES.REMOVE_ROBOTS; REMOVE_ROBOTS_BUTTON.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text = REMOVE_SELECTED_ROBOTS_TEXT; REMOVE_ROBOTS_BUTTON.GetComponent <UnityEngine.UI.Image>().color = CANCEL_REMOVE_ROBOTS_BUTTON.GetComponent <UnityEngine.UI.Image>().color; CANCEL_REMOVE_ROBOTS_BUTTON.SetActive(true); robotsToRemove = new List <Robot>(); selectedRobotIndicesToRemove = new List <int>(); break; } } if ((MY_ROBOTS_PANEL.offsetMax.y - MY_ROBOTS_PANEL.offsetMin.y) > (MY_ROBOTS_CONTAINER.offsetMax.y - MY_ROBOTS_CONTAINER.offsetMin.y)) { SCROLLBAR_OBJECT.SetActive(true); SCROLL_RECT.vertical = true; } else { SCROLLBAR_OBJECT.SetActive(false); SCROLL_RECT.vertical = false; } for (int myRobotsButtonIndex = 0; myRobotsButtonIndex < myRobotsButtons.Count; ++myRobotsButtonIndex) { ButtonListener buttonListener = myRobotsButtons[myRobotsButtonIndex].GetComponent <ButtonListener>(); if (buttonListener.isClicked()) { buttonListener.resetClick(); switch (mode) { case MODES.VIEW_MY_ROBOTS_STATS: mode = MODES.PICK_ROBOT; myRobotsInfo.SetActive(false); robotBeingPicked = myRobots[myRobotsButtonIndex]; break; case MODES.REMOVE_ROBOTS: if (!selectedRobotIndicesToRemove.Contains(myRobotsButtonIndex)) { selectedRobotIndicesToRemove.Add(myRobotsButtonIndex); myRobotsButtons[myRobotsButtonIndex].transform.Find("SelectionIndicator").gameObject.SetActive(true); REMOVE_ROBOTS_BUTTON.GetComponent <UnityEngine.UI.Image>().color = REMOVE_ROBOTS_BUTTON_COLOR; } else { selectedRobotIndicesToRemove.Remove(myRobotsButtonIndex); myRobotsButtons[myRobotsButtonIndex].transform.Find("SelectionIndicator").gameObject.SetActive(false); if (selectedRobotIndicesToRemove.Count == 0) { REMOVE_ROBOTS_BUTTON.GetComponent <UnityEngine.UI.Image>().color = CANCEL_REMOVE_ROBOTS_BUTTON.GetComponent <UnityEngine.UI.Image>().color; } } break; default: break; } break; } if (buttonListener.isMouseOver() && mode == MODES.VIEW_MY_ROBOTS_STATS) { robotBeingPreviewed = myRobots[myRobotsButtonIndex]; Vector2 position; RectTransformUtility.ScreenPointToLocalPointInRectangle(GameObject.Find("BuildHubCanvas").GetComponent <RectTransform>(), Input.mousePosition, Camera.main, out position); position.x += myRobotsInfo.GetComponent <RectTransform>().sizeDelta.x / 2; myRobotsInfo.transform.localPosition = position; myRobotsName.GetComponent <TextMeshProUGUI>().text = myRobots[myRobotsButtonIndex].getName(); foreach (GameObject partStat in myRobotsStatsList) { GameObject.Destroy(partStat); } myRobotsStatsList.Clear(); robotWidgetDurabilityBar.GetComponent <RectTransform>().localScale = new Vector3((float)(myRobots[myRobotsButtonIndex].getRemainingDurability() / myRobots[myRobotsButtonIndex].getDurability()), robotWidgetDurabilityBar.GetComponent <RectTransform>().localScale.y, 0); robotWidgetDurabilityBarLabel.GetComponent <TextMeshProUGUI>().text = DURABILITY_BAR_LABEL_PREFIX + StringTools.formatString(myRobots[myRobotsButtonIndex].getRemainingDurability()) + " / " + StringTools.formatString(myRobots[myRobotsButtonIndex].getDurability()); string[] myRobotsStatStrings = myRobots[myRobotsButtonIndex].getRobotStatStrings(); for (int myRobotsStatIndex = 0; myRobotsStatIndex < myRobotsStatStrings.Length; ++myRobotsStatIndex) { GameObject myRobotsStat = GameObject.Instantiate(Resources.Load("Prefabs/PartStat") as GameObject); myRobotsStat.GetComponent <TextMeshProUGUI>().text = myRobotsStatStrings[myRobotsStatIndex]; myRobotsStat.transform.SetParent(myRobotsStats.GetComponent <RectTransform>()); myRobotsStat.transform.localPosition = new Vector3(myRobotsStat.transform.localPosition.x, myRobotsStat.transform.localPosition.y, 0); myRobotsStatsList.Add(myRobotsStat); } myRobotsInfo.SetActive(true); break; } else { myRobotsInfo.SetActive(false); } } if (currentSort != MY_ROBOTS_SORT.GetComponent <TMP_Dropdown>().value) { currentSort = MY_ROBOTS_SORT.GetComponent <TMP_Dropdown>().value; applySorting(); } } }
public void update(long credits, Part[] humanParts, Part[] robotParts) { this.credits = credits; if (this.humanParts.Length != humanParts.Length || this.robotParts.Length != robotParts.Length) { this.humanParts = humanParts; this.robotParts = robotParts; initialize(); } if (base.enabled) { if (Input.GetMouseButton(0) && mode == MODES.PREVIEW_PART) { mode = MODES.VIEW_PART_STATS; partBeingPreviewed = null; partBeingEquipt = null; MASKED_INVENTORY_PART_BUTTON.SetActive(false); } if ((PARTS_PANEL.offsetMax.y - PARTS_PANEL.offsetMin.y) > (PARTS_CONTAINER.offsetMax.y - PARTS_CONTAINER.offsetMin.y)) { SCROLLBAR_OBJECT.SetActive(true); SCROLL_RECT.vertical = true; } else { SCROLLBAR_OBJECT.SetActive(false); SCROLL_RECT.vertical = false; } for (int partButtonIndex = 0; partButtonIndex < partButtons.Count; ++partButtonIndex) { ButtonListener buttonListener = partButtons[partButtonIndex].GetComponent <ButtonListener>(); if ((buttonListener.isClicked() || buttonListener.isControlClicked()) && mode != MODES.PREVIEW_PART) { bool ignoreClick = false; foreach (Part part in robotParts) { if (humanParts[partButtonIndex].getID() == part.getID()) { ignoreClick = true; break; } } if (!ignoreClick) { if (buttonListener.isClicked()) { mode = MODES.PREVIEW_PART; partInfo.SetActive(false); partBeingPreviewed = humanParts[partButtonIndex]; Texture2D partIcon = humanParts[partButtonIndex].getIcon(); MASKED_INVENTORY_PART_BUTTON.transform.Find("Icon").gameObject.GetComponent <UnityEngine.UI.Image>().sprite = Sprite.Create(partIcon, new Rect(0, 0, partIcon.width, partIcon.height), new Vector2(0.5f, 0.5f), 100); MASKED_INVENTORY_PART_BUTTON.GetComponent <RectTransform>().localScale = Vector3.one; MASKED_INVENTORY_PART_BUTTON.transform.position = partButtons[partButtonIndex].transform.position; MASKED_INVENTORY_PART_BUTTON.SetActive(true); } else if (buttonListener.isControlClicked()) { mode = MODES.EQUIPT_PART; partBeingEquipt = humanParts[partButtonIndex]; } buttonListener.resetClick(); break; } buttonListener.resetClick(); } if (buttonListener.isMouseOver() && mode != MODES.PREVIEW_PART) { Part robotPart = null; foreach (Part part in robotParts) { if (part.GetType() == humanParts[partButtonIndex].GetType()) { robotPart = part; break; } } float positionY = Input.mousePosition.y / (UnityEngine.Screen.height) * GameObject.Find("BuildHubCanvas").GetComponent <RectTransform>().sizeDelta.y - partInfo.GetComponent <RectTransform>().sizeDelta.y * 2; positionY = Mathf.Clamp(positionY, -partInfo.GetComponent <RectTransform>().sizeDelta.y * 2, GameObject.Find("BuildHubCanvas").GetComponent <RectTransform>().sizeDelta.y - partInfo.GetComponent <RectTransform>().sizeDelta.y * 2); partInfo.transform.localPosition = new Vector3(partInfo.transform.localPosition.x, positionY, partInfo.transform.localPosition.z); partType.GetComponent <TextMeshProUGUI>().text = humanParts[partButtonIndex].GetType().ToString(); double[] differenceInStats = (robotPart != null ? robotPart.compareTo(humanParts[partButtonIndex]) : new double[0]); durabilityBar.GetComponent <RectTransform>().localScale = new Vector3((humanParts[partButtonIndex].getDurability() > 0 ? (float)(humanParts[partButtonIndex].getRemainingDurability() / humanParts[partButtonIndex].getDurability()) : 0), durabilityBar.GetComponent <RectTransform>().localScale.y, 0); durabilityBarLabel.GetComponent <TextMeshProUGUI>().text = ConfigurationCard.DURABILITY_BAR_LABEL_PREFIX + StringTools.formatString(humanParts[partButtonIndex].getRemainingDurability()) + " / " + StringTools.formatString(humanParts[partButtonIndex].getDurability()) + (differenceInStats != null && differenceInStats.Length > 0 ? " (" + applyStatDifferenceFormatting(differenceInStats[0], false) + " / " + applyStatDifferenceFormatting(differenceInStats[1], false) + ")" : ""); foreach (GameObject partStat in partStatsList) { GameObject.Destroy(partStat); } partStatsList.Clear(); string[] partStatStrings = humanParts[partButtonIndex].getStatStrings(); for (int partStatIndex = 0; partStatIndex < partStatStrings.Length; ++partStatIndex) { GameObject partStat = GameObject.Instantiate(Resources.Load("Prefabs/PartStat") as GameObject); string differenceInStatString = ""; int differenceInStatsIndex = partStatIndex + 2; if (!(humanParts[partButtonIndex] is Attachment)) { differenceInStatString = applyStatDifferenceFormatting(differenceInStats[differenceInStatsIndex], differenceInStatsIndex == 2); } else if (differenceInStats != null && differenceInStats.Length > 0) { if (differenceInStatsIndex == 3 || (differenceInStatsIndex >= 8 && differenceInStatsIndex < 11)) { differenceInStatsIndex = -1; } else if (differenceInStatsIndex > 3 && differenceInStatsIndex < 8) { differenceInStatsIndex -= 1; } else if (differenceInStatsIndex == 11) { differenceInStatsIndex -= 4; } if (differenceInStatsIndex != -1) { if (differenceInStatsIndex >= 3 && differenceInStatsIndex <= 6) { differenceInStats[differenceInStatsIndex] /= 1000; } differenceInStatString = applyStatDifferenceFormatting(differenceInStats[differenceInStatsIndex], differenceInStatsIndex == 2 || differenceInStatsIndex == 3 || differenceInStatsIndex == 4 || differenceInStatsIndex == 6); } } partStat.GetComponent <TextMeshProUGUI>().text = partStatStrings[partStatIndex] + (differenceInStatString != "" ? " (" + differenceInStatString + ")" : ""); partStat.transform.SetParent(partStats.GetComponent <RectTransform>()); partStat.transform.localPosition = new Vector3(partStat.transform.localPosition.x, partStat.transform.localPosition.y, 0); partStatsList.Add(partStat); } partInfo.SetActive(true); break; } else { partInfo.SetActive(false); } } bool switchTabs = false; foreach (GameObject tab in PART_TABS) { if (tab.GetComponent <ButtonListener>().isClicked() && currentPartFilter != tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text) { switchTabs = true; filterParts(tab.transform.Find("Label").gameObject.GetComponent <TextMeshProUGUI>().text); updateSorting(); break; } else { tab.GetComponent <ButtonListener>().resetClick(); } } if (switchTabs) { foreach (GameObject tab in PART_TABS) { if (tab.GetComponent <ButtonListener>().isClicked()) { tab.GetComponent <ButtonListener>().resetClick(); tab.GetComponent <UnityEngine.UI.Image>().color = ACTIVE_TAB_COLOR; } else { tab.GetComponent <UnityEngine.UI.Image>().color = INACTIVE_TAB_COLOR; } } } if (currentSort != INVENTORY_SORT.GetComponent <TMP_Dropdown>().value) { currentSort = INVENTORY_SORT.GetComponent <TMP_Dropdown>().value; applySorting(); } } }