Преглед изворни кода

实现boss的第一版多阶段功能,给二三阶段加了连击效果

HY-LSZNWIN10\Administrator пре 1 недеља
родитељ
комит
38b776602e

+ 1 - 1
ActionTowerDefense/Assets/Resources/Prefab/Arrow_shurikan_Boss.prefab

@@ -9799,7 +9799,7 @@ MonoBehaviour:
     attackName: 
     attackType: 0
     attackInfo:
-      attackValue: 0
+      attackValue: 10
       damage: 40
       attackDir: {x: 0, y: 0, z: 0}
       criticalChance: 0

+ 46 - 19
ActionTowerDefense/Assets/Resources/Prefab/Boss/WaterSprite/Boss_Braid.prefab

@@ -77,7 +77,9 @@ MonoBehaviour:
       criticalChance: 0
       criticalStrikeEffect: 0
       lifesteal: 0
-      effect: {fileID: 0}
+      attackOnEffect: {fileID: 0}
+      attackOnEffectPos: {fileID: 0}
+      hitEffect: {fileID: 0}
       attackEffect: 
       attackMethod_Type: 0
       floatState:
@@ -389,21 +391,23 @@ MonoBehaviour:
   statOfPhase:
   - hpRadioThreshold: 1
     maxInterval: 3
-    minInterval: 2
+    minInterval: 2.6
   - hpRadioThreshold: 0.6
-    maxInterval: 1.8
-    minInterval: 1.2
-  - hpRadioThreshold: 0.25
-    maxInterval: 1
-    minInterval: 0.8
+    maxInterval: 2.6
+    minInterval: 2.4
+  - hpRadioThreshold: 0.3
+    maxInterval: 2.4
+    minInterval: 2
   idleAniNames:
   - idle
   - idle2
   weight: 0300000001000000
   circulate:
-  - BBB
-  - CCC
-  categories: 000000000100000002000000
+  - BBBA
+  - C
+  - DDDA
+  - EEEAEEEEA
+  categories: 0000000001000000020000000300000004000000
   curInterval: 0
   bossState: 0
   weakTime: 6
@@ -425,6 +429,8 @@ MonoBehaviour:
   dropSoulMax: 6
   dropSoulMin: 3
   dropSoulAngle: 60
+  attackCount: 0
+  comboInterval: 0.5
   attackConfigurations:
   - category: 0
     attacks:
@@ -433,7 +439,7 @@ MonoBehaviour:
   - category: 1
     attacks:
     - attack: 1
-      weight: 8
+      weight: 3
     - attack: 3
       weight: 0
     - attack: 5
@@ -442,16 +448,31 @@ MonoBehaviour:
     attacks:
     - attack: 3
       weight: 1
+  - category: 3
+    attacks:
+    - attack: 1
+      weight: 1
+    - attack: 3
+      weight: 1
+    - attack: 5
+      weight: 2
+  - category: 4
+    attacks:
+    - attack: 1
+      weight: 1
+    - attack: 3
+      weight: 2
+    - attack: 5
+      weight: 2
   smokeFx: {fileID: 417478504669294145, guid: db445634305994d48be096bffc1684d0, type: 3}
   bodyFlickerTime: 1
   isDisappear: 0
   polliNum: 50
   pws: {fileID: 566765055176838525}
-  changeStateHPPer: 500000003200000014000000
+  changeStateHPPer: 50000000320000001e0000000a000000
   polliTime: 5
-  hpRadioOfPhase: 0.99
   angryAttackInterval: 1.5
-  angryDuration: 9
+  angryDuration: 10
   isHoldingUmbre: 1
   attackNum: 0
 --- !u!114 &16214313399265844
@@ -486,7 +507,9 @@ MonoBehaviour:
       criticalChance: 0
       criticalStrikeEffect: 0
       lifesteal: 0
-      effect: {fileID: 0}
+      attackOnEffect: {fileID: 0}
+      attackOnEffectPos: {fileID: 0}
+      hitEffect: {fileID: 0}
       attackEffect: 
       attackMethod_Type: 0
       floatState:
@@ -587,8 +610,8 @@ MonoBehaviour:
   maxLength: 12
   singleJumpTime: 2.333
   isHitWater: 0
-  minJumpCount: 3
-  maxJumpCount: 5
+  minJumpCount: 1
+  maxJumpCount: 2
   leafGhostPre: {fileID: 8023685214597940645, guid: 6b02b98183385a547a11b1f1453fa3a6, type: 3}
 --- !u!1 &16214313449006091
 GameObject:
@@ -1079,7 +1102,9 @@ MonoBehaviour:
       criticalChance: 0
       criticalStrikeEffect: 0
       lifesteal: 0
-      effect: {fileID: 0}
+      attackOnEffect: {fileID: 0}
+      attackOnEffectPos: {fileID: 0}
+      hitEffect: {fileID: 0}
       attackEffect: 
       attackMethod_Type: 0
       floatState:
@@ -1195,7 +1220,9 @@ MonoBehaviour:
       criticalChance: 0
       criticalStrikeEffect: 0
       lifesteal: 0
-      effect: {fileID: 0}
+      attackOnEffect: {fileID: 0}
+      attackOnEffectPos: {fileID: 0}
+      hitEffect: {fileID: 0}
       attackEffect: 
       attackMethod_Type: 0
       floatState:

+ 2 - 1
ActionTowerDefense/Assets/Resources/Prefab/Boss/WaterSprite/Boss_Umbrella.prefab

@@ -226,7 +226,7 @@ MonoBehaviour:
     attackType: 0
     attackInfo:
       attackValue: 0
-      damage: 100
+      damage: 50
       attackDir: {x: 0, y: 0, z: 0}
       criticalChance: 0
       criticalStrikeEffect: 0
@@ -249,6 +249,7 @@ MonoBehaviour:
         time: 0
         haveLandingDamage: 0
         landingDamageRate: 0
+        jumpNum: 0
         ControlOrder: 0
       shotDown:
         directionType: 0

+ 13 - 13
ActionTowerDefense/Assets/Resources/Prefab/FX/smoke_boom.prefab

@@ -4857,7 +4857,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -1
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -9783,7 +9783,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -2
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -14671,7 +14671,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -2
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -19559,7 +19559,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -5
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -24429,7 +24429,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: 10
+  m_SortingOrder: 0
   m_RenderMode: 1
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -29299,7 +29299,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -3
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -34169,7 +34169,7 @@ ParticleSystemRenderer:
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: -1730265859
   m_SortingLayer: 4
-  m_SortingOrder: -2
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -39045,9 +39045,9 @@ ParticleSystemRenderer:
   m_AutoUVMaxDistance: 0.5
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
-  m_SortingLayerID: 341237651
-  m_SortingLayer: 3
-  m_SortingOrder: 5000
+  m_SortingLayerID: -1730265859
+  m_SortingLayer: 4
+  m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
   m_SortMode: 0
@@ -43915,9 +43915,9 @@ ParticleSystemRenderer:
   m_AutoUVMaxDistance: 0.5
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
-  m_SortingLayerID: 341237651
-  m_SortingLayer: 3
-  m_SortingOrder: 2
+  m_SortingLayerID: -1730265859
+  m_SortingLayer: 4
+  m_SortingOrder: 0
   m_RenderMode: 1
   m_MeshDistribution: 0
   m_SortMode: 0

+ 29 - 9
ActionTowerDefense/Assets/Scripts/Boss/Boss.cs

@@ -11,6 +11,8 @@ public enum AttackCategories
     A = 0,
     B = 1,
     C = 2,
+    D = 3,
+    E = 4,
 }
 
 public class Boss : MoveCharacter
@@ -76,15 +78,15 @@ public class Boss : MoveCharacter
     private GameObject bossRoomIns;
     private int startHP;            //开始计数的血量
     private ChangeRoomState rs;
-    private bool isToBossRoom;      //要切换到boss空间中
-    private bool isInBossRoom;      //在boss空间中
+    protected bool isToBossRoom;      //要切换到boss空间中
+    protected bool isInBossRoom;      //在boss空间中
     [LabelText("切换到boss空间的血量扣除值")]
     public float toBossNeedHP;
     [LabelText("切换到boss空间的次数")]
     public int toBossTime;
     [LabelText("切换回原空间所需的时间")]
     public float toOrigNeedTime;
-    private float changeBackTime;
+    protected float changeBackTime;
     [LabelText("切换到原空间所需的血量")]
     public float toOrigNeedHP;
     //动画时长
@@ -164,6 +166,12 @@ public class Boss : MoveCharacter
                 case 'C':
                     categories[cur] = AttackCategories.C;
                     break;
+                case 'D':
+                    categories[cur] = AttackCategories.D;
+                    break;
+                case 'E':
+                    categories[cur] = AttackCategories.E;
+                    break;
                 default:
                     break;
             }
@@ -190,6 +198,12 @@ public class Boss : MoveCharacter
                 case 'C':
                     categories[cur] = AttackCategories.C;
                     break;
+                case 'D':
+                    categories[cur] = AttackCategories.D;
+                    break;
+                case 'E':
+                    categories[cur] = AttackCategories.E;
+                    break;
                 default:
                     break;
             }
@@ -319,7 +333,7 @@ public class Boss : MoveCharacter
         ani.speed = 1;
     }
 
-    private void OnBossState()
+    protected void OnBossState()
     {
         switch (bossState)
         {
@@ -345,7 +359,7 @@ public class Boss : MoveCharacter
         {
             return;
         }
-        Debug.Log("从" + state + "切换到" + newState);
+        //Debug.Log("从" + state + "切换到" + newState);
         switch (state)
         {
             case CharacterState.Attack:
@@ -496,11 +510,17 @@ public class Boss : MoveCharacter
             case AttackCategories.C:
                 RandomAttackType(AttackCategories.C);
                 break;
+            case AttackCategories.D:
+                RandomAttackType(AttackCategories.D);
+                break;
+            case AttackCategories.E:
+                RandomAttackType(AttackCategories.E);
+                break;
             default:
                 break;
         }
         curCategoryID++;
-        if (curCategoryID == len)
+        if (curCategoryID > categories.Length - 1)
         {
             curCategoryID = 0;
         }
@@ -572,8 +592,8 @@ public class Boss : MoveCharacter
                 break;
         }
     }
-    
-    private void OnChangeBG()
+
+    protected void OnChangeBG()
     {
         switch (rs)
         {
@@ -610,7 +630,7 @@ public class Boss : MoveCharacter
     }
 
     //拉入boss房间(通过切换bg实现)
-    private void ChangeBG(bool isToBossBG)
+    protected void ChangeBG(bool isToBossBG)
     {
         if (isToBossBG)
         {

+ 112 - 20
ActionTowerDefense/Assets/Scripts/Boss/WaterGhost/WaterSprite.cs

@@ -5,6 +5,8 @@ using Sirenix.OdinInspector;
 
 public class WaterSprite : Boss
 {
+    public int attackCount = 0;
+    public float comboInterval;
     public enum AttackMethods
     {
         Move,       //移动,浮空+点水,动画控制高度,代码控制位移x;点水处生化
@@ -67,7 +69,6 @@ public class WaterSprite : Boss
     private float pastPoliTime;         //已经过去的蝌蚪时间
 
     [Header("变化阶段")]
-    [LabelText("转阶段的生命比例")] public float hpRadioOfPhase;
     [LabelText("愤怒状态攻击间隔")] public float angryAttackInterval;
     [LabelText("愤怒状态持续时间")] public float angryDuration;
     private float angryTimer;
@@ -146,8 +147,8 @@ public class WaterSprite : Boss
             {
                 Debug.Log("退出愤怒状态");
                 isAngry = false;
-                ChangeCirculate(0);
                 bodyTrans.gameObject.SetActive(true);
+                ChangeCirculate(2);
             }
         }
         if(!isHoldingUmbre) attack.OnBlackUmbrella();
@@ -179,27 +180,30 @@ public class WaterSprite : Boss
         int[] powers = new int[attacks.Length];
         for (int i = 0; i < attacks.Length; i++)
         {
+            if (curAttackType == AttackMethods.Umbrella && !isHoldingUmbre && attacks[i].attack == AttackMethods.Umbrella)
+            {
+                continue;
+            }
             powers[i] = attacks[i].weight;
         }
-        //int a = RandomWithWeight(powers);
-        //curAttackType = attacks[a].attack;
-
-        bool result = false;
-        while (!result)
+        int a = RandomWithWeight(powers);
+        curAttackType = attacks[a].attack;
+        attackCount = 1;
+        switch (curAttackType)
         {
-            int a = RandomWithWeight(powers);
-            curAttackType = attacks[a].attack;
-            result = true;
-            if (curAttackType == AttackMethods.Umbrella && !isHoldingUmbre)
-            {
-                result = false;
-            }
+            case AttackMethods.Hair:
+                if (bossPhase == 2) attackCount = Random.Range(1, 3);
+                break;
+            case AttackMethods.Shoot:
+                if (bossPhase == 2) attackCount = Random.Range(1, 3);
+                if (bossPhase == 2) attackCount = Random.Range(2, 4);
+                break;
         }
-
     }
 
     public override void Attack()
     {
+        attackCount--;
         switch (curAttackType)
         {
             case AttackMethods.Move:
@@ -253,6 +257,7 @@ public class WaterSprite : Boss
                 RandomAttackState();
                 break;
             case 2:
+                ChangeCirculate(3);
                 break;
         }
     }
@@ -265,6 +270,77 @@ public class WaterSprite : Boss
             umbrella.SetActive(false);
         }
     }
+    public override void OnState()
+    {
+        switch (state)
+        {
+            case CharacterState.Idle:
+                if (isToBossRoom)
+                {
+                    OnChangeBG();
+                }
+                else if(attackCount > 0)
+                {
+                    curInterval -= Time.deltaTime;
+                    if (curInterval <= 0)
+                    {
+                        //Debug.Log("触发连招");
+                        ChangeState(CharacterState.Attack);
+                    }
+                }
+                else if (bossState != BossState.weak)
+                {
+                    //Debug.Log(curInterval);
+                    curInterval -= Time.deltaTime;
+                    if (curInterval <= 0)
+                    {
+                        RandomAttackState();
+                    }
+                }
+                break;
+            case CharacterState.Run:
+                OnMove();
+                break;
+            case CharacterState.Attack:
+                OnAttack();
+                break;
+            case CharacterState.HitStun:
+                hitFeedbackSystem.HitStunUpdate();
+                break;
+            case CharacterState.SpecialStatus_Float:
+                attributeStatus.SpecialStateEffect(SpecialState.FloatState);
+                break;
+            case CharacterState.SpecialStatus_BlowUp:
+                attributeStatus.SpecialStateEffect(SpecialState.BlownUp);
+                break;
+            case CharacterState.SpecialStatus_ShotDown:
+                attributeStatus.SpecialStateEffect(SpecialState.ShotDown);
+                break;
+            case CharacterState.SpecialStatus_Weak:
+                attributeStatus.SpecialStateEffect(SpecialState.Weak);
+                break;
+            default:
+                break;
+        }
+        if (isInBossRoom)
+        {
+            changeBackTime += Time.deltaTime;
+            if (changeBackTime >= toOrigNeedTime)
+            {
+                ChangeBG(false);
+                changeBackTime = 0;
+            }
+        }
+        OnBossState();
+        if (stage < hpRadio.Length)
+        {
+            if ((float)hp / (float)totalHp < hpRadio[stage])
+            {
+                stage++;
+                DropSouls();
+            }
+        }
+    }
 
     public override void OnAttack()
     {
@@ -300,7 +376,7 @@ public class WaterSprite : Boss
                     }
                     attack.KunaiAttack((pc.transform.position - pws.transform.position).normalized, num);
                     BodyFlickerAppear();
-                    ChangeState(CharacterState.Run);
+                    EndCurAttackState(true);
                 }
                 break;
             default:
@@ -311,8 +387,8 @@ public class WaterSprite : Boss
     #region 瞬身相关
     public void BodyFlickerDisappear()
     {
-        if (isDisappear) return;
-        Debug.Log("瞬身开始");
+        if (isDisappear || curBossStage == BossStage.polliwog) return;
+        //Debug.Log("瞬身开始");
         bodyTrans.gameObject.SetActive(false);
         PoolManager.Instantiate(smokeFx, transform.position);
         ChangeBossState(BossState.invincible);
@@ -322,12 +398,28 @@ public class WaterSprite : Boss
 
     public void BodyFlickerAppear()
     {
-        if (!isDisappear) return;
-        Debug.Log("瞬身结束");
+        if (!isDisappear || curBossStage == BossStage.polliwog) return;
+        //Debug.Log("瞬身结束");
         bodyTrans.gameObject.SetActive(true);
         PoolManager.Instantiate(smokeFx, transform.position);
         ChangeBossState(BossState.normal);
         isDisappear = false;
     }
+
+    public override void EndCurAttackState(bool hasIntervalTime)
+    {
+        //和下一个动作有没有间隔
+        if (hasIntervalTime)
+        {
+            if (attackCount <= 0)
+            {
+                if (bossPhase < statOfPhase.Length) curInterval = Random.Range(statOfPhase[bossPhase].minInterval, statOfPhase[bossPhase].maxInterval);
+                else Debug.LogError("没有配置该阶段属性");
+            }
+            else curInterval = comboInterval;
+        }
+        ChangeState(CharacterState.Idle);
+        ChangeBossState(BossState.rise);
+    }
     #endregion
 }

+ 1 - 0
ActionTowerDefense/Assets/Scripts/Boss/WaterGhost/WaterSpriteAttackController.cs

@@ -158,6 +158,7 @@ public class WaterSpriteAttackController : AttackController
             GameObject obj = PoolManager.Instantiate(kunaiPrefab, ws.pws.transform.position, Quaternion.identity, null);
             Bullet bullet = obj.GetComponent<Bullet>();
             bullet.BeShoot(ws, ws.pws.transform.position, bulletDir);
+            bullet.attackMethod.attackInfo.damage = 40;
         }
     }