1118OPSSNew/Assets/Zion/Scripts/GameScene/Processes/LimitPointerAngle.cs

46 lines
1.1 KiB
C#

using MGS.Machinery;
using UnityEngine;
/// <summary>
/// 仪表盘指针旋转
/// </summary>
public class LimitPointerAngle : MonoBehaviour
{
public float minAngle;
public float maxAngle;
private float velocity = 50;
protected Mechanism mechanism;
[HideInInspector]
public LimitCrank limitCrank;
public OneValueSyncObject syncObject;
public FunctionSync_PositionRoate syncRoate;
protected virtual void Awake()
{
Initialize();
limitCrank = GetComponent<LimitCrank>();
syncObject = GetComponent<OneValueSyncObject>();
syncRoate = GetComponent<FunctionSync_PositionRoate>();
limitCrank.range.min = Random.Range(minAngle, maxAngle);
}
protected virtual void Initialize()
{
mechanism = GetComponent<Mechanism>();
}
private void Update()
{
StartDashboards(syncObject.mybool);
}
public void StartDashboards(bool isStart)
{
if (isStart)
{
mechanism.Drive(-velocity, DriveType.Ignore);
}
else
{
mechanism.Drive(velocity, DriveType.Ignore);
}
}
}