31 lines
826 B
C#
31 lines
826 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);
|
|
}
|
|
|
|
private void UpdateSpeedScale(float originSpeed, float speed)
|
|
{
|
|
_rotateTween.timeScale = speed;
|
|
}
|
|
}
|
|
} |