added Game UI Controller
Show money on UI, buy items
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
{
|
||||
public class Eat : BaseAction
|
||||
{
|
||||
private int energyPerTick;
|
||||
public Eat(int duration, int energyPerTick, double cost) : base(duration)
|
||||
private double _price;
|
||||
private int _energyPerTick;
|
||||
public Eat(int duration, int energyPerTick, double price) : base(duration)
|
||||
{
|
||||
this.energyPerTick = energyPerTick;
|
||||
_price = price;
|
||||
_energyPerTick = energyPerTick;
|
||||
}
|
||||
public override void ApplyAction(PlayerController playerController)
|
||||
{
|
||||
playerController.foodEnergy.increase(energyPerTick);
|
||||
playerController.foodEnergy.increase(_energyPerTick);
|
||||
playerController.money.deduct(_price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DateTimeController : MonoBehaviour
|
||||
@@ -10,9 +9,6 @@ public class DateTimeController : MonoBehaviour
|
||||
[SerializeField]
|
||||
private float _startHour;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _timeText;
|
||||
|
||||
[SerializeField]
|
||||
private Light _sunLight;
|
||||
|
||||
@@ -43,6 +39,9 @@ public class DateTimeController : MonoBehaviour
|
||||
private TimeSpan _sunsetTime;
|
||||
|
||||
private DateTime _currentTime;
|
||||
|
||||
public DateTime CurrentTime => _currentTime;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -61,11 +60,6 @@ public class DateTimeController : MonoBehaviour
|
||||
private void UpdateTime()
|
||||
{
|
||||
_currentTime = _currentTime.AddSeconds(Time.deltaTime * _timeMultiplier);
|
||||
|
||||
if (_timeText != null)
|
||||
{
|
||||
_timeText.text = _currentTime.ToString("HH:mm");
|
||||
}
|
||||
}
|
||||
|
||||
private void RotateSun()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameUIController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private DateTimeController _dateTimeController;
|
||||
|
||||
[SerializeField]
|
||||
private PlayerController _playerController;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _timeText;
|
||||
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _moneyText;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
_moneyText.text = $"Money: {_playerController.money.Value}$";
|
||||
UpdateTime();
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
if (_timeText != null)
|
||||
{
|
||||
_timeText.text = _dateTimeController.CurrentTime.ToString("HH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2649ed9748ff3864880311f1c2aecdef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
public Stat money = new Stat("Money", 1000.00);
|
||||
public Stat money = new Stat("Money", 100.00);
|
||||
public Stat rentAccount = new Stat("Rent Account", 0);
|
||||
public Stat foodEnergy = new Stat("Food Energy", 0);
|
||||
public Stat restEnergy = new Stat("Rest Energy", 0);
|
||||
|
||||
Reference in New Issue
Block a user