mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-30 04:47:10 +01:00
money UI
This commit is contained in:
@@ -13,9 +13,6 @@ public class CameraMovement : MonoBehaviour
|
||||
float slowSpeed = 50f;
|
||||
|
||||
[Header("Zoom")]
|
||||
[SerializeField]
|
||||
float cameraSize = 15.0f;
|
||||
|
||||
[SerializeField]
|
||||
float maxCameraSize = 100f;
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ public class EconomyManager : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void AddMoney(float value) => money += value;
|
||||
public float GetMoney() => money;
|
||||
public string GetMoneyStr() => money.ToString() + " <20>";
|
||||
public void SetMoney(float value) => money = value;
|
||||
public void RemoveMone(float value) => money -= value;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,13 @@ public class TimeManager : MonoBehaviour
|
||||
|
||||
[Header("ReadOnly")]
|
||||
[SerializeField]
|
||||
string readOnlyTimeString;
|
||||
string readOnlyTimeString;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
8
Assets/Scripts/UI.meta
Normal file
8
Assets/Scripts/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b6d236e48426364cb29789a24ffe55a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Scripts/UI/MoneyUI.cs
Normal file
19
Assets/Scripts/UI/MoneyUI.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class MoneyUI : MonoBehaviour
|
||||
{
|
||||
TextMeshProUGUI moneyText;
|
||||
|
||||
void Start()
|
||||
{
|
||||
TimeManager.OnTimeUpdate += OnTimeUpdate;
|
||||
moneyText = GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
void OnTimeUpdate()
|
||||
{
|
||||
if (moneyText != null)
|
||||
moneyText.text = EconomyManager.instance.GetMoneyStr();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/MoneyUI.cs.meta
Normal file
11
Assets/Scripts/UI/MoneyUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24ee615049306e041af2b4679b9a19f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class TimeUI : MonoBehaviour
|
||||
{
|
||||
TextMeshProUGUI dateTimeText;
|
||||
TimeManager timeManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeManager = GameObject.Find("GameManager").GetComponent<TimeManager>();
|
||||
TimeManager.OnTimeUpdate += OnTimeUpdate;
|
||||
dateTimeText = GetComponent<TextMeshProUGUI>();
|
||||
|
||||
}
|
||||
|
||||
void OnTimeUpdate()
|
||||
{
|
||||
DateTime dateTime = timeManager.GetDateTime();
|
||||
DateTime dateTime = TimeManager.instance.GetDateTime();
|
||||
if (dateTimeText != null)
|
||||
dateTimeText.text = dateTime.ToString("hh:mm tt / dd.MM.yyyy", timeManager.cultureInfo);
|
||||
dateTimeText.text = dateTime.ToString("hh:mm tt / dd.MM.yyyy", TimeManager.instance.cultureInfo);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user