private void Update() { if (info != null) { icon.sprite = info.icon; selectButton.interactable = builder.HasProtein(info) && builder.HasRoom(); costField.text = info.proteinCost.ToString(); Color c = selectButton.targetGraphic.color; c.a = selectButton.interactable ? 1.0f : disabledAlpha; selectButton.targetGraphic.color = c; c = icon.color; c.a = selectButton.interactable ? 1.0f : disabledAlpha; icon.color = c; } }
// Update is called once per frame void Update() { rectTransform.position = Input.mousePosition; if (currentMode == Mode.Build) { container.gameObject.SetActive(hoverInfo != null); if (hoverInfo != null) { nameField.text = hoverInfo.cellName; descriptionField.text = hoverInfo.cellDescription; costField.text = "<color=red>" + hoverInfo.proteinCost.ToString() + " PROTEIN </color>"; if (builder.HasProtein(hoverInfo)) { if (builder.HasRoom()) { instructionsButton.color = canBuildColor; instructionsField.text = "CLICK TO PRODUCE"; } else { instructionsButton.color = cannotBuildColor; instructionsField.text = "-NOT ENOUGH ROOM-"; } } else { instructionsButton.color = cannotBuildColor; instructionsField.text = "-NOT ENOUGH RESOURCES-"; } } } if (currentMode == Mode.Destroy) { container.gameObject.SetActive(hoverInfo != null); if (hoverInfo != null) { nameField.text = hoverInfo.cellName; descriptionField.text = hoverInfo.cellDescription; costField.text = ""; if (!destroyer.InRangeToDestroy(hoverInfo)) { instructionsButton.color = cannotBuildColor; instructionsField.text = "TOO FAR TO DESTROY"; } else if (destroyer.IsLastSupportingCell(hoverInfo)) { instructionsButton.color = cannotBuildColor; instructionsField.text = "-CANNOT DESTROY CRITICAL FIBROBLAST-"; } else { instructionsButton.color = canBuildColor; instructionsField.text = "(WARNING!) CLICK TO DESTROY"; } if (Input.GetMouseButtonDown(0)) { destroyer.DestroyCell(hoverInfo); } } } if (currentMode == Mode.Other) { container.gameObject.SetActive(tooltippable != null); if (tooltippable != null) { nameField.text = tooltippable.titleString; descriptionField.text = tooltippable.descriptionString; instructionsButton.color = canBuildColor; instructionsField.text = tooltippable.instructionString; costField.text = ""; } } // Check for hovered item CheckHovered(); }