(client) feat:添加游玩时UI相关贴图,添加3d模型场景按钮,添加多级调色进度条,添加SVG图片包,添加事件定义以及管理器,添加音频管理器,定义部分怪物,添加通信协议定义;fix:修复维度切换错误,修复LogUI显示不正确 (#55)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: #55
This commit is contained in:
@ -1,91 +1,34 @@
|
||||
using Base;
|
||||
|
||||
using System;
|
||||
using TMPro;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ItemUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler, ITick
|
||||
public class ItemUI:MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image textureUI;
|
||||
[SerializeField] private TMP_Text countUI;
|
||||
[SerializeField] private TMP_Text nameUI;
|
||||
[SerializeField] private GameObject selectedOutline;
|
||||
public Entity.InventorySlot inventorySlot;
|
||||
public UIImageAnimator icon;
|
||||
|
||||
private Entity.InventorySlot _item;
|
||||
private float timer = 0;
|
||||
private float switchTime = 0;
|
||||
private int texturePtr = 0;
|
||||
|
||||
public event Action OnPlayerSelect;
|
||||
|
||||
public bool Select
|
||||
private void Start()
|
||||
{
|
||||
get => selectedOutline.activeSelf;
|
||||
set => selectedOutline.SetActive(value);
|
||||
icon.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public int SlotIndex { get; private set; } = -1;
|
||||
|
||||
public void Init(Entity.InventorySlot item, int index)
|
||||
public void SetDisplayItem(Entity.InventorySlot slot)
|
||||
{
|
||||
if (item == null)
|
||||
inventorySlot = slot;
|
||||
if (inventorySlot == null)
|
||||
{
|
||||
switchTime = -1;
|
||||
textureUI.gameObject.SetActive(false);
|
||||
countUI.text = "";
|
||||
nameUI.text = "";
|
||||
return;
|
||||
}
|
||||
|
||||
textureUI.gameObject.SetActive(true);
|
||||
_item = item;
|
||||
textureUI.sprite = item.Item.Icon[0];
|
||||
countUI.text = item.Quantity.ToString();
|
||||
nameUI.text = item.Item.Name;
|
||||
nameUI.gameObject.SetActive(false);
|
||||
Select = false;
|
||||
SlotIndex = index;
|
||||
if (item.Item.FPS > 0)
|
||||
{
|
||||
switchTime = 1f / item.Item.FPS;
|
||||
icon.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
switchTime = 0;
|
||||
icon.gameObject.SetActive(true);
|
||||
icon.SetSprites(inventorySlot.Item.Icon.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
nameUI.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
nameUI.gameObject.SetActive(false);
|
||||
}
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
OnPlayerSelect?.Invoke();
|
||||
}
|
||||
public void Tick()
|
||||
{
|
||||
if (switchTime > 0)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
if (timer >= switchTime)
|
||||
{
|
||||
timer -= switchTime;
|
||||
texturePtr++;
|
||||
texturePtr %= _item.Item.Icon.Count;
|
||||
textureUI.sprite = _item.Item.Icon[texturePtr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user