summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Tag
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
commit74a4f421b436b5950e52660ba7d6ebc53a818fa5 (patch)
tree9841fb6655fee855ba581768872de2deacf57f38 /Assets/Scripts/Tag
parent38e3e1fa64334f9cfd2f35e21439b93f525bf1b4 (diff)
完成好多HEADmain
Diffstat (limited to 'Assets/Scripts/Tag')
-rw-r--r--Assets/Scripts/Tag/Area.cs39
-rw-r--r--Assets/Scripts/Tag/Area.cs.meta2
-rw-r--r--Assets/Scripts/Tag/MaskAnswers.cs48
-rw-r--r--Assets/Scripts/Tag/MaskAnswers.cs.meta2
-rw-r--r--Assets/Scripts/Tag/TagItem.cs16
-rw-r--r--Assets/Scripts/Tag/TagPool.cs2
-rw-r--r--Assets/Scripts/Tag/TaggedItemSelector.cs9
-rw-r--r--Assets/Scripts/Tag/TaggedItemSelector.cs.meta2
8 files changed, 119 insertions, 1 deletions
diff --git a/Assets/Scripts/Tag/Area.cs b/Assets/Scripts/Tag/Area.cs
new file mode 100644
index 0000000..196bd36
--- /dev/null
+++ b/Assets/Scripts/Tag/Area.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Tag
+{
+ public class Area : MonoBehaviour
+ {
+ public ItemType itemAccepted;
+ public List<TagItem> items;
+
+ private void OnTriggerEnter(Collider other)
+ {
+ if (other.CompareTag("Part"))
+ {
+ var obj = other.GetComponent<TagItem>();
+ if (obj.info.itemType == itemAccepted)
+ {
+ if (! items.Contains(obj))
+ {
+ items.Add(obj);
+ }
+ }
+ }
+ }
+
+ private void OnTriggerExit(Collider other)
+ {
+ if (other.CompareTag("Part"))
+ {
+ var obj = other.GetComponent<TagItem>();
+ if (items.Contains(obj))
+ {
+ items.Remove(obj);
+ }
+ }
+ }
+ }
+}
diff --git a/Assets/Scripts/Tag/Area.cs.meta b/Assets/Scripts/Tag/Area.cs.meta
new file mode 100644
index 0000000..1faee20
--- /dev/null
+++ b/Assets/Scripts/Tag/Area.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 495019f9357aaff04b03214dd604b5b8 \ No newline at end of file
diff --git a/Assets/Scripts/Tag/MaskAnswers.cs b/Assets/Scripts/Tag/MaskAnswers.cs
new file mode 100644
index 0000000..f8e5583
--- /dev/null
+++ b/Assets/Scripts/Tag/MaskAnswers.cs
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Tag
+{
+ public class MaskAnswers : MonoBehaviour
+ {
+ public PlayerMovement bindPlayer;
+ public Area eyeArea;
+ public Area norseArea;
+ public Area mouseArea;
+ public Area elbowArea;
+ public Area accessoriesArea;
+
+ public Answer CollectToAnswer()
+ {
+ var totalTag = new List<string>();
+
+ foreach (var areaItem in eyeArea.items)
+ {
+ foreach (var t in areaItem.info.tags)
+ totalTag.Add(t);
+ }
+ foreach (var areaItem in norseArea.items)
+ {
+ foreach (var t in areaItem.info.tags)
+ totalTag.Add(t);
+ }
+ foreach (var areaItem in mouseArea.items)
+ {
+ foreach (var t in areaItem.info.tags)
+ totalTag.Add(t);
+ }
+ foreach (var areaItem in elbowArea.items)
+ {
+ foreach (var t in areaItem.info.tags)
+ totalTag.Add(t);
+ }
+ foreach (var areaItem in accessoriesArea.items)
+ {
+ foreach (var t in areaItem.info.tags)
+ totalTag.Add(t);
+ }
+
+ return new Answer(totalTag.ToArray());
+ }
+ }
+}
diff --git a/Assets/Scripts/Tag/MaskAnswers.cs.meta b/Assets/Scripts/Tag/MaskAnswers.cs.meta
new file mode 100644
index 0000000..6f91e25
--- /dev/null
+++ b/Assets/Scripts/Tag/MaskAnswers.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 2b048de9cb06a25ba843bc01f0729b49 \ No newline at end of file
diff --git a/Assets/Scripts/Tag/TagItem.cs b/Assets/Scripts/Tag/TagItem.cs
index 837eb3f..27b5efe 100644
--- a/Assets/Scripts/Tag/TagItem.cs
+++ b/Assets/Scripts/Tag/TagItem.cs
@@ -5,5 +5,21 @@ namespace Tag
public class TagItem : MonoBehaviour
{
public TaggedItemInfo info;
+ public SpriteRenderer spriteRenderer;
+
+ public static void CleanTagItem()
+ {
+ foreach (var i in FindObjectsByType<TagItem>(FindObjectsSortMode.None))
+ {
+ if (i.info == null)
+ Destroy(i.gameObject);
+ }
+ }
+
+ private void OnEnable()
+ {
+ if (info == null) return;
+ spriteRenderer.sprite = info.image;
+ }
}
}
diff --git a/Assets/Scripts/Tag/TagPool.cs b/Assets/Scripts/Tag/TagPool.cs
index 75bd0fc..e6109fd 100644
--- a/Assets/Scripts/Tag/TagPool.cs
+++ b/Assets/Scripts/Tag/TagPool.cs
@@ -5,6 +5,6 @@ namespace Tag
{
public class TagPool : MonoBehaviour
{
- public List<TaggedItemInfo> items = new();
+ public List<TagItem> items = new();
}
}
diff --git a/Assets/Scripts/Tag/TaggedItemSelector.cs b/Assets/Scripts/Tag/TaggedItemSelector.cs
new file mode 100644
index 0000000..87a563e
--- /dev/null
+++ b/Assets/Scripts/Tag/TaggedItemSelector.cs
@@ -0,0 +1,9 @@
+using UnityEngine;
+
+namespace Tag
+{
+ public class TaggedItemSelector : MonoBehaviour
+ {
+
+ }
+}
diff --git a/Assets/Scripts/Tag/TaggedItemSelector.cs.meta b/Assets/Scripts/Tag/TaggedItemSelector.cs.meta
new file mode 100644
index 0000000..bbe62e0
--- /dev/null
+++ b/Assets/Scripts/Tag/TaggedItemSelector.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a3c64c11fc0f4b9b698b811d2051db1a \ No newline at end of file