unityzgy/Assets/ThirdPackages/QuickRopes 2/_EXAMPLES/Scripts/CraneControl_QR2.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

61 lines
2.2 KiB
C#

using UnityEngine;
using System.Collections;
public class CraneControl_QR2 : MonoBehaviour
{
public Transform craneRotationObject = null;
public Transform trollyObject = null;
public Transform trollyInStop = null;
public Transform trollyOutStop = null;
private float rotationVelocity = 0;
public float rotationAccel = 3;
public float maxRotationVelocity = 7;
public float rotationDampening = 0.985f;
private float trollyVelocity = 0;
public float trollyAccel = 3;
public float maxTrollyVelocity = 7;
public float trollyDampening = 0.985f;
private float trollyPosition = 0.5f;
void Update ()
{
if (!Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
{
rotationVelocity += rotationAccel * Time.deltaTime;
}
else if (Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
{
rotationVelocity -= rotationAccel * Time.deltaTime;
}
else if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
{
rotationVelocity *= rotationDampening;
}
rotationVelocity = Mathf.Clamp(rotationVelocity, -maxRotationVelocity, maxRotationVelocity);
craneRotationObject.Rotate(0, rotationVelocity * Time.deltaTime, 0);
// Trolly
if (!Input.GetKey(KeyCode.S) && Input.GetKey(KeyCode.W))
{
trollyVelocity += trollyAccel * 0.1f * Time.deltaTime;
}
else if (Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W))
{
trollyVelocity -= trollyAccel * 0.1f * Time.deltaTime;
}
else if (!Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W))
{
trollyVelocity *= trollyDampening;
}
trollyVelocity = Mathf.Clamp(trollyVelocity, -maxTrollyVelocity * 0.1f, maxTrollyVelocity * 0.1f);
trollyPosition += trollyVelocity * Time.deltaTime;
trollyPosition = Mathf.Clamp(trollyPosition, 0f, 1f);
if (trollyPosition == 0 || trollyPosition == 1)
trollyVelocity = 0;
trollyObject.transform.position = trollyInStop.position + ((trollyOutStop.position - trollyInStop.position) * trollyPosition);
}
}