fix(huoshan): 销售旋钮与发条交互高亮及辉光曲线
Made-with: Cursor
This commit is contained in:
@@ -78,6 +78,16 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
[Tooltip("缩放动画时长")]
|
||||
[SerializeField] private float scaleDuration = 0.1f;
|
||||
|
||||
[Header("交互提示")]
|
||||
[Tooltip("高亮目标:发条 Sprite(材质需含 _ShineFade);不填则使用 crankTransform 上 SpriteRenderer")]
|
||||
[SerializeField] private SpriteRenderer interactionHighlightSprite;
|
||||
|
||||
[Tooltip("开始拖拽发条时是否自动关闭高亮")]
|
||||
[SerializeField] private bool clearHighlightWhenDragStarts = true;
|
||||
|
||||
private static readonly int ShineFadeId = Shader.PropertyToID("_ShineFade");
|
||||
private SpriteRenderer _shineHighlightSprite;
|
||||
|
||||
private Vector3 _dragStartPosition;
|
||||
private float _dragStartAngle; // 按下时鼠标相对中心的角度
|
||||
private float _dragStartRotation; // 按下时发条的角度
|
||||
@@ -169,6 +179,33 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
_eventTrigger.Register(EventTriggerType.PointerUp, OnEventPointerUp);
|
||||
_eventTrigger.Register(EventTriggerType.Drag, OnEventDrag);
|
||||
}
|
||||
|
||||
EnsureInteractionHighlightSprite();
|
||||
SetInteractionHighlightVisible(false);
|
||||
}
|
||||
|
||||
private void EnsureInteractionHighlightSprite()
|
||||
{
|
||||
if (interactionHighlightSprite != null)
|
||||
{
|
||||
_shineHighlightSprite = interactionHighlightSprite;
|
||||
return;
|
||||
}
|
||||
if (crankTransform != null)
|
||||
_shineHighlightSprite = crankTransform.GetComponent<SpriteRenderer>()
|
||||
?? crankTransform.GetComponentInChildren<SpriteRenderer>(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制发条交互提示高亮(材质 _ShineFade)。由外部脚本、Yarn 命令等在合适时机调用。
|
||||
/// </summary>
|
||||
public void SetInteractionHighlightVisible(bool visible)
|
||||
{
|
||||
EnsureInteractionHighlightSprite();
|
||||
if (_shineHighlightSprite == null) return;
|
||||
var mat = _shineHighlightSprite.material;
|
||||
if (mat == null || !mat.HasProperty(ShineFadeId)) return;
|
||||
mat.SetFloat(ShineFadeId, visible ? 1f : 0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -352,6 +389,9 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
|
||||
private void StartDrag()
|
||||
{
|
||||
if (clearHighlightWhenDragStarts)
|
||||
SetInteractionHighlightVisible(false);
|
||||
|
||||
_isDragging = true;
|
||||
_dragStartPosition = Input.mousePosition;
|
||||
_dragStartRotation = _currentRotation;
|
||||
|
||||
@@ -77,6 +77,13 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
[Tooltip("盖子开合动画时长")]
|
||||
[SerializeField] private float lidAnimDuration = 0.4f;
|
||||
|
||||
[Header("交互提示")]
|
||||
[Tooltip("高亮目标:旋钮本体 Sprite(一般为 knobPlate,材质需含 _ShineFade);不填则使用 knobPlate,再回退为 knobTransform 上 SpriteRenderer(不含盖子子物体)")]
|
||||
[SerializeField] private SpriteRenderer interactionHighlightSprite;
|
||||
|
||||
[Tooltip("开始拖拽旋钮时是否自动关闭高亮")]
|
||||
[SerializeField] private bool clearHighlightWhenDragStarts = true;
|
||||
|
||||
[Header("环形进度条")]
|
||||
[Tooltip("灯带进度条 SpriteRenderer;不填则尝试自动查找")]
|
||||
[SerializeField] private SpriteRenderer ringProgressRenderer;
|
||||
@@ -157,6 +164,9 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
private static readonly int ProgressId = Shader.PropertyToID("_Progress");
|
||||
private static readonly int StartAngleId = Shader.PropertyToID("_StartAngle");
|
||||
private static readonly int FillClockwiseId = Shader.PropertyToID("_FillClockwise");
|
||||
private static readonly int ShineFadeId = Shader.PropertyToID("_ShineFade");
|
||||
|
||||
private SpriteRenderer _shineHighlightSprite;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -203,6 +213,37 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
_lidClosedPosition = knobLid.localPosition;
|
||||
|
||||
EnsureRingProgress();
|
||||
|
||||
EnsureInteractionHighlightSprite();
|
||||
SetInteractionHighlightVisible(false);
|
||||
}
|
||||
|
||||
private void EnsureInteractionHighlightSprite()
|
||||
{
|
||||
if (interactionHighlightSprite != null)
|
||||
{
|
||||
_shineHighlightSprite = interactionHighlightSprite;
|
||||
return;
|
||||
}
|
||||
if (knobPlate != null)
|
||||
{
|
||||
_shineHighlightSprite = knobPlate;
|
||||
return;
|
||||
}
|
||||
if (knobTransform != null)
|
||||
_shineHighlightSprite = knobTransform.GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制旋钮交互提示高亮(材质 _ShineFade)。由外部脚本、Yarn 命令等在合适时机调用。
|
||||
/// </summary>
|
||||
public void SetInteractionHighlightVisible(bool visible)
|
||||
{
|
||||
EnsureInteractionHighlightSprite();
|
||||
if (_shineHighlightSprite == null) return;
|
||||
var mat = _shineHighlightSprite.material;
|
||||
if (mat == null || !mat.HasProperty(ShineFadeId)) return;
|
||||
mat.SetFloat(ShineFadeId, visible ? 1f : 0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -399,6 +440,9 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
{
|
||||
if (_hasFailed || _hasSucceeded || _isLocked) return;
|
||||
|
||||
if (clearHighlightWhenDragStarts)
|
||||
SetInteractionHighlightVisible(false);
|
||||
|
||||
_isDragging = true;
|
||||
_prevMouseAngle = GetMouseAngleDeg(Input.mousePosition);
|
||||
ClearIdleState();
|
||||
@@ -643,7 +687,9 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
float overshoot = _overshootIntensity * Mathf.Exp(-_overshootDecay * 2.5f)
|
||||
* (1f + Mathf.Sin(_overshootDecay * 40f) * 0.5f * Mathf.Exp(-_overshootDecay * 1.5f));
|
||||
|
||||
_displayIntensity = _intensity + _resistancePulse + Mathf.Max(0f, overshoot);
|
||||
// 辉光与环形进度一致:用线性剩余量驱动粒子,避免 Pow(...,3) 导致中段过暗、与灯带进度脱节
|
||||
float glowBase = Mathf.Max(0.03f, 1f - _knobValue);
|
||||
_displayIntensity = glowBase + _resistancePulse + Mathf.Max(0f, overshoot);
|
||||
_displayIntensity = Mathf.Min(1.5f, _displayIntensity);
|
||||
|
||||
if (glowTubeEffect != null)
|
||||
|
||||
@@ -148,6 +148,34 @@ namespace AibisDream.MiniGame.HuoShan
|
||||
yield return new WaitForSeconds(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 旋钮交互提示高亮(_ShineFade)。需在旋钮 Sprite 使用含该属性的材质(如 ShineMaterial)。
|
||||
/// 用法: <<set_knob_highlight true>> / <<set_knob_highlight false>>
|
||||
/// </summary>
|
||||
[YarnCommand("set_knob_highlight")]
|
||||
public static void SetKnobHighlight(bool visible)
|
||||
{
|
||||
var knobController = GetSalesManager()?.KnobController;
|
||||
if (knobController != null)
|
||||
knobController.SetInteractionHighlightVisible(visible);
|
||||
else
|
||||
Debug.LogWarning("[SalesYarnCommand] 未找到 KnobController");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发条交互提示高亮(_ShineFade)。
|
||||
/// 用法: <<set_crank_highlight true>> / <<set_crank_highlight false>>
|
||||
/// </summary>
|
||||
[YarnCommand("set_crank_highlight")]
|
||||
public static void SetCrankHighlight(bool visible)
|
||||
{
|
||||
var crankController = GetSalesManager()?.CrankController;
|
||||
if (crankController != null)
|
||||
crankController.SetInteractionHighlightVisible(visible);
|
||||
else
|
||||
Debug.LogWarning("[SalesYarnCommand] 未找到 CrankController");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 滑片控制命令
|
||||
|
||||
Reference in New Issue
Block a user