GameVsJam/3d Prototyp/Assets/Scripts/UiController.cs

67 lines
1.9 KiB
C#
Raw Normal View History

2024-04-06 18:08:54 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
2024-04-07 00:09:53 +02:00
using Interaction;
2024-04-06 18:08:54 +02:00
using TMPro;
using UnityEngine;
2024-04-07 00:09:53 +02:00
using UnityEngine.Serialization;
2024-04-06 18:08:54 +02:00
using UnityEngine.UI;
public class UiController : MonoBehaviour
{
2024-04-07 00:09:53 +02:00
[FormerlySerializedAs("_pickupper")]
2024-04-06 18:08:54 +02:00
[Header("Objects")]
[SerializeField]
2024-04-07 00:09:53 +02:00
private InteractionHandler interactionHandler;
2024-04-06 18:08:54 +02:00
[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()
{
2024-04-07 00:09:53 +02:00
bool show = interactionHandler.InteractionsInRange.Count > 0;
2024-04-06 18:08:54 +02:00
_actionDisplay.SetActive(show);
if (!show)
return;
2024-04-07 00:09:53 +02:00
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;
}
2024-04-06 18:08:54 +02:00
2024-04-07 00:09:53 +02:00
//_prevActionButton.interactable = _pickupper.CanSelectPrevious;
//_nextActionButton.interactable = _pickupper.CanSelectNext;
2024-04-06 18:08:54 +02:00
}
}