1118OPSSNew/Assets/Zion/Scripts//点击弹起/ClickMoveBounce.cs

43 lines
1012 B
C#

using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClickMoveBounce : Device_Base
{
public Vector3 UpLocalPos;
public Vector3 DownLocalPos;
/// <summary>
/// µã»÷ʼþ
/// </summary>
public Action clickAction;
protected override void OnMDown()
{
base.OnMDown();
Click();
StepManager.Instance.FinishStep(triggerName);
}
private void Click()
{
if (!isMoving && triggerAction?.Invoke(triggerName, false) == 0)
{
isMoving = true;
transform.DOLocalMove(DownLocalPos, 0.5f).OnComplete(() =>
{
transform.DOLocalMove(UpLocalPos, 0.5f).OnComplete(() =>
{
isMoving = false;
clickAction?.Invoke();
triggerAction?.Invoke(triggerName, true);
CallScoreAction();
});
});
}
}
}