101 lines
3.5 KiB
C#
101 lines
3.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Interaction;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
public class UiController : MonoBehaviour
|
|
{
|
|
[FormerlySerializedAs("_pickupper")]
|
|
[Header("Objects")]
|
|
[SerializeField]
|
|
private InteractionHandler interactionHandler;
|
|
|
|
[Header("UI Elements")]
|
|
[SerializeField]
|
|
private GameObject _actionDisplay;
|
|
[SerializeField]
|
|
private TextMeshProUGUI _actionText;
|
|
[SerializeField]
|
|
private Button _prevActionButton;
|
|
[SerializeField]
|
|
private Button _nextActionButton;
|
|
|
|
[SerializeField]
|
|
private Image _progressBarImage;
|
|
|
|
[SerializeField]
|
|
private Image _progressBarBorder;
|
|
|
|
[SerializeField] private TextMeshProUGUI _progressText;
|
|
|
|
[SerializeField] private TextMeshProUGUI _deadlineText;
|
|
[SerializeField] private TextMeshProUGUI _currentDateText;
|
|
[SerializeField] private TextMeshProUGUI _predictedEndText;
|
|
|
|
[SerializeField] private Gradient _deadlineTextColors;
|
|
|
|
void Update()
|
|
{
|
|
UpdateActionDisplay();
|
|
UpdateProgressBar();
|
|
UpdateDeadlineDateStuffTexts();
|
|
}
|
|
|
|
private void UpdateProgressBar()
|
|
{
|
|
Vector3 scale = _progressBarImage.rectTransform.localScale;
|
|
scale.x = (float)GameManager.Instance.GameProgress;
|
|
|
|
_progressBarImage.rectTransform.localScale = scale;
|
|
_progressBarImage.pixelsPerUnitMultiplier = _progressBarBorder.pixelsPerUnitMultiplier * scale.x;
|
|
_progressText.text = $"Entwicklungsfortschritt: {GameManager.Instance.GameProgress:##0%}";
|
|
}
|
|
|
|
private void UpdateDeadlineDateStuffTexts()
|
|
{
|
|
_currentDateText.text = $"Aktuelle Zeit: {TimeManager.Instance.CurrentDate: dddd dd.MM.yy hh U\\hr}";
|
|
_deadlineText.text = $"Deadline: {TimeManager.Instance.Deadline: dddd dd.MM.yy hh U\\hr}";
|
|
_predictedEndText.text = $"Vorraussichtlich fertig: {(TimeManager.Instance.PredictedEndDate == DateTime.MaxValue ? "Nie" : TimeManager.Instance.PredictedEndDate.ToString("dddd dd.MM.yy hh U\\hr"))}";
|
|
_predictedEndText.color = _deadlineTextColors.Evaluate(TimeManager.Instance.PredictedMissesDeadline ? 0.0f : 1.0f);
|
|
}
|
|
|
|
private void UpdateActionDisplay()
|
|
{
|
|
bool show = interactionHandler.InteractionsInRange.Count > 0;
|
|
|
|
_actionDisplay.SetActive(show);
|
|
|
|
if (!show)
|
|
return;
|
|
|
|
switch (interactionHandler.SelectedAction)
|
|
{
|
|
case PickupInteractible pickup:
|
|
_actionText.text = $"Hebe {pickup.Name} auf";
|
|
break;
|
|
case UseInteractible usable:
|
|
_actionText.text = usable.UseText;
|
|
break;
|
|
case GiveItemInteractible giveItem:
|
|
_actionText.text = $"Gebe {GameManager.Instance.Player.CarriedItem?.Name ?? "keinen Gegenstand"} an {giveItem.Developer.Name}";
|
|
break;
|
|
default:
|
|
_actionText.text = $"Unbekannte Aktion";
|
|
break;
|
|
// case InteractibleType.Use:
|
|
// _actionText.text = $"{_pickupper.Selected.Name} benutzen";
|
|
// break;
|
|
// case InteractibleType.Give:
|
|
// _actionText.text = $"An {_pickupper.Selected.Name} geben";
|
|
// break;
|
|
}
|
|
|
|
//_prevActionButton.interactable = _pickupper.CanSelectPrevious;
|
|
//_nextActionButton.interactable = _pickupper.CanSelectNext;
|
|
}
|
|
}
|