Handbuch Scroll-Listen entfernt. Handbuch offen und tabs eingefügt. Upgrades eingefügt. "Garage" eingefügt. Anbindung eines echten Gameplaymanager möglich (theoretisch)
This commit is contained in:
@@ -6,13 +6,13 @@ using UnityEngine.UI;
|
||||
|
||||
namespace DepthsOfGreed.HandbookUI
|
||||
{
|
||||
public sealed class TowerCardView : MonoBehaviour, IPointerClickHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
public sealed class TowerCardView : MonoBehaviour, IPointerClickHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public HandbookTowerEntry Entry { get; private set; }
|
||||
private BuildMenuController menu;
|
||||
private GameObject front, back;
|
||||
private TMP_Text nameText, costText, statsText, infoText;
|
||||
private Coroutine animation;
|
||||
private Coroutine flipRoutine;
|
||||
private Vector3 originalScale;
|
||||
private bool showingBack, dragged;
|
||||
private Image icon;
|
||||
@@ -47,7 +47,9 @@ namespace DepthsOfGreed.HandbookUI
|
||||
{
|
||||
Entry = entry;
|
||||
nameText.text = entry.displayName;
|
||||
costText.text = "Kosten: " + entry.energyCost + " Energie (Test)";
|
||||
string price = HandbookCostText.Format(entry.energyCost, entry.entrailsCost);
|
||||
costText.text = price.Length > 0 ? "Kosten: " + price : "";
|
||||
costText.gameObject.SetActive(price.Length > 0);
|
||||
statsText.text = entry.summary;
|
||||
infoText.text = entry.description;
|
||||
icon.sprite = entry.icon ? entry.icon : placeholderSprite;
|
||||
@@ -61,6 +63,8 @@ namespace DepthsOfGreed.HandbookUI
|
||||
menu.ToggleCard(this);
|
||||
dragged = false;
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData data) { if (menu.Placement) menu.Placement.ShowCardHint(Entry); }
|
||||
public void OnPointerExit(PointerEventData data) { if (menu.Placement) menu.Placement.ClearCardHint(); }
|
||||
|
||||
public void OnBeginDrag(PointerEventData data)
|
||||
{
|
||||
@@ -81,15 +85,15 @@ namespace DepthsOfGreed.HandbookUI
|
||||
public void SetBack(bool showBack, bool instant = false)
|
||||
{
|
||||
showingBack = showBack;
|
||||
if (animation != null) StopCoroutine(animation);
|
||||
animation = null;
|
||||
if (flipRoutine != null) StopCoroutine(flipRoutine);
|
||||
flipRoutine = null;
|
||||
if (instant || !isActiveAndEnabled)
|
||||
{
|
||||
transform.localScale = originalScale;
|
||||
front.SetActive(!showBack);
|
||||
back.SetActive(showBack);
|
||||
}
|
||||
else animation = StartCoroutine(Flip(showBack));
|
||||
else flipRoutine = StartCoroutine(Flip(showBack));
|
||||
}
|
||||
|
||||
private IEnumerator Flip(bool showBack)
|
||||
@@ -109,14 +113,15 @@ namespace DepthsOfGreed.HandbookUI
|
||||
yield return null;
|
||||
}
|
||||
transform.localScale = originalScale;
|
||||
animation = null;
|
||||
flipRoutine = null;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (animation != null) StopCoroutine(animation);
|
||||
animation = null;
|
||||
if (flipRoutine != null) StopCoroutine(flipRoutine);
|
||||
flipRoutine = null;
|
||||
transform.localScale = originalScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user