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
---
.../ExampleScenes/ExampleScripts/MineBotAI.cs | 54 ++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MineBotAI.cs
(limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MineBotAI.cs')
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MineBotAI.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MineBotAI.cs
new file mode 100644
index 0000000..100b23e
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/ExampleScenes/ExampleScripts/MineBotAI.cs
@@ -0,0 +1,54 @@
+using UnityEngine;
+
+namespace Pathfinding.Examples {
+ ///
+ /// AI controller specifically made for the spider robot.
+ /// Deprecated: This script has been replaced by Pathfinding.Examples.MineBotAnimation. Any uses of this script in the Unity editor will be automatically replaced by one AIPath component and one MineBotAnimation component.
+ ///
+ [RequireComponent(typeof(Seeker))]
+ [System.Obsolete("This script has been replaced by Pathfinding.Examples.MineBotAnimation. Any uses of this script in the Unity editor will be automatically replaced by one AIPath component and one MineBotAnimation component.")]
+ [HelpURL("https://arongranberg.com/astar/documentation/stable/minebotai.html")]
+ public class MineBotAI : AIPath {
+ ///
+ /// Animation component.
+ /// Should hold animations "awake" and "forward"
+ ///
+ public Animation anim;
+
+ /// Minimum velocity for moving
+ public float sleepVelocity = 0.4F;
+
+ /// Speed relative to velocity with which to play animations
+ public float animationSpeed = 0.2F;
+
+ ///
+ /// Effect which will be instantiated when end of path is reached.
+ /// See: OnTargetReached
+ ///
+ public GameObject endOfPathEffect;
+
+#if UNITY_EDITOR
+ protected override void OnUpgradeSerializedData (ref Serialization.Migrations migrations, bool unityThread) {
+ if (unityThread) {
+ var components = gameObject.GetComponents();
+ int index = System.Array.IndexOf(components, this);
+ foreach (System.Type newType in new [] { typeof(AIPath), typeof(MineBotAnimation) }) {
+ var newComp = gameObject.AddComponent(newType);
+ foreach (var field in newComp.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public)) {
+ var oldField = this.GetType().GetField(field.Name);
+ try {
+ if (oldField != null) field.SetValue(newComp, oldField.GetValue(this));
+ } catch (System.Exception e) {
+ Debug.LogError("Failed to upgrade some fields.\n" + e);
+ }
+ }
+ for (int i = components.Length - 1; i > index; i--) UnityEditorInternal.ComponentUtility.MoveComponentUp(newComp);
+ }
+ GameObject.DestroyImmediate(this);
+ } else {
+ base.OnUpgradeSerializedData(ref migrations, unityThread);
+ }
+ }
+#endif
+ }
+}
--
cgit v1.1-26-g67d0