using System.Collections.Generic; using Michsky.UI.Heat; using TMPro; using UFS3; using UnityEngine; using UnityEngine.UI; public class UI_ItemStatisticWindow : MonoBehaviour { [SerializeField] private ModalWindowManager modalWindowManager; [SerializeField] private TextMeshProUGUI _Name; [SerializeField] private Image _Image; [SerializeField] private TextMeshProUGUI _Parameters; [SerializeField] private TextMeshProUGUI _Description; [SerializeField] private float XpositionOffsetForItemPanel; [SerializeField] private float XpositionOffsetForSetPanel; private GameObject currentlyFocusedObject; private BaseItemData itemData; private bool isShowing; private CanvasGroup canvasGroup; private Animator animator; private void Start() { canvasGroup = GetComponent(); animator = GetComponent(); } private void Update() { if (isShowing && currentlyFocusedObject == null) { PointerExitHandler(currentlyFocusedObject); } if (isShowing && canvasGroup.alpha == 0f) { animator.Play("In"); } } public void PointerEnterHandler(GameObject go) { itemData = TryGetItem(go); if (itemData == null) { itemData = null; return; } currentlyFocusedObject = go; isShowing = true; modalWindowManager.OpenWindow(); Refresh(); } public void PointerExitHandler(GameObject go) { if (!(go != currentlyFocusedObject)) { currentlyFocusedObject = null; itemData = null; isShowing = false; modalWindowManager.CloseWindow(); } } private void Refresh() { _Name.text = itemData.name.Replace("(Clone)", "").TrimEnd(); _Image.sprite = itemData.Icon; _Parameters.text = GetParametersString(itemData); _Description.text = string.Empty; GetComponent().anchoredPosition = GetAnchoredPosition(currentlyFocusedObject); } private BaseItemData TryGetItem(GameObject go) { BaseItemData result = null; UI_SlotItemAssignButton component2; if (go.TryGetComponent(out var component)) { result = component.ItemData; } else if (go.TryGetComponent(out component2)) { result = component2.ItemData; } return result; } private Vector2 GetAnchoredPosition(GameObject go) { Vector2 result = Vector2.zero; UI_SlotItemAssignButton component2; if (go.TryGetComponent(out var _)) { result = new Vector2(XpositionOffsetForItemPanel, 0f); } else if (go.TryGetComponent(out component2)) { result = new Vector2(XpositionOffsetForSetPanel, 0f); } return result; } private string GetParametersString(BaseItemData item) { string result = "" + item.StatisticText; _ = ((IItemType)item).ItemType; return result; } private string GetDescriptionString(BaseItemData item) { string text = item.Description; ItemType itemType = ((IItemType)item).ItemType; switch (itemType) { case ItemType.Lure: { text += "\nBest for:\n"; LureData obj2 = item as LureData; List lureFishNames = new List(); obj2.attractedFish.ForEach(delegate(FishData fish) { lureFishNames.Add(fish.FishName); }); text += string.Join(", ", lureFishNames); break; } case ItemType.Bait: { text += "\nBest for:\n"; BaitData obj = item as BaitData; List baitFishNames = new List(); obj.attractedFish.ForEach(delegate(FishData fish) { baitFishNames.Add(fish.FishName); }); text += string.Join(", ", baitFishNames); break; } } return text; } }