using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using DG.Tweening;
namespace DisComputer
{
public class ToolItem : MonoBehaviour
{
public Image selectFrame_img;
public Image tool_img;
public Color normal_color;
private Sequence shakeTw;
public ToolType toolType;
///
/// 当前检测的零件标签
///
public string chectSpareTag;
// Start is called before the first frame update
void Start()
{
EventTrigger trigger = tool_img.GetComponent();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerDown;
entry.callback.AddListener((data)=> {
onPointDown((PointerEventData)data);
});
trigger.triggers.Add(entry);
}
///
/// 鼠标按下
///
public void onPointDown(PointerEventData data)
{
shakeTw = DOTween.Sequence();
shakeTw.Append(selectFrame_img.DOColor(Color.white, 0.1f).SetEase(Ease.Linear));
shakeTw.Append(selectFrame_img.DOColor(normal_color, 0.1f).SetEase(Ease.Linear));
shakeTw.SetLoops(-1);
MouseControl.Instance.SetDragTool(this);
}
///
/// 恢复设置
///
public void ResetTool()
{
shakeTw.Kill();
chectSpareTag = "";
selectFrame_img.DOColor(normal_color,0.3f).SetEase(Ease.InSine);
}
}
///
/// 工具类型
///
public enum ToolType
{
//手
Hand,
//刷子
Brush,
//橡皮
Eraser,
//螺丝刀
BoltDriver
}
}