using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using DG.Tweening; public enum ToolType { 万用表, 剥线钳, 绝缘螺丝刀, 验电笔, 国网安全帽, 工作服, 编织手套, 绝缘靴, 工作证, 盒装封印, 绝缘胶带, 螺丝, 接线 } /// /// 工具材料基类 /// public class Tool_Base : PermanentTriggerBase { /// /// 工具类型 /// public ToolType toolType; /// /// trigger触发事件 /// public Func triggerAction; /// /// 是否再移动 /// public bool isMoving; private Vector3 head_LocalPos; private Vector3 head_LocalEulerAnglesl; protected override void OnAwake() { base.OnAwake(); } protected override void OnStart() { base.OnStart(); } protected override void OnMEnter() { base.OnMEnter(); _highlight.SetHighlighted(true); } protected override void OnMExit() { _highlight.SetHighlighted(false); } public void AddTriggerAction(Func action) { this.triggerAction = action; } public void AddStartAction(Action callback) { hand_out_action = callback; } public void AddEndAction(Action callback) { hand_back_action = callback; } /// /// 设置工具回到手中的位置 /// /// /// public void SetHeadPosAndEulerang(Vector3 head_LocalPos, Vector3 head_LocalEulerAnglesl) { this.head_LocalPos = head_LocalPos; this.head_LocalEulerAnglesl = head_LocalEulerAnglesl; } /// /// 工具回到手中 /// public void ReBackHead(Action back = null) { isMoving = true; transform.parent = Camera.main.transform; transform.DOLocalRotate(head_LocalEulerAnglesl, 0.3f); transform.DOLocalMove(head_LocalPos, 0.8f).OnComplete(() => { transform.localPosition = head_LocalPos; transform.localEulerAngles = head_LocalEulerAnglesl; isMoving = false; hand_back_action?.Invoke(); back?.Invoke(); }); } }