2026-06-30 02:19:13 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-06-30 03:02:12 +08:00
|
|
|
|
/// 挂在 touchArray 子球体上。球体用双Pass膨胀描边shader(Custom/OutlineUnlit),
|
|
|
|
|
|
/// 闪烁提示用户点击。点击后移动到对应位置并顺序显示下一个。
|
2026-06-30 02:19:13 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class TouchPositionHandler : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public Transform targetPosition;
|
|
|
|
|
|
public GameObject womanObject;
|
2026-06-30 02:24:54 +08:00
|
|
|
|
public GameObject nextTouchObject;
|
2026-07-01 19:51:41 +08:00
|
|
|
|
public AudioClip voiceClip;
|
2026-06-30 02:24:54 +08:00
|
|
|
|
|
2026-06-30 03:02:12 +08:00
|
|
|
|
private MeshRenderer _meshRenderer;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
|
2026-06-30 02:24:54 +08:00
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2026-06-30 03:02:12 +08:00
|
|
|
|
_meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
|
|
StartCoroutine(BlinkMesh());
|
2026-06-30 02:32:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-30 03:02:12 +08:00
|
|
|
|
private System.Collections.IEnumerator BlinkMesh()
|
2026-06-30 02:32:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
2026-06-30 03:02:12 +08:00
|
|
|
|
if (_meshRenderer != null)
|
|
|
|
|
|
_meshRenderer.enabled = !_meshRenderer.enabled;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
yield return new WaitForSeconds(0.4f);
|
2026-06-30 02:24:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
|
|
|
|
|
|
private void OnMouseDown()
|
|
|
|
|
|
{
|
2026-06-30 02:24:54 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] {name}: 被点击");
|
|
|
|
|
|
|
2026-06-30 02:19:13 +08:00
|
|
|
|
if (womanObject != null && targetPosition != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
womanObject.transform.position = targetPosition.position;
|
|
|
|
|
|
womanObject.transform.rotation = targetPosition.rotation;
|
2026-06-30 02:48:13 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name}");
|
2026-07-01 20:19:17 +08:00
|
|
|
|
if (voiceClip != null) { AudioSource.PlayClipAtPoint(voiceClip, transform.position); Debug.Log("[TouchPosition] 播放语音: " + voiceClip.name);
|
2026-06-30 02:24:54 +08:00
|
|
|
|
|
2026-06-30 14:32:30 +08:00
|
|
|
|
// 通知 StepManager 记录步骤
|
|
|
|
|
|
int stepIndex = transform.GetSiblingIndex() + 1;
|
|
|
|
|
|
var sm = FindObjectOfType<StepManager>();
|
|
|
|
|
|
if (sm != null) sm.RecordWomanStep(stepIndex);
|
|
|
|
|
|
|
2026-06-30 02:32:27 +08:00
|
|
|
|
StopAllCoroutines();
|
2026-06-30 03:02:12 +08:00
|
|
|
|
if (_meshRenderer != null) _meshRenderer.enabled = false;
|
2026-06-30 02:32:27 +08:00
|
|
|
|
|
2026-06-30 02:24:54 +08:00
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
|
if (nextTouchObject != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
nextTouchObject.SetActive(true);
|
2026-06-30 02:48:13 +08:00
|
|
|
|
Debug.Log($"[TouchPosition] {name} → {nextTouchObject.name} 显示");
|
2026-06-30 02:24:54 +08:00
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
}
|
2026-06-30 15:09:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
_meshRenderer = GetComponent<MeshRenderer>();
|
|
|
|
|
|
if (_meshRenderer != null) _meshRenderer.enabled = true;
|
|
|
|
|
|
StopAllCoroutines();
|
|
|
|
|
|
StartCoroutine(BlinkMesh());
|
|
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
}
|