35 lines
925 B
C#
35 lines
925 B
C#
using DG.Tweening;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class StaticGear : MonoBehaviour
|
|
{
|
|
public float initSpeed;
|
|
private Tween _rotateTween;
|
|
|
|
private void Start()
|
|
{
|
|
transform.parent.GetComponent<EngineSystem>().updateSpeedEvent.AddListener(UpdateSpeedScale);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始旋转
|
|
/// </summary>
|
|
public void StartRotate()
|
|
{
|
|
_rotateTween = transform.DORotate(new Vector3(0, 0, 360), 1 / Mathf.Abs(initSpeed), RotateMode.LocalAxisAdd)
|
|
.SetEase(Ease.Linear)
|
|
.SetLoops(-1, LoopType.Incremental);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 为旋转加速
|
|
/// </summary>
|
|
/// <param name="speed">速度倍率</param>
|
|
private void UpdateSpeedScale(float speed)
|
|
{
|
|
_rotateTween.timeScale = speed;
|
|
}
|
|
}
|
|
} |