Răsfoiți Sursa

游龙结束后士兵恢复自然状态

WGL 1 lună în urmă
părinte
comite
f7c244da4f

+ 17 - 10
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -1579,6 +1579,21 @@ public class PlayerController : MoveCharacter
     }
 
     public Demonic CreateDemonic(int id)
+    {
+        Demonic demonic = InitDemonic(id);
+        if (!demonicDic.ContainsKey(id))
+        {
+            demonicDic.Add(id, new List<Demonic>());
+        }
+        demonicDic[id].Add(demonic);
+        if (id <= 2)
+        {
+            demonicNums[id].text = demonicDic[id].Count.ToString();
+        }
+        return demonic;
+    }
+
+    public Demonic InitDemonic(int id)
     {
         GameObject demonicObj = PoolManager.Instantiate(demonicPrefabs[id]);
         Demonic demonic = demonicObj.GetComponent<Demonic>();
@@ -1611,7 +1626,7 @@ public class PlayerController : MoveCharacter
                 AttackInfo attackInfo = attackController.attackMethod_march[i].attackInfo;
                 attackInfo.damage += (int)(attackInfo.damage * demonicDic[0].Count * GameManager.instance.attackRate);
                 //Debug.Log("飞行兵的数量是:" + demonicDic[0].Count + ",增加的行军式伤害为" + (int)(attackInfo.damage * demonicDic[0].Count * GameManager.instance.attackRate));
-            }        
+            }
         }
         if (GameManager.instance.isGroundEnable)
         {
@@ -1655,17 +1670,9 @@ public class PlayerController : MoveCharacter
         demonic.Init();
         int order = demonicPrefabs[id].GetComponent<Demonic>().baseSortingOrder + demonicDic[demonic.id].Count;
         demonic.SetSortingOrder(order);
-        if (!demonicDic.ContainsKey(id))
-        {
-            demonicDic.Add(id, new List<Demonic>());
-        }
-        demonicDic[id].Add(demonic);
-        if (id <= 2)
-        {
-            demonicNums[id].text = demonicDic[id].Count.ToString();
-        }
         return demonic;
     }
+
     public void OnDemonicRecycle(Demonic demonic)
     {
         if (!demonicDic.ContainsKey(demonic.id))

+ 10 - 23
ActionTowerDefense/Assets/Scripts/Conduct/DragonController.cs

@@ -67,7 +67,15 @@ public class DragonController : MonoBehaviour
             demonic.beHitTrigger.gameObject.SetActive(true);
             demonic.beSearchTrigger.gameObject.SetActive(true);
             demonic.dragonTrigger.gameObject.SetActive(false);
-            demonic.gameObject.SetActive(false);
+            if (!player.demonicDic.ContainsKey(demonicId))
+            {
+                player.demonicDic.Add(demonicId, new List<Demonic>());
+            }
+            player.demonicDic[demonicId].Add(demonic);
+            if (demonicId <= 2)
+            {
+                player.demonicNums[demonicId].text = player.demonicDic[demonicId].Count.ToString();
+            }
         }
         gameObject.SetActive(false);
     }
@@ -99,10 +107,7 @@ public class DragonController : MonoBehaviour
 
     public Demonic CreateDemonic()
     {
-        GameObject demonicPrefabs = player.demonicPrefabs[demonicId];
-        GameObject demonicObj = PoolManager.Instantiate(demonicPrefabs);
-        Demonic demonic = demonicObj.GetComponent<Demonic>();
-        float dir = player.bodyTrans.localScale.x;
+        Demonic demonic = player.InitDemonic(demonicId);
         demonic.ignoresOnState = true;
         AttackTrigger dragonTrigger = demonic.dragonTrigger;
         dragonTrigger.gameObject.SetActive(true);
@@ -110,24 +115,6 @@ public class DragonController : MonoBehaviour
         demonic.beHitTrigger.gameObject.SetActive(false);
         demonic.beSearchTrigger.gameObject.SetActive(false);
         demonic.ani.Play(AnimatorHash.ANIMATOR_walk, 0, 0);
-        Vector3 offset = player.demonicSummonPos[demonicId];
-        if (dir > 0)
-        {
-            if (demonic.bodyTrans.localScale.x < 0)
-            {
-                demonic.Turn();
-            }
-        }
-        else
-        {
-            if (demonic.bodyTrans.localScale.x > 0)
-            {
-                demonic.Turn();
-            }
-        }
-        playerOffset = new Vector3(dir > 0 ? offset.x : -offset.x, offset.y, offset.z);
-        demonicObj.transform.position = player.transform.position + playerOffset;
-        demonic.Init();
         return demonic;
     }
 }