private void filterAttachmentParts() { STORE_PANEL.GetComponent <GridLayoutGroup>().constraintCount = STORE_ATTACHMENT_COLUMN_COUNT; STORE_PANEL.GetComponent <GridLayoutGroup>().cellSize = STORE_ATTACHMENT_CELL_SIZE; foreach (GameObject attachmentPartsRow in ATTACHMENT_PARTS_ROWS) { attachmentPartsRow.SetActive(true); attachmentPartsRow.transform.SetParent(STORE_PANEL); attachmentPartsRow.transform.localPosition = new Vector3(attachmentPartsRow.transform.localPosition.x, attachmentPartsRow.transform.localPosition.y, 0); attachmentPartsRow.transform.localScale = Vector3.one; } for (int partIndex = 0; partIndex < storeButtons.Count; ++partIndex) { for (int attachmentPartsRowIndex = 0; attachmentPartsRowIndex < ATTACHMENT_PARTS_ROWS_LABELS.Count; ++attachmentPartsRowIndex) { if (ATTACHMENT_PARTS_ROWS_LABELS[attachmentPartsRowIndex] == storeParts[partIndex].GetType().ToString()) { ATTACHMENT_PARTS_ROWS[attachmentPartsRowIndex].transform.localScale = Vector3.one; storeButtons[partIndex].SetActive(true); storeButtons[partIndex].transform.SetParent(ATTACHMENT_PARTS_ROWS[attachmentPartsRowIndex].transform.Find("PartsPanel")); storeButtons[partIndex].transform.localPosition = new Vector3(storeButtons[partIndex].transform.localPosition.x, storeButtons[partIndex].transform.localPosition.y, 0); storeButtons[partIndex].transform.localScale = Vector3.one; break; } } } foreach (GameObject attachmentPartsRow in ATTACHMENT_PARTS_ROWS) { if (attachmentPartsRow.transform.Find("PartsPanel").childCount == 0) { attachmentPartsRow.transform.SetParent(null); attachmentPartsRow.SetActive(false); } } }
private void filterParts(string filterPartType) { currentPartFilter = filterPartType; if (currentPartFilter == DEFAULT_STORE_FILTER) { foreach (GameObject attachmentPartsRow in ATTACHMENT_PARTS_ROWS) { attachmentPartsRow.transform.SetParent(null); attachmentPartsRow.SetActive(false); } filterFeaturedParts(); } else if (currentPartFilter == ATTACHMENT_PART_FILTER) { foreach (GameObject featuredPartsRow in FEATURED_PARTS_ROWS) { featuredPartsRow.transform.SetParent(null); featuredPartsRow.SetActive(false); } filterAttachmentParts(); } else { foreach (GameObject featuredPartsRow in FEATURED_PARTS_ROWS) { featuredPartsRow.transform.SetParent(null); featuredPartsRow.SetActive(false); } foreach (GameObject attachmentPartsRow in ATTACHMENT_PARTS_ROWS) { attachmentPartsRow.transform.SetParent(null); attachmentPartsRow.SetActive(false); } STORE_PANEL.GetComponent <GridLayoutGroup>().constraintCount = STORE_COLUMN_COUNT; STORE_PANEL.GetComponent <GridLayoutGroup>().cellSize = STORE_CELL_SIZE; for (int storeButtonIndex = 0; storeButtonIndex < storeButtons.Count; ++storeButtonIndex) { if (storeParts[storeButtonIndex].GetType().ToString() == filterPartType || (filterPartType == ATTACHMENT_PART_FILTER && storeParts[storeButtonIndex] is Attachment)) { storeButtons[storeButtonIndex].SetActive(true); storeButtons[storeButtonIndex].transform.SetParent(null); storeButtons[storeButtonIndex].transform.SetParent(STORE_PANEL); storeButtons[storeButtonIndex].transform.localPosition = new Vector3(storeButtons[storeButtonIndex].transform.localPosition.x, storeButtons[storeButtonIndex].transform.localPosition.y, 0); storeButtons[storeButtonIndex].transform.localScale = Vector3.one; } else { storeButtons[storeButtonIndex].transform.SetParent(null); storeButtons[storeButtonIndex].SetActive(false); } } } }
private void filterFeaturedParts() { STORE_PANEL.GetComponent <GridLayoutGroup>().constraintCount = STORE_FEATURED_COLUMN_COUNT; STORE_PANEL.GetComponent <GridLayoutGroup>().cellSize = STORE_FEATURED_CELL_SIZE; foreach (GameObject featuredPartsRow in FEATURED_PARTS_ROWS) { featuredPartsRow.SetActive(true); featuredPartsRow.transform.SetParent(STORE_PANEL); featuredPartsRow.transform.localPosition = new Vector3(featuredPartsRow.transform.localPosition.x, featuredPartsRow.transform.localPosition.y, 0); featuredPartsRow.transform.localScale = Vector3.one; } for (int partIndex = 0; partIndex < storeButtons.Count; ++partIndex) { int cost = PERFORMANCE_METRIC_CALCULATOR.calculateCost(storeParts[partIndex]); if (cost <= credits) { for (int featuredPartsRowIndex = 0; featuredPartsRowIndex < FEATURED_PARTS_ROWS_LABELS.Length; ++featuredPartsRowIndex) { if (FEATURED_PARTS_ROWS_LABELS[featuredPartsRowIndex] == storeParts[partIndex].GetType().ToString() || (storeParts[partIndex] is Attachment && FEATURED_PARTS_ROWS_LABELS[featuredPartsRowIndex] == "Attachment")) { FEATURED_PARTS_ROWS[featuredPartsRowIndex].transform.localScale = Vector3.one; storeButtons[partIndex].SetActive(true); storeButtons[partIndex].transform.SetParent(FEATURED_PARTS_ROWS[featuredPartsRowIndex].transform.Find("PartsPanel")); storeButtons[partIndex].transform.localPosition = new Vector3(storeButtons[partIndex].transform.localPosition.x, storeButtons[partIndex].transform.localPosition.y, 0); storeButtons[partIndex].transform.localScale = Vector3.one; break; } } } else { storeButtons[partIndex].SetActive(false); storeButtons[partIndex].transform.SetParent(null); } } foreach (GameObject featuredPartsRow in FEATURED_PARTS_ROWS) { if (featuredPartsRow.transform.Find("PartsPanel").childCount == 0) { featuredPartsRow.transform.SetParent(null); featuredPartsRow.SetActive(false); } } }