You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

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;
/// <summary>
/// 当前检测的零件标签
/// </summary>
public string chectSpareTag;
// Start is called before the first frame update
void Start()
{
EventTrigger trigger = tool_img.GetComponent<EventTrigger>();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerDown;
entry.callback.AddListener((data)=> {
onPointDown((PointerEventData)data);
});
trigger.triggers.Add(entry);
}
/// <summary>
/// 鼠标按下
/// </summary>
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);
}
/// <summary>
/// 恢复设置
/// </summary>
public void ResetTool()
{
shakeTw.Kill();
chectSpareTag = "";
selectFrame_img.DOColor(normal_color,0.3f).SetEase(Ease.InSine);
}
}
/// <summary>
/// 工具类型
/// </summary>
public enum ToolType
{
//手
Hand,
//刷子
Brush,
//橡皮
Eraser,
//螺丝刀
BoltDriver
}
}