1+ using ExitGames . Client . Photon . StructWrapping ;
12using UnityEngine ;
23using UnityEngine . UIElements ;
4+ using BuildingPlacement . Buildings ;
35
46namespace UISystem
57{
@@ -9,17 +11,22 @@ public class BuildingHUDController : GameHUDController
911 private Button hangarButton ;
1012 private Button energyTowerButton ;
1113
14+
15+ #region Main Station Details
16+ private VisualElement mainStationDetailsPanel ;
17+ private Label mainStationNameLabel ;
18+ private Label mainStationHealthLabel ;
19+
20+ private Building currentlySelectedBuilding ;
21+ #endregion
22+
1223 protected override void OnEnable ( )
1324 {
1425 base . OnEnable ( ) ;
1526
16- uiDocument = GetComponent < UIDocument > ( ) ;
17- if ( uiDocument == null )
18- {
19- Debug . LogError ( "Bu objede UIDocument bileşeni bulunamadı!" , this ) ;
20- return ;
21- }
22- var root = uiDocument . rootVisualElement ;
27+ mainStationDetailsPanel = root . Q < VisualElement > ( "main-station-details-panel" ) ;
28+ mainStationNameLabel = mainStationDetailsPanel . Q < Label > ( "build-type-label" ) ;
29+ mainStationHealthLabel = mainStationDetailsPanel . Q < Label > ( "building-health-label" ) ;
2330
2431 mainStationButton = root . Q < Button > ( "main-station-button" ) ;
2532 hangarButton = root . Q < Button > ( "hangar-button" ) ;
@@ -28,6 +35,8 @@ protected override void OnEnable()
2835 mainStationButton . clicked += OnMainStationClicked ;
2936 hangarButton . clicked += OnHangarClicked ;
3037 energyTowerButton . clicked += OnEnergyTowerClicked ;
38+
39+ HideBuildingDetails ( ) ;
3140 }
3241
3342 protected override void OnDisable ( )
@@ -39,6 +48,37 @@ protected override void OnDisable()
3948 energyTowerButton . clicked -= OnEnergyTowerClicked ;
4049 }
4150
51+ protected override void Update ( )
52+ {
53+ base . Update ( ) ;
54+
55+ if ( currentlySelectedBuilding != null )
56+ {
57+ RefreshVehicleDetails ( ) ;
58+ }
59+ }
60+
61+ private void RefreshVehicleDetails ( )
62+ {
63+ var status = currentlySelectedBuilding . GetBuildingStatus ( ) ;
64+ string buildingName = status . Item1 ;
65+ string health = status . Item2 . ToString ( "F1" ) ;
66+ mainStationNameLabel . text = buildingName ;
67+ mainStationHealthLabel . text = "Health: " + health ;
68+ }
69+
70+ public void HideBuildingDetails ( )
71+ {
72+ currentlySelectedBuilding = null ;
73+ mainStationDetailsPanel . style . display = DisplayStyle . None ;
74+ }
75+
76+ public void ShowBuildingDetails ( Building buildingToShow )
77+ {
78+ currentlySelectedBuilding = buildingToShow ;
79+ mainStationDetailsPanel . style . display = DisplayStyle . Flex ;
80+ }
81+
4282 private void OnBuildingButtonClicked ( string buildingName )
4383 {
4484 if ( inputController != null )
0 commit comments