From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Thu, 23 May 2024 10:08:29 +0800
Subject: + astar project
---
.../Scenes/HexagonalTurnBased/HexagonTrigger.cs | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/Scenes/HexagonalTurnBased/HexagonTrigger.cs
(limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/Scenes/HexagonalTurnBased/HexagonTrigger.cs')
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/Scenes/HexagonalTurnBased/HexagonTrigger.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/Scenes/HexagonalTurnBased/HexagonTrigger.cs
new file mode 100644
index 0000000..0ca166f
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/Scenes/HexagonalTurnBased/HexagonTrigger.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+
+namespace Pathfinding.Examples {
+ /// Helper script in the example scene 'Turn Based'
+ [RequireComponent(typeof(Animator))]
+ [HelpURL("https://arongranberg.com/astar/documentation/stable/hexagontrigger.html")]
+ public class HexagonTrigger : MonoBehaviour {
+ Animator anim;
+ bool visible;
+
+ void Awake () {
+ anim = GetComponent();
+ }
+
+ /// [OnTriggerEnter]
+ void OnTriggerEnter (Collider coll) {
+ var unit = coll.GetComponentInParent();
+ var node = AstarPath.active.GetNearest(transform.position).node;
+
+ // Check if it is an agent and the agent is headed for this node
+ if (unit != null && unit.targetNode == node) {
+ visible = true;
+ anim.CrossFade("show", 0.1f);
+ }
+ }
+ /// [OnTriggerEnter]
+
+ void OnTriggerExit (Collider coll) {
+ if (coll.GetComponentInParent() != null && visible) {
+ anim.CrossFade("hide", 0.1f);
+ }
+ }
+ }
+}
--
cgit v1.1-26-g67d0