ui Changes
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c347a40ca3c44cf4da082942f26de978
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class TopPanel : MonoBehaviour
|
||||
{
|
||||
private Label _timeLabel;
|
||||
private Label _moneyLabel;
|
||||
private Label _locationLabel;
|
||||
private VisualElement _energy;
|
||||
private VisualElement _food;
|
||||
|
||||
void Start()
|
||||
{
|
||||
GameManager.Instance.Time.OnMinuteChanged -= UpdateTime;
|
||||
GameManager.Instance.Time.OnMinuteChanged += UpdateTime;
|
||||
|
||||
var root = GetComponent<UIDocument>().rootVisualElement;
|
||||
_timeLabel = root.Q<Label>("TimeLabel");
|
||||
_locationLabel= root.Q<Label>("LocationLabel");
|
||||
_moneyLabel = root.Q<Label>("MoneyLabel");
|
||||
|
||||
_energy = root.Q<VisualElement>("EnergyProgressFill");
|
||||
_food = root.Q<VisualElement>("HungerProgressFill");
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameManager.Instance.Time.OnMinuteChanged -= UpdateTime;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_moneyLabel.text = $"${(Player.Instance.Stats[StatsId.Money] as INumericStat).Value}";
|
||||
_locationLabel.text= $"{(Player.Instance.Stats[StatsId.LocationName] as IStringStat).Value}";
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
if (_timeLabel != null)
|
||||
{
|
||||
_timeLabel.text = $"{GameManager.Instance.Time.CurrentTime.GetDayName()} {GameManager.Instance.Time.CurrentTime.ToString(@"hh\:mm")} day ({GameManager.Instance.Time.CurrentTime.Days})";
|
||||
}
|
||||
|
||||
//progressBarFill.style.width = new Length(progress * 100, LengthUnit.Percent);
|
||||
_energy.style.width = new Length((Player.Instance.Stats[StatsId.Energy] as INumericStat).Value , LengthUnit.Percent);
|
||||
_food.style.width = new Length((Player.Instance.Stats[StatsId.Food] as INumericStat).Value, LengthUnit.Percent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b12a25de2b34933489e52900d32221dd
|
||||
@@ -0,0 +1,6 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&guid=755fc3f2b04b5014794dec9f2787b86e&type=3#progressBar" />
|
||||
<ui:VisualElement name="VisualElement">
|
||||
<ui:Button text="Button" style="border-top-left-radius: 20px; border-top-right-radius: 20px; border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; background-color: rgb(255, 255, 255); color: rgb(0, 2, 255); width: 150px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 257b45a55d104c846b4c2a03096e6afa
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -8,14 +8,14 @@
|
||||
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&guid=755fc3f2b04b5014794dec9f2787b86e&type=3#progressBar" />
|
||||
<ui:VisualElement name="icon" class="progress-icon" style="background-image: url("project://database/Assets/3dAssets/Textures/EnergyIcon.png?fileID=2800000&guid=dfe1a973babd6cc4bb1a418ed2f3562e&type=3#EnergyIcon");" />
|
||||
<ui:VisualElement name="progressBarContainer" class="progress-bar-container">
|
||||
<ui:VisualElement name="progressFill" class="progress-bar-fill" />
|
||||
<ui:VisualElement name="EnergyProgressFill" class="progress-bar-fill" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="HungerProgress" template="progressBar" class="stat-container">
|
||||
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&guid=755fc3f2b04b5014794dec9f2787b86e&type=3#progressBar" />
|
||||
<ui:VisualElement name="icon" class="progress-icon" style="background-image: url("project://database/Assets/3dAssets/Textures/FoodIcon.png?fileID=2800000&guid=bc479ad3f781c4540995d023a62d8c1d&type=3#FoodIcon");" />
|
||||
<ui:VisualElement name="progressBarContainer" class="progress-bar-container">
|
||||
<ui:VisualElement name="progressFill" class="progress-bar-fill" />
|
||||
<ui:VisualElement name="HungerProgressFill" class="progress-bar-fill" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="MoneyPanel" class="stat-container">
|
||||
@@ -24,12 +24,12 @@
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="LocationInfo" class="top-elements-block justify-center">
|
||||
<ui:Label text="Nowhere" name="AdressLabel" class="top-bar-label justify-center" />
|
||||
<ui:Label text="Nowhere" name="LocationLabel" class="top-bar-label justify-center" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="TimeInfo" class="top-elements-block justify-right">
|
||||
<ui:VisualElement name="TimePanel" class="stat-container">
|
||||
<ui:VisualElement name="icon" style="background-image: url("project://database/Assets/3dAssets/Textures/CalendarIcon.png?fileID=2800000&guid=40259e4947454c74bb483b1fab03888e&type=3#CalendarIcon"); height: 20px; width: 20px;" />
|
||||
<ui:Label text="Nowhere" name="ClockLabel" class="top-bar-label" />
|
||||
<ui:Label text="Nowhere" name="TimeLabel" class="top-bar-label" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
||||
Reference in New Issue
Block a user