Prechádzať zdrojové kódy

boss关切换场景

1243896040 5 hodín pred
rodič
commit
646e7612d6

+ 15 - 14
ActionTowerDefense/Assets/Resources/Prefab/GameManager.prefab

@@ -52,6 +52,21 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: a63e480014f84f04c8f1bb1145122988, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  p1uiHP: {fileID: 0}
+  p1uiMP: {fileID: 0}
+  p1uiRush: {fileID: 0}
+  demonicNum:
+  - {fileID: 0}
+  - {fileID: 0}
+  - {fileID: 0}
+  text: {fileID: 0}
+  chapterBG: {fileID: 0}
+  shopButton: {fileID: 0}
+  shopUI: {fileID: 0}
+  skillUI: {fileID: 0}
+  moneyText: {fileID: 0}
+  player: {fileID: 0}
+  bossSceneName: Game_Boss
   demonicAttributes:
   - skillTree:
     - skillType: 1
@@ -280,20 +295,6 @@ MonoBehaviour:
     trigger1: 0
     trigger2: 0
   gradeInterval: 3
-  p1uiHP: {fileID: 0}
-  p1uiMP: {fileID: 0}
-  p1uiRush: {fileID: 0}
-  demonicNum:
-  - {fileID: 0}
-  - {fileID: 0}
-  - {fileID: 0}
-  text: {fileID: 0}
-  chapterBG: {fileID: 0}
-  shopButton: {fileID: 0}
-  shopUI: {fileID: 0}
-  skillUI: {fileID: 0}
-  moneyText: {fileID: 0}
-  player: {fileID: 0}
   rewardTime: 90
   totalMoney: 600
   extraMoney: 100

+ 59 - 47
ActionTowerDefense/Assets/Scripts/GameManager.cs

@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.IO;
 using TMPro;
 using UnityEngine;
+using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 using Spine.Unity;
 public enum AttributeTag
@@ -50,13 +51,7 @@ public enum TargetType
 public class GameManager : MonoBehaviour
 {
     public static GameManager instance;
-    [FoldoutGroup("士兵相关")][LabelText("技能树/属性")][SerializeField]public List<DemonicAttributes> demonicAttributes = new List<DemonicAttributes>
-    {
-        new DemonicAttributes(),
-        new DemonicAttributes(),
-        new DemonicAttributes()
-    };
-    [FoldoutGroup("士兵相关")][LabelText("等级间隔")]public int gradeInterval;
+
     [FoldoutGroup("组件", order: -1)] public UIHP p1uiHP;
     [FoldoutGroup("组件")] public UIHP p1uiMP;
     [FoldoutGroup("组件")] public Transform p1uiRush;
@@ -69,15 +64,28 @@ public class GameManager : MonoBehaviour
     [FoldoutGroup("组件")] public TextMeshProUGUI moneyText;
     [FoldoutGroup("组件")] public PlayerController player;
 
-    [FoldoutGroup("金币结算", order: -1)][LabelText("限制时间")] public int rewardTime;
-    [FoldoutGroup("金币结算")][LabelText("金币奖励")] public int totalMoney;
-    [FoldoutGroup("金币结算")][LabelText("额外金币奖励")] public int extraMoney;
-    [FoldoutGroup("金币结算")][LabelText("惩罚时间间隔")] public int deductMoneyTime;
-    [FoldoutGroup("金币结算")][LabelText("每次惩罚扣除金币数量")] public int deductMoney;
+    [FoldoutGroup("场景")] public string bossSceneName;
+
+    [FoldoutGroup("士兵相关")]
+    [LabelText("技能树/属性")]
+    [SerializeField]
+    public List<DemonicAttributes> demonicAttributes = new List<DemonicAttributes>
+    {
+        new DemonicAttributes(),
+        new DemonicAttributes(),
+        new DemonicAttributes()
+    };
+    [FoldoutGroup("士兵相关")] [LabelText("等级间隔")] public int gradeInterval;
+
+    [FoldoutGroup("金币结算")] [LabelText("限制时间")] public int rewardTime;
+    [FoldoutGroup("金币结算")] [LabelText("金币奖励")] public int totalMoney;
+    [FoldoutGroup("金币结算")] [LabelText("额外金币奖励")] public int extraMoney;
+    [FoldoutGroup("金币结算")] [LabelText("惩罚时间间隔")] public int deductMoneyTime;
+    [FoldoutGroup("金币结算")] [LabelText("每次惩罚扣除金币数量")] public int deductMoney;
     [Header("金币掉落")]
-    [FoldoutGroup("金币结算")][LabelText("怪物掉落金币数量")] public int enemyGoldDrop;
-    [FoldoutGroup("金币结算")][LabelText("金币掉落特效")] public GameObject dropGoldFX;
-    [FoldoutGroup("金币结算")][LabelText("金币掉落字体")] public GameObject dropGoldText;
+    [FoldoutGroup("金币结算")] [LabelText("怪物掉落金币数量")] public int enemyGoldDrop;
+    [FoldoutGroup("金币结算")] [LabelText("金币掉落特效")] public GameObject dropGoldFX;
+    [FoldoutGroup("金币结算")] [LabelText("金币掉落字体")] public GameObject dropGoldText;
 
     [FoldoutGroup("标签")] [LabelText("单属性解锁阈值")] public int singleAttributeUnlockThreshold = 5;
     [FoldoutGroup("标签")] [LabelText("双属性解锁阈值")] public int dualAttributeUnlockThreshold = 10;
@@ -105,7 +113,7 @@ public class GameManager : MonoBehaviour
     [FoldoutGroup("标签/雷")] [LabelText("感电攻速比值")] [PropertyRange(0, 1)] public float attackSpeedScale = 0.6f;
     [FoldoutGroup("标签/雷")] [LabelText("易伤比值")] [PropertyRange(0, 2)] public float vulnerableRate = 0.5f;
 
-    [FoldoutGroup("标签/雷")] [LabelText("伤害")] public int thunderDamage =3;
+    [FoldoutGroup("标签/雷")] [LabelText("伤害")] public int thunderDamage = 3;
     [FoldoutGroup("标签/雷")] [LabelText("感电效果时间")] public float electrifyTime;
     [FoldoutGroup("标签/雷")] [LabelText("标签作用比值")] public float thunderLabelEffectRatio;
 
@@ -148,18 +156,18 @@ public class GameManager : MonoBehaviour
     [FoldoutGroup("标签/天地")] [LabelText("标签作用比值")] public float skyGroundLabelEffectRatio;
 
     [Header("商店刷新")]
-    [ValidateInput("CheckTagWeight","标签池子概率总和不是100%")]
+    [ValidateInput("CheckTagWeight", "标签池子概率总和不是100%")]
     [FoldoutGroup("Rogue")] [LabelText("标签池子比重(%)")] [Tooltip("最高标签池;标签池;公共池")] public List<float> tagWeight;
 
     public static readonly Dictionary<string, TargetType> TagToTargetTypeMap = new Dictionary<string, TargetType>(StringComparer.Ordinal);
     public bool CheckTagWeight(List<float> weights)
     {
         float num = 0;
-        for(int i = 0; i < 3; i++)
+        for (int i = 0; i < 3; i++)
         {
             num += weights[i];
         }
-        if(num == 100)
+        if (num == 100)
         {
             return true;
         }
@@ -167,12 +175,12 @@ public class GameManager : MonoBehaviour
         {
             return false;
         }
-        
+
     }
     [FoldoutGroup("Rogue")] [LabelText("第几关开始出现(%)")] public List<int> unlockLevel;
     [FoldoutGroup("Rogue")] [LabelText("基础几率(%)")] public List<float> baseChance;
     [FoldoutGroup("Rogue")] [LabelText("每关增加的几率(%)")] public List<float> chanceIncreasePerLevel;
-    [FoldoutGroup("Rogue")] [LabelText("最大几率(%)")] public List<float> maximumChance ;
+    [FoldoutGroup("Rogue")] [LabelText("最大几率(%)")] public List<float> maximumChance;
     [FoldoutGroup("Rogue")] public List<List<List<SingleTreasureConfig>>> treasuresList;
     [FoldoutGroup("Rogue")] [DisplayOnly] public List<float> trueRefreshChance;
     [FoldoutGroup("Rogue")] [HideInInspector] public List<float> refreshChance;
@@ -209,7 +217,7 @@ public class GameManager : MonoBehaviour
     public List<CreateEnemyConfig> createEnemyConfigs;
     [DisplayOnly] public GameType gameType;
     [DisplayOnly] public float levelRatio = 1;
-     
+
     private JSONNode Loader(string fileName)
     {
         return JSON.Parse(File.ReadAllText("GenerateDatas/json/" + fileName + ".json"));
@@ -232,24 +240,25 @@ public class GameManager : MonoBehaviour
     }
     private void Awake()
     {
-        //选定本局游戏有哪些士兵,后面兵多了这里要改
-        curSoldiers = new SoldierType[3];
-        curSoldiers[0] = SoldierType.sword;
-        curSoldiers[1] = SoldierType.shield;
-        curSoldiers[2] = SoldierType.spear;
-
         if (!instance)
         {
             instance = this;
-            GetAllExcel();
-            ReloadCfgCreateEnemyData();
+            DontDestroyOnLoad(gameObject);
         }
         else
         {
-            DestroyImmediate(gameObject);
+            Destroy(gameObject);
             return;
         }
-        //leveType = LeveType.Introduction;
+        GetAllExcel();
+        ReloadCfgCreateEnemyData();
+        //选定本局游戏有哪些士兵,后面兵多了这里要改
+        curSoldiers = new SoldierType[3];
+        curSoldiers[0] = SoldierType.sword;
+        curSoldiers[1] = SoldierType.shield;
+        curSoldiers[2] = SoldierType.spear;
+
+        leveType = LeveType.Introduction;
         myTreasures = new List<Treasure>();
         treasuresList = new List<List<List<SingleTreasureConfig>>>();
         refreshChance = new List<float>();
@@ -257,7 +266,7 @@ public class GameManager : MonoBehaviour
         {
             treasuresList.Add(new List<List<SingleTreasureConfig>>());
             refreshChance.Add(baseChance[i]);
-            for(int j = 0; j < 9; j++)
+            for (int j = 0; j < 9; j++)
             {
                 treasuresList[i].Add(new List<SingleTreasureConfig>());
             }
@@ -269,11 +278,11 @@ public class GameManager : MonoBehaviour
         }
         trueRefreshChance.Add(refreshChance[3]);
         List<SingleTreasureConfig> cfgTreasureList = allCfgData.CfgTreasure.DataList;
-        for(int i = 0;i< cfgTreasureList.Count; i++)
+        for (int i = 0; i < cfgTreasureList.Count; i++)
         {
             SingleTreasureConfig singleTreasureConfig = cfgTreasureList[i];
             treasuresList[singleTreasureConfig.Quality][0].Add(singleTreasureConfig);
-            for(int j = 0; j < singleTreasureConfig.Tag.Count;j++)
+            for (int j = 0; j < singleTreasureConfig.Tag.Count; j++)
             {
                 treasuresList[singleTreasureConfig.Quality][singleTreasureConfig.Tag[j]].Add(singleTreasureConfig);
             }
@@ -333,11 +342,11 @@ public class GameManager : MonoBehaviour
         AddMoney(dropGold);
         shopButton.SetActive(true);
     }
-    
+
     public void AddMoney(int enemyDrop)
     {
         int addMoney;
-        if(gameTime < rewardTime)
+        if (gameTime < rewardTime)
         {
             addMoney = totalMoney + extraMoney;
         }
@@ -355,7 +364,7 @@ public class GameManager : MonoBehaviour
     public void NextLevel()
     {
         shopButton.SetActive(false);
-        if(nowLevel - 1 < ratioIncrease.Count)
+        if (nowLevel - 1 < ratioIncrease.Count)
         {
             levelRatio += ratioIncrease[nowLevel - 1];
         }
@@ -375,17 +384,20 @@ public class GameManager : MonoBehaviour
             case LeveType.Conclusion:
                 leveType = LeveType.Boss;
                 break;
+            case LeveType.Boss:
+                SceneManager.LoadScene(bossSceneName);
+                break;
         }
         PlayersInput.instance[0].PlayerRevive();
-        foreach(List<GameObject> objs in PoolManager.instance.activeObjs.Values)
+        foreach (List<GameObject> objs in PoolManager.instance.activeObjs.Values)
         {
             List<GameObject> newObjs = new List<GameObject>(objs);
-            for(int i = 0; i < newObjs.Count; i++)
+            for (int i = 0; i < newObjs.Count; i++)
             {
                 newObjs[i].gameObject.SetActive(false);
             }
         }
-        for(int i = 0; i < 3; i++)
+        for (int i = 0; i < 3; i++)
         {
             player.demonicDic[i] = new List<Demonic>();
             demonicNum[i].GetComponentInChildren<TextMeshProUGUI>().text = "0";
@@ -395,7 +407,7 @@ public class GameManager : MonoBehaviour
         gameTime = 0;
         gameType = GameType.Gaming;
         nowLevel += 1;
-        ChangeRogueChance(); 
+        ChangeRogueChance();
     }
 
     public void ShowShop()
@@ -457,7 +469,7 @@ public class GameManager : MonoBehaviour
                     break;
                 case "伤害":
                     damage += (int)data;
-                    foreach(DemonicAttributes demonicAttribute in demonicAttributes)
+                    foreach (DemonicAttributes demonicAttribute in demonicAttributes)
                     {
                         demonicAttribute.ownDamage += (int)(data * demonicAttribute.damageGainEfficiency);
                     }
@@ -556,12 +568,12 @@ public class GameManager : MonoBehaviour
 
     public void ChangeRogueChance()
     {
-        for(int i = 0; i < 4; i++)
+        for (int i = 0; i < 4; i++)
         {
-            if(nowLevel >= unlockLevel[i])
+            if (nowLevel >= unlockLevel[i])
             {
                 refreshChance[i] += chanceIncreasePerLevel[i];
-                if(refreshChance[i] > maximumChance[i])
+                if (refreshChance[i] > maximumChance[i])
                 {
                     refreshChance[i] = maximumChance[i];
                 }
@@ -578,7 +590,7 @@ public class GameManager : MonoBehaviour
 [Serializable]
 public class DemonicAttributes
 {
-    [ShowInInspector][SerializeField] public List<DemonicSkill> skillTree;
+    [ShowInInspector] [SerializeField] public List<DemonicSkill> skillTree;
     public int levelCount;
     public SkeletonDataAsset sda;
 

+ 2 - 2
ActionTowerDefense/Assets/Scripts/Levels/LevelSelect.cs

@@ -74,13 +74,13 @@ public class LevelSelect : MonoBehaviour
         if (!instance)
         {
             instance = this;
+            DontDestroyOnLoad(gameObject);
         }
         else
         {
-            DestroyImmediate(gameObject);
+            Destroy(gameObject);
             return;
         }
-        
     }
 
     private void Start()

+ 3 - 0
ActionTowerDefense/ProjectSettings/EditorBuildSettings.asset

@@ -8,4 +8,7 @@ EditorBuildSettings:
   - enabled: 1
     path: Assets/Scenes/Game.unity
     guid: 2cda990e2423bbf4892e6590ba056729
+  - enabled: 1
+    path: Assets/Scenes/Game_Boss.unity
+    guid: 18ddccd0dbb4b684289e669e4b54a378
   m_configObjects: {}