59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
namespace Octopus.Simulator
|
|
{
|
|
public class LogicItemButton : MonoBehaviour
|
|
{
|
|
[Header("UI References")]
|
|
[SerializeField] private Image iconImage;
|
|
[SerializeField] private TMP_Text nameText;
|
|
[SerializeField] private Button button;
|
|
|
|
[Header("Type Icons")]
|
|
[SerializeField] private Sprite resourceIcon;
|
|
[SerializeField] private Sprite storeIcon;
|
|
[SerializeField] private Sprite queueIcon;
|
|
[SerializeField] private Sprite productGeneratorIcon;
|
|
[SerializeField] private Sprite processorIcon;
|
|
[SerializeField] private Sprite transporterIcon;
|
|
[SerializeField] private Sprite shipmentIcon;
|
|
|
|
// 타입→아이콘 매핑
|
|
private Dictionary<LogicItemType, Sprite> IconMap;
|
|
private Dictionary<ComponentType, Sprite> componentMap;
|
|
/// <summary>
|
|
/// 외부에서 이 버튼을 초기화할 때 호출
|
|
/// </summary>
|
|
public void Setup(ILogicItem item)
|
|
{
|
|
IconMap = new Dictionary<LogicItemType, Sprite>()
|
|
{
|
|
{ LogicItemType.Queue, queueIcon },
|
|
{ LogicItemType.Resource, resourceIcon },
|
|
{LogicItemType.Store,storeIcon }
|
|
};
|
|
componentMap = new Dictionary<ComponentType, Sprite>()
|
|
{
|
|
{ ComponentType.Source,productGeneratorIcon },
|
|
{ ComponentType.Processor,processorIcon },
|
|
{ ComponentType.Move,transporterIcon },
|
|
{ ComponentType.Sink,shipmentIcon },
|
|
{ ComponentType.Conveyor,transporterIcon },
|
|
};
|
|
|
|
|
|
if (item.ItemType != LogicItemType.Component)
|
|
{
|
|
iconImage.sprite = IconMap[item.ItemType];
|
|
}
|
|
else
|
|
{
|
|
iconImage.sprite = componentMap[(item as ILogicComponent).Type];
|
|
}
|
|
nameText.text = item.Label;
|
|
}
|
|
}
|
|
} |