public void OpenHexWindow(Hex h) { SwitchBuildmode(false); selectedStats = h.hexStats; selectedPosition = h.hexPosition; selectedHex = h; var affectionsList = new bool?[6] { null, null, null, null, null, null }; FillStatsPanel(affectionsList); WriteBuildingInfo(h.type, nameField, descriptionField); var hs = h.hexStats; if (hs.maxPersonnel == 0) { workersPanel.SetActive(false); } else { int pi = hs.personnelInvolved, mi = hs.maxPersonnel; workersPanel_label.text = pi.ToString() + " / " + mi.ToString(); workersPanel_minusButton.interactable = (pi != 0); workersPanel_plusButton.interactable = (pi != mi); workersPanel.SetActive(true); } if (!constructionWindow.activeSelf) { constructionWindow.SetActive(true); } }
private void RedrawConstructionWindow() { RecalculateAvailabilityMask(); int selected = (int)selectedType; bool buildingAvailable = availabilityMask[selected], buildConditionsMet = true; for (int i = 0; i < (int)HexType.TotalCount; i++) { if (availabilityMask[i]) { buildingButtons[i].GetComponent <Image>().color = i == selected ? Color.cyan : Color.white; } else { buildingButtons[i].GetComponent <Image>().color = Color.grey; } } selectedStats = new HexBuildingStats(selectedType, true); #region left panel bool?[] affectionsList; selectedStats.ApplyNeighboursAffection(hexBuilder.GetNeighboursHexTypes(selectedPosition), out affectionsList); FillStatsPanel(affectionsList); //-conditions if (buildingAvailable) { conditionLine0.gameObject.SetActive(false); conditionLine1.gameObject.SetActive(false); } else { bool?a; bool?b; Text t; CheckBuildingConditions(selectedType, out a, out b); if (a == null) { conditionLine0.gameObject.SetActive(false); } else { if (a == true) { conditionLine0.GetChild(0).GetComponent <RawImage>().uvRect = taskCompletedRect; t = conditionLine0.GetChild(1).GetComponent <Text>(); t.color = Color.grey; } else { conditionLine0.GetChild(0).GetComponent <RawImage>().uvRect = taskIncompletedRect; t = conditionLine0.GetChild(1).GetComponent <Text>(); t.color = Color.white; } WriteConditionsText(t, selectedType, 0); conditionLine0.gameObject.SetActive(true); } if (b == null) { conditionLine1.gameObject.SetActive(false); } else { if (b == true) { conditionLine1.GetChild(0).GetComponent <RawImage>().uvRect = taskCompletedRect; t = conditionLine1.GetChild(1).GetComponent <Text>(); t.color = Color.grey; } else { conditionLine1.GetChild(0).GetComponent <RawImage>().uvRect = taskIncompletedRect; t = conditionLine1.GetChild(1).GetComponent <Text>(); t.color = Color.white; } WriteConditionsText(t, selectedType, 1); conditionLine1.gameObject.SetActive(true); } buildConditionsMet = (a == null) || ((a == true) & ((b == null) | (b == true))); #endregion } //right panel: { WriteBuildingInfo(selectedType, nameField, descriptionField); var cost = selectedStats.GetCost(); int rcount = cost.GetLength(0), rid, costConditionsMet = 0; GameObject g; Transform t; Text label; Storage storage = colony.storage; ResourceContainer rc; void FillCostString(int i) { g = costLines[i]; rc = cost[i]; rid = rc.resourceID; t = g.transform; t.GetChild(0).GetComponent <RawImage>().uvRect = ResourceType.GetResourceIconRect(rid); label = t.GetChild(1).GetComponent <Text>(); label.text = ((int)rc.volume).ToString() + ' ' + Localization.GetResourceName(rid); if (storage.GetResourceCount(rid) >= rc.volume) { label.color = Color.white; costConditionsMet++; } else { label.color = Color.red; } g.SetActive(true); } FillCostString(0); FillCostString(1); FillCostString(2); if (rcount > 3) { FillCostString(3); if (rcount > 4) { FillCostString(4); } else { costLines[4].gameObject.SetActive(false); } } else { costLines[3].gameObject.SetActive(false); costLines[4].gameObject.SetActive(false); } if (buildConditionsMet & (costConditionsMet == rcount) & buildingAvailable == true) { buildButton.interactable = true; buildButton.GetComponentInChildren <Text>().color = Color.white; } else { buildButton.interactable = false; buildButton.GetComponentInChildren <Text>().color = Color.grey; } } }