Add point2 as the first step, trigger IsCheck, and enable Shose afterward
This commit is contained in:
@@ -131,15 +131,7 @@ public class AudioManager : MonoBehaviour
|
||||
c2.enabled = false;
|
||||
c3.enabled = true;
|
||||
|
||||
// 在这里把 woman 的 IsCheck 设为 true
|
||||
var woman = GameObject.Find("woman");
|
||||
if (woman != null)
|
||||
{
|
||||
var anim = woman.GetComponent<Animator>();
|
||||
if (anim != null) anim.SetBool("IsCheck", true);
|
||||
}
|
||||
|
||||
float duration = 1.0f;
|
||||
float duration = 1.0f;
|
||||
float elapsed = 0f;
|
||||
|
||||
while (elapsed < duration)
|
||||
|
||||
@@ -154,6 +154,17 @@ public class StepManager : MonoBehaviour
|
||||
|
||||
private bool TryClickActiveHandler()
|
||||
{
|
||||
var point2s = Object.FindObjectsOfType<Point2ClickHandler>();
|
||||
foreach (var p in point2s)
|
||||
{
|
||||
if (p.gameObject.activeInHierarchy && p.CanBeClicked())
|
||||
{
|
||||
Debug.LogError($"====== StepManager: 模拟点击了 {p.name}! ======");
|
||||
p.PerformClick();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var touches = Object.FindObjectsOfType<TouchPositionHandler>();
|
||||
System.Array.Sort(touches, (a, b) => string.Compare(a.name, b.name));
|
||||
foreach (var t in touches)
|
||||
|
||||
@@ -5,6 +5,7 @@ public static class ActionHistory
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
Point2,
|
||||
Shose,
|
||||
ChanraoTuibu,
|
||||
PingFirst,
|
||||
@@ -62,7 +63,12 @@ public static class ActionHistory
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.Type == ActionType.Shose)
|
||||
if (item.Type == ActionType.Point2)
|
||||
{
|
||||
var h = item.Handler as Point2ClickHandler;
|
||||
if (h != null) h.ResetState();
|
||||
}
|
||||
else if (item.Type == ActionType.Shose)
|
||||
{
|
||||
var h = item.Handler as ShoseClickHandler;
|
||||
if (h != null) h.ResetState();
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Point2ClickHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject nextObject; // This will be Shose
|
||||
private MeshRenderer _outlineMesh;
|
||||
private bool _clicked;
|
||||
|
||||
public bool CanBeClicked() { return !_clicked; }
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (GetComponent<Collider>() == null) gameObject.AddComponent<SphereCollider>().radius = 0.5f;
|
||||
foreach (var r in GetComponentsInChildren<Renderer>(true)) r.enabled = false;
|
||||
CreateOutlineMesh();
|
||||
_clicked = false;
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(BlinkOutline());
|
||||
}
|
||||
|
||||
void CreateOutlineMesh()
|
||||
{
|
||||
if (_outlineMesh != null) return;
|
||||
var mf = GetComponent<MeshFilter>();
|
||||
if (mf == null) mf = GetComponentInChildren<MeshFilter>();
|
||||
if (mf == null || mf.sharedMesh == null) return;
|
||||
var shader = Shader.Find("Custom/OutlineUnlit");
|
||||
if (shader == null) return;
|
||||
var mat = new Material(shader);
|
||||
mat.SetColor("_OutlineColor", new Color(0.2f, 0.5f, 1f, 1f));
|
||||
mat.SetColor("_MainColor", new Color(0, 0, 0, 0));
|
||||
mat.SetFloat("_OutlineWidth", OutlineConfig.Width);
|
||||
var go = new GameObject("Outline");
|
||||
go.transform.SetParent(transform, false);
|
||||
go.AddComponent<MeshFilter>().sharedMesh = mf.sharedMesh;
|
||||
_outlineMesh = go.AddComponent<MeshRenderer>();
|
||||
_outlineMesh.material = mat;
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator BlinkOutline()
|
||||
{
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = true;
|
||||
yield return new WaitForSeconds(0.4f);
|
||||
while (true) { if (_outlineMesh != null) _outlineMesh.enabled = !_outlineMesh.enabled; yield return new WaitForSeconds(0.4f); }
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
PerformClick();
|
||||
}
|
||||
|
||||
public void PerformClick()
|
||||
{
|
||||
if (_clicked) return;
|
||||
_clicked = true;
|
||||
|
||||
Debug.Log("[Point2Click] ★ 被点击 ★");
|
||||
ActionHistory.Push(ActionHistory.ActionType.Point2, this);
|
||||
|
||||
StopAllCoroutines();
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = false;
|
||||
|
||||
var woman = GameObject.Find("woman");
|
||||
if (woman != null)
|
||||
{
|
||||
var anim = woman.GetComponent<Animator>();
|
||||
if (anim != null)
|
||||
{
|
||||
anim.SetBool("IsCheck", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (nextObject != null) nextObject.SetActive(true);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void ResetState()
|
||||
{
|
||||
_clicked = false;
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = true;
|
||||
|
||||
if (nextObject != null) nextObject.SetActive(false);
|
||||
|
||||
var woman = GameObject.Find("woman");
|
||||
if (woman != null)
|
||||
{
|
||||
var anim = woman.GetComponent<Animator>();
|
||||
if (anim != null)
|
||||
{
|
||||
anim.SetBool("IsCheck", false);
|
||||
}
|
||||
}
|
||||
|
||||
gameObject.SetActive(true);
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(BlinkOutline());
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
if (anim != null)
|
||||
{
|
||||
anim.SetBool("isCrouch", false);
|
||||
anim.SetBool("IsCheck", false);
|
||||
|
||||
|
||||
}
|
||||
// 移回原位?如果最初在某个位置,PageController里有记录。这里只要不穿帮即可
|
||||
|
||||
@@ -420,14 +420,21 @@ public class PageController : MonoBehaviour
|
||||
}
|
||||
// ------------------------------
|
||||
|
||||
// 实验刚开始,立刻激活鞋子,不等语音播完
|
||||
// 实验刚开始,立刻激活point2,不等语音播完
|
||||
var shose = GameObject.Find("Shose");
|
||||
if (shose == null)
|
||||
{
|
||||
// 如果被禁用了,找它的最顶层引用
|
||||
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>();
|
||||
foreach(var t in allTransforms) { if (t.parent == null && t.name == "Shose") { shose = t.gameObject; break; } }
|
||||
}
|
||||
|
||||
var point2 = GameObject.Find("point2");
|
||||
if (point2 == null)
|
||||
{
|
||||
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>();
|
||||
foreach(var t in allTransforms) { if (t.name == "point2") { point2 = t.gameObject; break; } }
|
||||
}
|
||||
|
||||
if (shose != null)
|
||||
{
|
||||
var h = shose.GetComponent<ShoseClickHandler>();
|
||||
@@ -443,8 +450,20 @@ public class PageController : MonoBehaviour
|
||||
}
|
||||
h.nextObject = chanraotuibu;
|
||||
}
|
||||
shose.SetActive(true);
|
||||
Debug.Log("PageController: 开场动画结束,Shose 已立刻激活");
|
||||
shose.SetActive(false); // 确保一开始隐藏
|
||||
}
|
||||
|
||||
if (point2 != null)
|
||||
{
|
||||
var oldHandler = point2.GetComponent<TouchPositionHandler>();
|
||||
if (oldHandler != null) Destroy(oldHandler);
|
||||
|
||||
var h2 = point2.GetComponent<Point2ClickHandler>();
|
||||
if (h2 == null) h2 = point2.AddComponent<Point2ClickHandler>();
|
||||
if (h2.nextObject == null) h2.nextObject = shose;
|
||||
|
||||
point2.SetActive(true);
|
||||
Debug.Log("PageController: 开场动画结束,point2 已立刻激活");
|
||||
}
|
||||
|
||||
// 1. 强制播放第一句语音:“周围环境安全,我是救护志愿者,我可以帮助您吗”
|
||||
|
||||
Reference in New Issue
Block a user