58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function 接头跟随鼠标
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class GensuishubiaoCtrl : Step_0
|
|
{
|
|
public GensuishubiaoCtrl(AZBS itemAttr) : base(itemAttr) { }
|
|
/// <summary>
|
|
/// 执行鼠标交互的逻辑
|
|
/// </summary>
|
|
public void OnExcuteMouseHandle(string jumpStepName)
|
|
{
|
|
FollowMouse fm = outLineParts[0].GetComponent<FollowMouse>() ? outLineParts[0].GetComponent<FollowMouse>() : outLineParts[0].AddComponent<FollowMouse>();
|
|
OnMouseEvent(outLineParts[0], true, () =>
|
|
{
|
|
if (!CG.UTility.PopUpMng._TriAble) return;
|
|
fm.isFollow = !fm.isFollow;
|
|
CG.UTility.MonoManager.Instance.StartCoroutine(OnDelay(0.5f, () =>
|
|
{
|
|
StepEnd();
|
|
StepManager.Instance.SwitchStep(jumpStepName);
|
|
}));
|
|
}, 0.0f, () =>
|
|
{
|
|
return;
|
|
});
|
|
}
|
|
|
|
private IEnumerator OnDelay(float t, System.Action action)
|
|
{
|
|
yield return new WaitForSeconds(t);
|
|
action?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 触发鼠标点击事件后
|
|
/// 1.开始执行函数
|
|
/// 2.是否吸附到鼠标上
|
|
/// </summary>
|
|
private void OnMouseEvent(GameObject obj, bool _isAdsorbing = false,System.Action _startAction = null, float _maxDistance = 0.0f, System.Action _endAction = null)
|
|
{
|
|
MouseEventListener mel = obj.GetComponent<MouseEventListener>();
|
|
mel.isAdsorbing = _isAdsorbing;
|
|
if (mel.isAdsorbing == false)
|
|
{
|
|
return;
|
|
}
|
|
mel.startAction = _startAction;
|
|
mel.maxDistance = _maxDistance;
|
|
mel.endAction = _endAction;
|
|
}
|
|
}
|
|
} |