浏览代码

修复boss出生时报错

WGL 2 月之前
父节点
当前提交
e007cb3325

+ 192 - 139
ActionTowerDefense/Assets/Resources/Prefab/Boss/WaterSprite/Boss_Braid.prefab

@@ -65,53 +65,70 @@ MonoBehaviour:
   isSingleAttack: 0
   cantSingleAttack: 0
   trigedObjs: []
-  attackInfo:
-    attackValue: 0
-    damage: 0
-    attackDir: {x: 0, y: 0, z: 0}
-    effect: {fileID: 0}
-    attackEffect: 
-    attackMethod_Type: 0
-    floatState:
-      time: 0
-      upTime: {x: 0, y: 0}
-      backSpeed: {x: 0, y: 0}
-      rotateSpeed: {x: 0, y: 0}
-      height: {x: 0, y: 0}
-      ControlOrder: 0
-    blowUp:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamageRate: 0
-      ControlOrder: 0
-    shotDown:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamage: 0
-      ControlOrder: 0
-    weak:
-      time: 0
-      ControlOrder: 0
-    armorPiercing:
-      rate: 0
-    vulnerable:
-      rate: 0
-      time: 0
-    stackingWounds:
-      damage: 0
-      time: 0
-    changeDamage:
-      rate: 0
-    sustainedInjury:
+  attackMethod:
+    attackName: 
+    attackType: 0
+    attackInfo:
+      attackValue: 0
       damage: 0
+      attackDir: {x: 0, y: 0, z: 0}
+      effect: {fileID: 0}
+      attackEffect: 
+      attackMethod_Type: 0
+      floatState:
+        time: 0
+        upTime: {x: 0, y: 0}
+        backSpeed: {x: 0, y: 0}
+        rotateSpeed: {x: 0, y: 0}
+        height: {x: 0, y: 0}
+        ControlOrder: 0
+      blowUp:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamageRate: 0
+        ControlOrder: 0
+      shotDown:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamage: 0
+        ControlOrder: 0
+      weak:
+        time: 0
+        ControlOrder: 0
+      armorPiercing:
+        rate: 0
+      vulnerable:
+        rate: 0
+        time: 0
+      stackingWounds:
+        damage: 0
+        time: 0
+      changeDamage:
+        rate: 0
+      sustainedInjury:
+        damage: 0
+    attackTrigger: {fileID: 0}
+    needToChange: 0
+    attackDistance: 0
+    maxAttackDis: 0
+    minAttackDis: 0
+    searchMode: 0
+    canHitFly: 0
+    bulletPrefab: {fileID: 0}
+    shootPos: []
+    maxUpAngle: 0
+    maxDownAngle: 0
+    shootTrack: 0
+    shootAlwaysTrack: 0
+    skill: {fileID: 0}
   force: {x: 0, y: 0, z: 0}
   changeHurt: 0
   repelValue: 0
@@ -499,7 +516,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 0308c0fef3992584f8f61f226c0836db, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  ws: {fileID: 0}
+  ws: {fileID: 16214313399265845}
   minIdleY: 3
   maxIdleY: 6
   OnWaterPosY: -3
@@ -993,53 +1010,70 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   curSpecialStates: -1
-  attackInfo:
-    attackValue: 0
-    damage: 0
-    attackDir: {x: 0, y: 0, z: 0}
-    effect: {fileID: 0}
-    attackEffect: 
-    attackMethod_Type: 0
-    floatState:
-      time: 0
-      upTime: {x: 0, y: 0}
-      backSpeed: {x: 0, y: 0}
-      rotateSpeed: {x: 0, y: 0}
-      height: {x: 0, y: 0}
-      ControlOrder: 0
-    blowUp:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamageRate: 0
-      ControlOrder: 0
-    shotDown:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamage: 0
-      ControlOrder: 0
-    weak:
-      time: 0
-      ControlOrder: 0
-    armorPiercing:
-      rate: 0
-    vulnerable:
-      rate: 0
-      time: 0
-    stackingWounds:
-      damage: 0
-      time: 0
-    changeDamage:
-      rate: 0
-    sustainedInjury:
+  attackMethod:
+    attackName: 
+    attackType: 0
+    attackInfo:
+      attackValue: 0
       damage: 0
+      attackDir: {x: 0, y: 0, z: 0}
+      effect: {fileID: 0}
+      attackEffect: 
+      attackMethod_Type: 0
+      floatState:
+        time: 0
+        upTime: {x: 0, y: 0}
+        backSpeed: {x: 0, y: 0}
+        rotateSpeed: {x: 0, y: 0}
+        height: {x: 0, y: 0}
+        ControlOrder: 0
+      blowUp:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamageRate: 0
+        ControlOrder: 0
+      shotDown:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamage: 0
+        ControlOrder: 0
+      weak:
+        time: 0
+        ControlOrder: 0
+      armorPiercing:
+        rate: 0
+      vulnerable:
+        rate: 0
+        time: 0
+      stackingWounds:
+        damage: 0
+        time: 0
+      changeDamage:
+        rate: 0
+      sustainedInjury:
+        damage: 0
+    attackTrigger: {fileID: 0}
+    needToChange: 0
+    attackDistance: 0
+    maxAttackDis: 0
+    minAttackDis: 0
+    searchMode: 0
+    canHitFly: 0
+    bulletPrefab: {fileID: 0}
+    shootPos: []
+    maxUpAngle: 0
+    maxDownAngle: 0
+    shootTrack: 0
+    shootAlwaysTrack: 0
+    skill: {fileID: 0}
   attributeTime: 0
   floatingState: 0
   hitState: 0
@@ -1076,59 +1110,78 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   freezeFrame: 0
+  attackFromHasFreezeFrame: 0
   isFreeze: 0
   canFreeze: 0
   curCharacterState: 0
-  attackInfoData:
-    attackValue: 0
-    damage: 0
-    attackDir: {x: 0, y: 0, z: 0}
-    effect: {fileID: 0}
-    attackEffect: 
-    attackMethod_Type: 0
-    floatState:
-      time: 0
-      upTime: {x: 0, y: 0}
-      backSpeed: {x: 0, y: 0}
-      rotateSpeed: {x: 0, y: 0}
-      height: {x: 0, y: 0}
-      ControlOrder: 0
-    blowUp:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamageRate: 0
-      ControlOrder: 0
-    shotDown:
-      directionType: 0
-      dir: {x: 0, y: 0, z: 0}
-      dirRandom: {x: 0, y: 0, z: 0}
-      force: 0
-      time: 0
-      haveLandingDamage: 0
-      landingDamage: 0
-      ControlOrder: 0
-    weak:
-      time: 0
-      ControlOrder: 0
-    armorPiercing:
-      rate: 0
-    vulnerable:
-      rate: 0
-      time: 0
-    stackingWounds:
-      damage: 0
-      time: 0
-    changeDamage:
-      rate: 0
-    sustainedInjury:
+  attackMethod:
+    attackName: 
+    attackType: 0
+    attackInfo:
+      attackValue: 0
       damage: 0
+      attackDir: {x: 0, y: 0, z: 0}
+      effect: {fileID: 0}
+      attackEffect: 
+      attackMethod_Type: 0
+      floatState:
+        time: 0
+        upTime: {x: 0, y: 0}
+        backSpeed: {x: 0, y: 0}
+        rotateSpeed: {x: 0, y: 0}
+        height: {x: 0, y: 0}
+        ControlOrder: 0
+      blowUp:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamageRate: 0
+        ControlOrder: 0
+      shotDown:
+        directionType: 0
+        dir: {x: 0, y: 0, z: 0}
+        dirRandom: {x: 0, y: 0, z: 0}
+        force: 0
+        time: 0
+        haveLandingDamage: 0
+        landingDamage: 0
+        ControlOrder: 0
+      weak:
+        time: 0
+        ControlOrder: 0
+      armorPiercing:
+        rate: 0
+      vulnerable:
+        rate: 0
+        time: 0
+      stackingWounds:
+        damage: 0
+        time: 0
+      changeDamage:
+        rate: 0
+      sustainedInjury:
+        damage: 0
+    attackTrigger: {fileID: 0}
+    needToChange: 0
+    attackDistance: 0
+    maxAttackDis: 0
+    minAttackDis: 0
+    searchMode: 0
+    canHitFly: 0
+    bulletPrefab: {fileID: 0}
+    shootPos: []
+    maxUpAngle: 0
+    maxDownAngle: 0
+    shootTrack: 0
+    shootAlwaysTrack: 0
+    skill: {fileID: 0}
   attackFromData: {fileID: 0}
   hitStunTime: 0
   canHitStun: 0
+  canBeHitStun: 1
 --- !u!1 &16214314209775488
 GameObject:
   m_ObjectHideFlags: 0

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

@@ -138,7 +138,6 @@ public class Boss : MoveCharacter
     public virtual void Start()
     {
         len = circulate.Length;
-        Init();
         int cur = 0;
         categories = new AttackCategories[len];
         foreach(char c in circulate)

+ 81 - 59
ActionTowerDefense/Assets/Scripts/EnemyCreater.cs

@@ -21,6 +21,7 @@ public class EnemyCreater : MonoBehaviour
     public List<List<float>> createEnemyTime1 = new();
     public Dictionary<string, List<Enemy>> enemyDic;
     public Dictionary<string, List<GameObject>> buildingDic;
+    public Dictionary<string, List<Boss>> bossDic;
     public Vector2Int idRange;  //当前关卡为出怪表[x,y]行
     public Vector2Int idRange1;  //当前关卡为出怪表[x,y]行
     public Dictionary<string, EnemyTower> enemyCreateTowerDic;
@@ -98,6 +99,7 @@ public class EnemyCreater : MonoBehaviour
 
         enemyDic = new Dictionary<string, List<Enemy>>();
         buildingDic = new Dictionary<string, List<GameObject>>();
+        bossDic = new Dictionary<string, List<Boss>>();
         enemyCreateTowerDic = new Dictionary<string, EnemyTower>();
         createdEnemy = new List<bool>();
         createEnemyTime = new List<List<float>>();
@@ -483,74 +485,94 @@ public class EnemyCreater : MonoBehaviour
         pos = new Vector3(posx, posy <= 0 ? 0 : posy, 0);
         GameObject enemyObj = Util.Instantiate(enemyStr, pos, active: active);
         AttackInfo attackInfo;
-        if(cfgEnemy.Type == "Tower")
+        switch (cfgEnemy.Type)
         {
-            EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
-            Tower tower = enemyObj.GetComponent<Tower>();
-            if (enemyTower != null)
-            {
-                enemyTower.name = cfgEnemy.Name;
+            case "Tower":
+                EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
+                Tower tower = enemyObj.GetComponent<Tower>();
+                if (enemyTower != null)
+                {
+                    enemyTower.name = cfgEnemy.Name;
 
-                enemyTower.totalHp = (int)(cfgEnemy.HP * HPRatio);
-                enemyTower.hp = enemyTower.totalHp;
+                    enemyTower.totalHp = (int)(cfgEnemy.HP * HPRatio);
+                    enemyTower.hp = enemyTower.totalHp;
 
-                attackInfo = enemyTower.attackController.curAttackMethod.attackInfo;
-                attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
-                enemyTower.attackController.curAttackMethod.attackInfo = attackInfo;
-                enemyTower.Init();
-            }
-            if (tower != null)
-            {
-                tower.name = cfgEnemy.Name;
+                    attackInfo = enemyTower.attackController.curAttackMethod.attackInfo;
+                    attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
+                    enemyTower.attackController.curAttackMethod.attackInfo = attackInfo;
+                    enemyTower.Init();
+                }
+                if (tower != null)
+                {
+                    tower.name = cfgEnemy.Name;
 
-                tower.totalHp = (int)(cfgEnemy.HP * HPRatio);
-                tower.hp = tower.totalHp;
+                    tower.totalHp = (int)(cfgEnemy.HP * HPRatio);
+                    tower.hp = tower.totalHp;
 
-                attackInfo = tower.attackController.curAttackMethod.attackInfo;
-                attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
-                tower.attackController.curAttackMethod.attackInfo = attackInfo;
-                tower.Init();
-            }
-            if (!buildingDic.ContainsKey(cfgEnemy.Name))
-            {
-                buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
-            }
-            buildingDic[cfgEnemy.Name].Add(enemyObj);
-            enemyCreateTowerDic[WaveName] = enemyTower;
+                    attackInfo = tower.attackController.curAttackMethod.attackInfo;
+                    attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
+                    tower.attackController.curAttackMethod.attackInfo = attackInfo;
+                    tower.Init();
+                }
+                if (!buildingDic.ContainsKey(cfgEnemy.Name))
+                {
+                    buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
+                }
+                buildingDic[cfgEnemy.Name].Add(enemyObj);
+                enemyCreateTowerDic[WaveName] = enemyTower;
+                break;
+            case "Boss":
+                Boss boss = enemyObj.GetComponent<Boss>();
+                boss.name = cfgEnemy.Name;
+                if (!bossDic.ContainsKey(cfgEnemy.Name))
+                {
+                    bossDic.Add(cfgEnemy.Name, new List<Boss>());
+                }
+                bossDic[cfgEnemy.Name].Add(boss);
+                boss.hp = boss.totalHp;
+                boss.Init();
+                break;
+            default:
+                Enemy enemy = enemyObj.GetComponent<Enemy>();
+                enemy.name = cfgEnemy.Name;
+                if (!enemyDic.ContainsKey(cfgEnemy.Name))
+                {
+                    enemyDic.Add(cfgEnemy.Name, new List<Enemy>());
+                }
+                enemyDic[cfgEnemy.Name].Add(enemy);
+
+                enemy.totalHp = (int)(cfgEnemy.HP * HPRatio);
+                enemy.hp = enemy.totalHp;
+                enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * SpeedRatio;
+                enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * SpeedRatio;
+
+                enemy.attributeStatus.resistances.armor = (int)(enemy.attributeStatus.resistances.armor * ArmorRatio + 0.5f);
+                foreach (var item in enemy.attackController.attackMethod_summon)
+                {
+                    item.attackInfo.damage = (int)(cfgEnemy.AttackSummon * AttackRatio);
+                    item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
+                }
+                for (int i = 0; i < enemy.attackController.attackMethod_march.Length; i++)
+                {
+                    var item = enemy.attackController.attackMethod_march[i];
+                    item.attackInfo.damage = (int)(cfgEnemy.AttackMarch[i] * AttackRatio);
+                    item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
+                }
+                if (enemy.canFly)
+                {
+                    enemy.flyHeight = enemy.transform.position.y;
+                }
+                enemy.Init();
+                enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[cfgEnemy.Name].Count);
+                break;
         }
-        else
+        if(cfgEnemy.Type == "Tower")
         {
-            Enemy enemy = enemyObj.GetComponent<Enemy>();
-            enemy.name = cfgEnemy.Name;
-            if (!enemyDic.ContainsKey(cfgEnemy.Name))
-            {
-                enemyDic.Add(cfgEnemy.Name, new List<Enemy>());
-            }
-            enemyDic[cfgEnemy.Name].Add(enemy);
 
-            enemy.totalHp = (int)(cfgEnemy.HP * HPRatio);
-            enemy.hp = enemy.totalHp;
-            enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * SpeedRatio;
-            enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * SpeedRatio;
+        }
+        else
+        {
 
-            enemy.attributeStatus.resistances.armor = (int)(enemy.attributeStatus.resistances.armor * ArmorRatio + 0.5f);
-            foreach (var item in enemy.attackController.attackMethod_summon)
-            {
-                item.attackInfo.damage = (int)(cfgEnemy.AttackSummon * AttackRatio);
-                item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
-            }
-            for(int i = 0; i < enemy.attackController.attackMethod_march.Length; i++)
-            {
-                var item = enemy.attackController.attackMethod_march[i];
-                item.attackInfo.damage = (int)(cfgEnemy.AttackMarch[i] * AttackRatio);
-                item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
-            }
-            if (enemy.canFly)
-            {
-                enemy.flyHeight = enemy.transform.position.y;
-            }
-            enemy.Init();
-            enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[cfgEnemy.Name].Count);
         }
         enemyObj.transform.position = pos;
         return enemyObj;