105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using DG.Tweening;
|
|
|
|
/// <summary>
|
|
/// 工具材料基类
|
|
/// </summary>
|
|
public class Tool_Base : PermanentTriggerBase
|
|
{
|
|
/// <summary>
|
|
/// 工具类型
|
|
/// </summary>
|
|
public ToolType toolType;
|
|
|
|
/// <summary>
|
|
/// trigger触发事件
|
|
/// </summary>
|
|
public Func<string, bool, int> triggerAction;
|
|
/// <summary>
|
|
/// 是否再移动
|
|
/// </summary>
|
|
public bool isMoving;
|
|
|
|
|
|
private Vector3 head_LocalPos;
|
|
private Vector3 head_LocalEulerAnglesl;
|
|
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType == E_SceneType.Site)
|
|
{
|
|
base.OnAwake();
|
|
}
|
|
}
|
|
protected override void OnStart()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType == E_SceneType.Site)
|
|
{
|
|
base.OnStart();
|
|
AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID);
|
|
}
|
|
}
|
|
protected override void OnMEnter()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType == E_SceneType.Site && GameManager.RunModelMgr.ModeType != E_ModeType.Study)
|
|
{
|
|
base.OnMEnter();
|
|
_highlight.SetHighlighted(true);
|
|
|
|
}
|
|
}
|
|
protected override void OnMExit()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType == E_SceneType.Site && GameManager.RunModelMgr.ModeType != E_ModeType.Study)
|
|
{
|
|
base.OnMExit();
|
|
_highlight.SetHighlighted(false);
|
|
}
|
|
}
|
|
|
|
public void AddTriggerAction(Func<string, bool, int> action)
|
|
{
|
|
this.triggerAction = action;
|
|
}
|
|
public void AddStartAction(Action callback)
|
|
{
|
|
hand_out_action += callback;
|
|
}
|
|
public void AddEndAction(Action callback)
|
|
{
|
|
hand_back_action += callback;
|
|
}
|
|
/// <summary>
|
|
/// 设置工具回到手中的位置
|
|
/// </summary>
|
|
/// <param name="head_LocalPos"></param>
|
|
/// <param name="head_LocalEulerAnglesl"></param>
|
|
public void SetHeadPosAndEulerang(Vector3 head_LocalPos, Vector3 head_LocalEulerAnglesl)
|
|
{
|
|
this.head_LocalPos = head_LocalPos;
|
|
this.head_LocalEulerAnglesl = head_LocalEulerAnglesl;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工具回到手中
|
|
/// </summary>
|
|
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();
|
|
});
|
|
}
|
|
}
|