90 lines
2.4 KiB
C#
90 lines
2.4 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 Action<string, object, int, int> scoreAction;
|
|
|
|
private Vector3 head_LocalPos;
|
|
private Vector3 head_LocalEulerAnglesl;
|
|
|
|
protected override void OnStart()
|
|
{
|
|
if ( GameManager.RunModelMgr.SceneType == E_SceneType.Site)
|
|
{
|
|
base.OnStart();
|
|
AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID);
|
|
AddScoreAction(ScoreManager.instance.Check);
|
|
}
|
|
}
|
|
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 AddScoreAction(Action<string, object, int, int> back)
|
|
{
|
|
this.scoreAction = back;
|
|
}
|
|
/// <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()
|
|
{
|
|
transform.parent=Camera.main.transform;
|
|
transform.DOLocalRotate(head_LocalEulerAnglesl, 0.5f);
|
|
transform.DOLocalMove(head_LocalPos, 1).OnComplete(() =>
|
|
{
|
|
transform.localPosition = head_LocalPos;
|
|
transform.localEulerAngles = head_LocalEulerAnglesl;
|
|
});
|
|
}
|
|
}
|