summaryrefslogtreecommitdiff
path: root/marching/Assets/Scripts/Items/Item_Coin.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-05-05 20:33:57 +0800
committerchai <215380520@qq.com>2023-05-05 20:33:57 +0800
commit160d98b1772a212f4db4d973532579a60f4b218b (patch)
tree9b5ef6b1c9b255871ae4f74fe96bb60548ef89c5 /marching/Assets/Scripts/Items/Item_Coin.cs
parent81976db8c051ed7031fe3e3c2c4c41d4c149b2aa (diff)
*misc
Diffstat (limited to 'marching/Assets/Scripts/Items/Item_Coin.cs')
-rw-r--r--marching/Assets/Scripts/Items/Item_Coin.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/marching/Assets/Scripts/Items/Item_Coin.cs b/marching/Assets/Scripts/Items/Item_Coin.cs
new file mode 100644
index 0000000..1549646
--- /dev/null
+++ b/marching/Assets/Scripts/Items/Item_Coin.cs
@@ -0,0 +1,30 @@
+using MH;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Rendering.Universal;
+
+public class Item_Coin : ItemBase
+{
+
+ protected override void Update()
+ {
+ base.Update();
+
+ UnitBase hero = UnitManager.hero;
+
+ Vector2 pos = transform.position;
+ Vector2 target = hero.transform.position;
+
+ if(Vector2.Distance(pos, target) <= 0.1f)
+ {
+ this.gameObject.SetActive(false);
+ Destroy(this.gameObject);
+ return;
+ }
+
+ Vector2 cur = Vector2.Lerp(pos, target, 0.01f);
+ transform.position = cur.ToVector3();
+ }
+
+} \ No newline at end of file