aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/OneWayDoorBehaviour.cs14
-rw-r--r--Assets/Scripts/SoulCoreGameLoop/UI/AreaHintGenerator.cs2
-rw-r--r--Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs40
-rw-r--r--Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs.meta11
4 files changed, 64 insertions, 3 deletions
diff --git a/Assets/Scripts/OneWayDoorBehaviour.cs b/Assets/Scripts/OneWayDoorBehaviour.cs
index a92d8cd..25a06ec 100644
--- a/Assets/Scripts/OneWayDoorBehaviour.cs
+++ b/Assets/Scripts/OneWayDoorBehaviour.cs
@@ -1,11 +1,19 @@
+using System;
using UnityEngine;
public class OneWayDoorBehaviour : MonoBehaviour
{
[Header("绑定")]
public Transform door;
+ public GameObject messageHint;
- public float Angle => door.localRotation.eulerAngles.y;
- public float AnglePercent => Angle / 90;
- public bool IsOpened => Angle > 75;
+ public float Angle => Mathf.Round(door.localRotation.eulerAngles.y);
+ public float AnglePercent => Mathf.Clamp01(Angle / 90);
+ public bool IsOpened => Angle > 25;
+
+ private void FixedUpdate()
+ {
+ // 如果门打开,就关闭消息提示
+ messageHint.SetActive(! IsOpened);
+ }
}
diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/AreaHintGenerator.cs b/Assets/Scripts/SoulCoreGameLoop/UI/AreaHintGenerator.cs
index efc5e5f..c016ad9 100644
--- a/Assets/Scripts/SoulCoreGameLoop/UI/AreaHintGenerator.cs
+++ b/Assets/Scripts/SoulCoreGameLoop/UI/AreaHintGenerator.cs
@@ -18,6 +18,8 @@ namespace SoulCoreGameLoop.UI
private void OnTriggerEnter(Collider other)
{
+ if (! other.CompareTag("Player")) return;
+
Debug.Log("AreaHintGenerator OnTriggerEnter");
// 向监听器发送消息
UIEventListener.Send(new AreaHintMessage(name));
diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs b/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs
new file mode 100644
index 0000000..a286273
--- /dev/null
+++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs
@@ -0,0 +1,40 @@
+using UnityEngine;
+
+namespace SoulCoreGameLoop.UI
+{
+ [RequireComponent(typeof(BoxCollider))]
+ public class MessageGenerator : MonoBehaviour
+ {
+ [Header("消息")]
+ public new string message = "哈哈";
+
+ private BoxCollider _collider;
+
+ private void Awake()
+ {
+ _collider = GetComponent<BoxCollider>();
+ _collider.isTrigger = true;
+ }
+
+ private void OnTriggerEnter(Collider other)
+ {
+ if (! other.CompareTag("Player")) return;
+
+ // 向监听器发送消息
+ UIEventListener.Send(new Message(message));
+ }
+
+ private void OnDrawGizmosSelected()
+ {
+ if (_collider == null) return;
+
+ var cs = _collider.size;
+ var ts = transform.lossyScale;
+ var size = new Vector3(cs.x * ts.x, cs.y * ts.y, cs.z * ts.z);
+
+ Gizmos.color = new Color(1f, 1f, 1f, 0.5f);
+ Gizmos.matrix = transform.localToWorldMatrix;
+ Gizmos.DrawCube(_collider.center, size);
+ }
+ }
+} \ No newline at end of file
diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs.meta b/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs.meta
new file mode 100644
index 0000000..6b8c065
--- /dev/null
+++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageGenerator.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b7e8b0c55f5e43f4da8dd4ab3c6eb639
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: