Browse Source

实现木岩的20➕20标签技能,优化天地的标签技能,现在召唤多个士兵有时间间隔和重复动作

HY-LSZNWIN10\Administrator 1 tháng trước cách đây
mục cha
commit
9cd8c2fda9

+ 17 - 9
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -740,15 +740,6 @@ public class Demonic : MoveCharacter
             case CharacterState.Attack:
                 break;
             case CharacterState.Die:
-                if (GameManager.instance.isSkyGroundIceEnable)
-                {
-                    int randomInt = Random.Range(0, 100);
-                    if (randomInt < GameManager.instance.skyGroundProbability)
-                    {
-                        player.nextSummonNum++;
-                        GameUI.instance.summonNum.text = player.nextSummonNum.ToString();
-                    }
-                }
                 if (canFly)
                 {
                     if (isDie)
@@ -788,6 +779,23 @@ public class Demonic : MoveCharacter
                     //    }
                     //}
                 }
+                if (GameManager.instance.isSkyGroundIceEnable)
+                {
+                    int randomInt = Random.Range(0, 100);
+                    if (randomInt < GameManager.instance.skyGroundProbability)
+                    {
+                        player.nextSummonNum++;
+                        GameUI.instance.summonNum.text = player.nextSummonNum.ToString();
+                    }
+                }
+                if (GameManager.instance.isWoodRockEnable)
+                {
+                    int randomInt = Random.Range(0, 100);
+                    if (randomInt < GameManager.instance.woodRockProbability)
+                    {
+                        player.CheckReborn(this);
+                    }
+                }
                 summonEndToDie = false;
                 canSizeChange = false;
                 bigSoldier.enabled = false;

+ 12 - 8
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -673,7 +673,17 @@ public class Enemy : MoveCharacter
                     int randomInt = Random.Range(0, 100);
                     if (randomInt < GameManager.instance.rockProbability)
                     {
-                        PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/StoneStatue"), transform.position);
+                        RebornSkill rebornSkill = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/StoneStatue"), transform.position).GetComponentInChildren<RebornSkill>();
+                        GameManager.instance.player.rebornSkills.Add(rebornSkill);
+                    }
+                }
+                if (GameManager.instance.isWoodEnable)
+                {
+                    int randomInt = Random.Range(0, 100);
+                    if (randomInt < GameManager.instance.woodProbability)
+                    {
+                        RebornSkill rebornSkill = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/SoulFlower"), transform.position).GetComponent<RebornSkill>();
+                        GameManager.instance.player.rebornSkills.Add(rebornSkill);
                     }
                 }
                 break;
@@ -684,12 +694,6 @@ public class Enemy : MoveCharacter
 
     public void DropSouls()
     {
-        int randomInt;
-        if (GameManager.instance.isWoodEnable)
-        {
-            randomInt = Random.Range(0, 100);
-            if (randomInt < GameManager.instance.woodProbability) PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/SoulFlower"), transform.position);
-        }
         int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
         if (dropSoulNum > 1)
         {
@@ -707,7 +711,7 @@ public class Enemy : MoveCharacter
         }
         else
         {
-            randomInt = Random.Range(0, 100);
+            int randomInt = Random.Range(0, 100);
             if (randomInt >= dropProbability)
             {
                 return;

+ 0 - 1
ActionTowerDefense/Assets/Scripts/Characters/MoveCharacter.cs

@@ -664,6 +664,5 @@ public class MoveCharacter : Character
         if (electrifyEffect != null) electrifyEffect.SetActive(false);
         ani.speed = 1;
         moveSpeedScale = 1f;
-        Debug.Log("ʧ»î");
     }
 }

+ 75 - 7
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -160,6 +160,7 @@ public class PlayerController : MoveCharacter
     //怨气弹
     public GameObject angryBulletObj;
     [Header("怨气弹数量基数")] public int angryBulletNum;
+    [Header("士兵复活点位")] [ShowInInspector] public List<RebornSkill> rebornSkills = new List<RebornSkill>();
 
     public bool btnJumpPress
     {
@@ -1468,8 +1469,8 @@ public class PlayerController : MoveCharacter
 
     public void Summon(int id)
     {
-        ChangeState(CharacterState.Summon);
-        summonTime = totalSummonTime;
+        //ChangeState(CharacterState.Summon);
+        //summonTime = totalSummonTime;
         Demonic dem = demonicPrefabs[id].GetComponent<Demonic>();
         float costMp = dem.costMp;
         for (int i = 0; i < 3; i++)
@@ -1482,16 +1483,76 @@ public class PlayerController : MoveCharacter
         }
         mp -= costMp;
         uiMp.Show(mp, totalMp);
-        for (int i = 0; i < nextSummonNum; i++)
+        StartCoroutine(SummonDemoic(id));
+        //for (int i = 0; i < nextSummonNum; i++)
+        //{
+        //    Demonic demonic = CreateDemonic(id);
+        //    if (demonic.canFly)
+        //    {
+        //        if (i > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), 0);
+        //    }
+        //    else
+        //    {
+        //        if (i > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(0f, 0.5f), 0);
+        //    }
+
+        //    int attackSummonId = nowAttackSummonID;
+
+        //    if (lastSoldier != demonic.soldierType)
+        //    {
+        //        attackSummonId = 0;
+        //    }
+        //    demonic.attackController.attackSummonId = attackSummonId;
+        //    onlySummonTime = demonic.attackController.summonTime[attackSummonId];
+        //    invincibleTime = onlySummonTime + addSummonInvincibleTime;
+        //    restSummonTime = onlySummonTime;
+        //    demonic.Attack_summon();
+        //    lastSoldier = demonic.soldierType;
+        //    attackSummonId++;
+        //    if (attackSummonId >= demonic.attackController.attackMethod_summon.Length)
+        //    {
+        //        attackSummonId = 0;
+        //        AttackSummonChangeTime = 0;
+        //    }
+        //    else
+        //    {
+        //        AttackSummonChangeTime = AttackSummonChangeTotalTime;
+        //    }
+        //    nowAttackSummonID = attackSummonId;
+        //    //id 3~6 为四个英灵
+        //    if (id >= 3)
+        //    {
+        //        spirits.ultimateTimes[id - 3] -= spirits.summonCost;
+        //    }
+        //    spiritSystem.RefreshPlayerUI();
+        //    if (isInSoulTower)
+        //    {
+        //        ls.AddDenomic(demonic);
+        //    }
+        //}
+        //nextSummonNum = 1;
+        //GameUI.instance.summonNum.text = nextSummonNum.ToString();
+
+    }
+
+    IEnumerator<WaitForSeconds> SummonDemoic(int id)
+    {
+        int count = 0;
+        int num = nextSummonNum;
+        nextSummonNum = 1;
+        GameUI.instance.summonNum.text = nextSummonNum.ToString();
+        while (count < num)
         {
+            ChangeState(CharacterState.Summon);
+            summonTime = totalSummonTime;
             Demonic demonic = CreateDemonic(id);
             if (demonic.canFly)
             {
-                if (i > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), 0);
+                if (count > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), 0);
             }
             else
             {
-                if (i > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(-0.5f, 0.5f), 0);
+                if (count > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(0f, 0.5f), 0);
             }
 
             int attackSummonId = nowAttackSummonID;
@@ -1527,9 +1588,10 @@ public class PlayerController : MoveCharacter
             {
                 ls.AddDenomic(demonic);
             }
+            count++;
+            yield return new WaitForSeconds(0.1f);
         }
-        nextSummonNum = 1;
-        GameUI.instance.summonNum.text = nextSummonNum.ToString();
+        yield return null;
 
     }
 
@@ -1735,4 +1797,10 @@ public class PlayerController : MoveCharacter
         }
         GameUI.instance.HurtMask((hp *1f)/totalHp);
     }
+
+    public void CheckReborn(Demonic demonic)
+    {
+        if (rebornSkills.Count == 0) return;
+        rebornSkills[0].Reborn(this, demonic.id);
+    }
 }

+ 13 - 5
ActionTowerDefense/Assets/Scripts/Characters/StoneStatue.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using UnityEngine;
 using Sirenix.OdinInspector;
 
-public class StoneStatue:MonoBehaviour
+public class StoneStatue:MonoBehaviour,RebornSkill
 {
     public GameObject bulletPrefab;
     public GameObject parent;
@@ -131,9 +131,17 @@ public class StoneStatue:MonoBehaviour
         //Debug.Log($"发射子弹,方向:{direction},速度:{velocity.magnitude}");
     }
 
+    public void Reborn(PlayerController player, int id)
+    {
+        Demonic demonic = player.CreateDemonic(id);
+        demonic.transform.position = transform.position;
+        demonic.attackController.attackSummonId = 0;
+        demonic.Attack_summon();
+        Shoot(new Vector3(-1, 0, 0), demonic);
+    }
 
-    //public override void Init()
-    //{
-    //    base.Init();
-    //}
+    private void OnDisable()
+    {
+        GameManager.instance.player.rebornSkills.Remove(this);
+    }
 }

+ 3 - 0
ActionTowerDefense/Assets/Scripts/GameManager.cs

@@ -112,6 +112,9 @@ public class GameManager : MonoBehaviour
     [FoldoutGroup("标签/岩")] [LabelText("触发概率")] [PropertyRange(0, 100)] public int rockProbability = 100;
     [FoldoutGroup("标签/岩")] [LabelText("石像预制体")] public GameObject stoneStatuePrefab;
 
+    [FoldoutGroup("标签/木岩")] [LabelText("是否启用")] public bool isWoodRockEnable = false;
+    [FoldoutGroup("标签/木岩")] [LabelText("触发概率")] [PropertyRange(0, 100)] public int woodRockProbability = 100;
+
     [FoldoutGroup("标签/天")] [LabelText("是否启用")] public bool isSkyEnable = false;
     [FoldoutGroup("标签/天")] [LabelText("每个兵提供的攻击buff比率")] public float attackRate = 0.01f;
     //[FoldoutGroup("标签/天")] [LabelText("最大比例")] public float maxScale = 2;

+ 8 - 0
ActionTowerDefense/Assets/Scripts/RebornSkill.cs

@@ -0,0 +1,8 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public interface RebornSkill
+{
+    public abstract void Reborn(PlayerController player, int id);
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/RebornSkill.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d1eeee66243567a42a347001e505ec7d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 16 - 1
ActionTowerDefense/Assets/Scripts/SoulFlower.cs

@@ -2,7 +2,7 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
-public class SoulFlower : MonoBehaviour
+public class SoulFlower : MonoBehaviour,RebornSkill
 {
     public GameObject soulPrefab;
     public float soulStartSpeed = 1f;
@@ -22,6 +22,11 @@ public class SoulFlower : MonoBehaviour
         DropSouls();
     }
 
+    private void OnDisable()
+    {
+        GameManager.instance.player.rebornSkills.Remove(this);
+    }
+
     private void Update()
     {
         if(Time.time - dropTimer > dropInterval)
@@ -60,4 +65,14 @@ public class SoulFlower : MonoBehaviour
             soul.Burst(dir * soulStartSpeed);
         }
     }
+
+    public void Reborn(PlayerController player,int id)
+    {
+        DropSouls();
+        Demonic demonic = player.CreateDemonic(id);
+        demonic.transform.position = transform.position;
+        demonic.attackController.attackSummonId = 0;
+        demonic.Attack_summon();
+        gameObject.SetActive(false);
+    }
 }