/** * <summary> * Select a given building * </summary> * * <param name="building"></param> * * <returns> * void * </returns> */ public static void SelectBuilding(GameObject building) { // Unselect previous building BuildingsManagerBehaviour.UnselectBuilding(); // Unselect units if (UnitsManagerBehaviour.SelectedUnits != null) { UnitsManagerBehaviour.UnselectGameObjects(); } // Unselect previous resource if (ResourcesManagerBehaviour.SelectedResource != null) { ResourcesManagerBehaviour.UnselectResource(); } BuildingBehaviour buildingBehaviour = building.GetComponent <BuildingBehaviour>(); buildingBehaviour.SetSelect(true); // Show info component panel Self.infoComponentPanel.SetActive(true); Self.infoComponentPanel .transform .Find("Single") .gameObject .SetActive(true); BuildingUI buildingUI = buildingBehaviour.GetUI() .GetComponent <BuildingUI>(); InfoComponentPanelUI infoComponentPanelUI = Self.infoComponentPanel.GetComponent <InfoComponentPanelUI>(); infoComponentPanelUI.SetName(building.name); infoComponentPanelUI.SetHealth(buildingBehaviour.GetHealth(), buildingBehaviour.GetMaxHealth()); infoComponentPanelUI.SetIcon(buildingUI.GetIcon()); // Show action component panel Self.actionComponentPanel.SetActive(true); // Set selected building BuildingsManagerBehaviour.SelectedBuilding = building; }
/** * <summary> * Refresh or update the selected building information * </summary> * * <returns> * void * </returns> */ public static void UpdateSelectedBuildingInfo() { if (!BuildingsManagerBehaviour.SelectedBuilding) { return; } BuildingBehaviour buildingBehaviour = BuildingsManagerBehaviour.SelectedBuilding .GetComponent <BuildingBehaviour>(); BuildingUI buildingUI = buildingBehaviour.GetUI() .GetComponent <BuildingUI>(); InfoComponentPanelUI infoComponentPanelUI = Self.infoComponentPanel.GetComponent <InfoComponentPanelUI>(); infoComponentPanelUI.SetName(BuildingsManagerBehaviour.SelectedBuilding.name); infoComponentPanelUI.SetHealth(buildingBehaviour.GetHealth(), buildingBehaviour.GetMaxHealth()); infoComponentPanelUI.SetIcon(buildingUI.GetIcon()); }