67 lines
1.9 KiB
C#
67 lines
1.9 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;
|
|
|
|
void Update()
|
|
{
|
|
UpdateActionDisplay();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|