浏览代码

隐身普攻发射魂

LAPTOP-OM1V99U2\永远de小亡灵 1 年之前
父节点
当前提交
68ca08c7c7

+ 39 - 2
ActionTowerDefense/Assets/Resources/Prefab/Transfiguration/Trans_Invisible.prefab

@@ -65,6 +65,37 @@ BoxCollider:
   serializedVersion: 2
   m_Size: {x: 40, y: 3, z: 1}
   m_Center: {x: 0, y: 1.5, z: 0}
+--- !u!1 &286913089395434820
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 7644101665628300234}
+  m_Layer: 7
+  m_Name: ShootPos
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &7644101665628300234
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 286913089395434820}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: -2, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 2730232521377132808}
+  m_RootOrder: 2
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &1090663073729466903
 GameObject:
   m_ObjectHideFlags: 0
@@ -176,8 +207,13 @@ MonoBehaviour:
   demonic: {fileID: 2437299196472462353}
   player: {fileID: 0}
   playerController: {fileID: 0}
-  addMp: 0
-  soulCollector: {fileID: 0}
+  addMp: 100
+  soulCollector: {fileID: 1289604965499631171}
+  soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
+  distance: 20
+  body: {fileID: 2730232521377132808}
+  shootPos: {fileID: 7644101665628300234}
+  soulFollowEffect: {fileID: 4610496197409361392}
 --- !u!114 &2437299196472462353
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -385,6 +421,7 @@ Transform:
   m_Children:
   - {fileID: 1971427318739414964}
   - {fileID: 7794457276998281569}
+  - {fileID: 7644101665628300234}
   m_Father: {fileID: 2437299196472462364}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

+ 5 - 0
ActionTowerDefense/Assets/Resources/Prefab/soul.prefab

@@ -9837,8 +9837,13 @@ MonoBehaviour:
   tweenPos: {fileID: -7697323034879839750}
   flySpeed: 20
   upSpeed: 1
+  shootSpeed: 1
   altitude: 30
   target: {fileID: 0}
+  isShoot: 0
+  from: {x: 0, y: 0, z: 0}
+  to: {x: 0, y: 0, z: 0}
+  time: 0
 --- !u!54 &1723151111827507801
 Rigidbody:
   m_ObjectHideFlags: 0

+ 23 - 2
ActionTowerDefense/Assets/Scripts/Soul.cs

@@ -13,8 +13,16 @@ public class Soul : MonoBehaviour
     public uTweenPositionTarget tweenPos;
     public float flySpeed = 10f;
     public float upSpeed = 1;
+    public float shootSpeed;
     public float altitude;
-    public Transform target;
+    [HideInInspector]
+    public bool isShoot;
+    [HideInInspector]
+    public Vector3 from;
+    [HideInInspector]
+    public Vector3 to;
+    [HideInInspector]
+    public float time;
 
     private void Awake()
     {
@@ -49,7 +57,15 @@ public class Soul : MonoBehaviour
 
     private void FixedUpdate()
     {
-        
+        if (isShoot)
+        {
+            time += Time.deltaTime;
+            transform.position = Vector3.Lerp(from, to, time);
+            if (Vector3.Distance(transform.position, to)<1f)
+            {
+                isShoot = false;
+            }
+        }   
         if(transform.position.y>= altitude)
         {
             rb.velocity = Vector3.zero;
@@ -62,4 +78,9 @@ public class Soul : MonoBehaviour
 
         }
     }
+    public void BeShoot()
+    {
+        time = 0;
+        isShoot = true;
+    }
 }

+ 0 - 2
ActionTowerDefense/Assets/Scripts/Spirits/InvisibleSoulCollector.cs

@@ -13,8 +13,6 @@ public class InvisibleSoulCollector : MonoBehaviour
         if (soul)
         {
             BeCollect(soul);
-
-
         }
     }
     public async void BeCollect(Soul soul)

+ 16 - 4
ActionTowerDefense/Assets/Scripts/Spirits/SoulFollowEffect.cs

@@ -55,7 +55,15 @@ public class SoulFollowEffect : MonoBehaviour
             newSoul.SetActive(false);
             soulsList.Add(newSoul);
         }
-        if(newNumber != 0)
+
+        if(newNumber == 0)
+        {
+            for(int i = 0;i< soulsList.Count; i++)
+            {
+                soulsList[i].gameObject.SetActive(false);
+            }
+        }
+        else if (newNumber > soulsNumber)
         {
             soulsList[newNumber - 1].gameObject.SetActive(true);
             float angle = 360f / newNumber;
@@ -69,12 +77,16 @@ public class SoulFollowEffect : MonoBehaviour
         }
         else
         {
-            for(int i = 0;i< eSpirits.followNumber; i++)
+            soulsList[newNumber].gameObject.SetActive(false);
+            float angle = 360f / newNumber;
+            for (int i = 0; i < newNumber; i++)
             {
-                soulsList[i].gameObject.SetActive(false);
+                float targetRad = angle * i * Mathf.Deg2Rad;
+                soulsList[i].transform.localPosition =
+                    new Vector3(distance * Mathf.Cos(targetRad), distance * Mathf.Sin(targetRad), 0);
             }
         }
-        
+
         soulsNumber = newNumber;
     }
 }

+ 35 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Invisible.cs

@@ -12,6 +12,11 @@ public class Spirits_Invisible : MonoBehaviour
     public PlayerController playerController;
     public float addMp;
     public InvisibleSoulCollector soulCollector;
+    public GameObject soulPrefab;
+    public float distance;
+    public Transform body;
+    public Transform shootPos;
+    public SoulFollowEffect soulFollowEffect;
     private void Start()
     {
         
@@ -27,8 +32,38 @@ public class Spirits_Invisible : MonoBehaviour
     }
     private void Update()
     {
+        if (playerController.btnWestPress)
+        {
+            if (soulCollector.soulNumbers > 0)
+            {
+                soulCollector.soulNumbers--;
+                soulFollowEffect.ShowSouls(soulCollector.soulNumbers);
+                AttackJ();
+            }
+            else if(playerController.mp>=10)
+            {
+                playerController.mp -= 10;
+                AttackJ();
+            }
+            
+        }
     }
     public void BackToPlayer()
     {
     }
+    void AttackJ()
+    {
+        GameObject soulObj = Instantiate(soulPrefab);
+        Soul soul = soulObj.GetComponent<Soul>();
+        soul.from = shootPos.transform.position;
+        if(body.localScale.x > 0)
+        {
+            soul.to = transform.position + Vector3.left * distance;
+        }
+        else
+        {
+            soul.to = transform.position + Vector3.right * distance;
+        }
+        soul.isShoot = true;
+    }
 }