diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/MapManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/MapManager.cs index 833c60e3..9685343b 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/MapManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/MapManager.cs @@ -5,6 +5,7 @@ using UnityEngine; using UnityEngine.Rendering.VirtualTexturing; using UnityEngine.UI; using static GameManager; +using static UnityEngine.Rendering.DebugUI; public class MapManager : Singleton { @@ -621,26 +622,34 @@ public class MapManager : Singleton HashSet allNode = getNodeTools.getAllCanUseNode(); //获取物品上限 - List itemLimitList = PlayerStatsManager.Instance.itemLimitDic[int.Parse(currentLevelData.mapIndex)]; + List totalInfor = PlayerStatsManager.Instance.itemLimitDic[30001]; string limitInfor=null ; switch (currentLevelData.fightEenemyPool) { case Name.EnemyPool.Weak: - limitInfor =itemLimitList[0]; + limitInfor = totalInfor[levelData_SO.mapLevel]; break; case Name.EnemyPool.Strong: - limitInfor = itemLimitList[1]; + limitInfor = totalInfor[levelData_SO.mapLevel + 3]; break; case Name.EnemyPool.Elite: - limitInfor = itemLimitList[2]; + limitInfor = totalInfor[levelData_SO.mapLevel + 6]; break; case Name.EnemyPool.Boss: - limitInfor = itemLimitList[3]; + limitInfor = totalInfor[levelData_SO.mapLevel + 9]; break; } string[] limitValue = limitInfor.Split(';'); - int lowerLimit = int.Parse(limitValue[(levelData_SO.mapLevel - 1) * 2]); - int maxLimit = int.Parse(limitValue[(levelData_SO.mapLevel - 1) * 2 + 1]); + Debug.Log("随机数量限制" + limitInfor); + //地形区间 + int lowerLandformLimit = int.Parse(limitValue[0]); + int maxLandformLimit = int.Parse(limitValue[1]); + //地块区间 + int lowerLandblockLimit = int.Parse(limitValue[2]); + int maxLandblockLimit = int.Parse(limitValue[3]); + //物品区间 + int lowerObjectItemLimit = int.Parse(limitValue[4]); + int maxObjectItemLimit = int.Parse(limitValue[5]); //切分物品数据 List itemInforStringList = new List (); @@ -652,22 +661,34 @@ public class MapManager : Singleton //随机物品数量并限制上限 int count = 0; List itemCountList = new List (); + while (count <100) { count++; - int totalCount = 0; + int landformCount = 0; + int blockCount = 0; + int objectCount = 0; itemCountList.Clear(); + for (int i = 0; i < itemInforStringList.Count; i++) { - int itemCount = Random.Range(int.Parse(itemInforStringList[i][1]), int.Parse(itemInforStringList[i][2])); - Debug.Log("随机" + itemInforStringList[i][0] + itemCount); - if(itemInforStringList[i][0] != "Vacancy") + int itemCount = Random.Range(int.Parse(itemInforStringList[i][2]), int.Parse(itemInforStringList[i][3])+1); + Debug.Log("随机" + itemInforStringList[i][1] + itemCount); + switch (int.Parse ( itemInforStringList[i][0])) { - totalCount += itemCount; + case 1: + landformCount+=itemCount; + break; + case 2: + blockCount+=itemCount; + break; + case 3: + objectCount+=itemCount; + break; } itemCountList.Add(itemCount); } - if(totalCount >=lowerLimit &&totalCount <=maxLimit ) + if(Scope0fJudgment(lowerLandformLimit , maxLandformLimit , landformCount )&& Scope0fJudgment(lowerLandblockLimit, maxLandblockLimit, blockCount) && Scope0fJudgment(lowerObjectItemLimit, maxObjectItemLimit,objectCount)) { Debug.Log("成功"); break; @@ -676,7 +697,7 @@ public class MapManager : Singleton //根据随机出的数量表生成物品 for (int i=0;i< itemInforStringList.Count;i++) { - GameObject item = Resources.Load(itemPrefabPath + itemInforStringList[i][0]); + GameObject item = Resources.Load(itemPrefabPath + itemInforStringList[i][1]); int itemCount = itemCountList[i]; for(int j=0;j yield return null; } + + public bool Scope0fJudgment(int min,int max,int value ) + { + Debug.Log("随机判断" + "min:" + min + "max:" + max); + if(value >=min &&value <=max ) + { + return true; + } + return false; + } [System .Serializable ] public class EnemyGenerateData { diff --git a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/LevelMapToItem.csv b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/LevelMapToItem.csv index c1e85523..d92e0928 100644 --- a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/LevelMapToItem.csv +++ b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/LevelMapToItem.csv @@ -1,5 +1,5 @@ 锘垮湴鍥剧紪鍙,鐗╁搧鏁版嵁,,, -100001,tree;0;2,boom;0;2,Whirlpool;0;2,Vacancy;0;5 -100002,tree;0;2,boom;1;2,Whirlpool;0;2,Vacancy;0;4 -100003,tree;0;2,boom;0;2,Whirlpool;0;2,Vacancy;1;5 -100004,tree;0;2,boom;0;2,Whirlpool;0;2,Vacancy;2;8 +100001,3;tree;0;1,3;boom;0;1,1;Whirlpool;0;2,2;Vacancy;0;5 +100002,3;tree;0;1,3;boom;0;1,1;Whirlpool;0;2,2;Vacancy;0;4 +100003,3;tree;0;1,3;boom;0;1,1;Whirlpool;0;2,2;Vacancy;1;5 +100004,3;tree;0;1,3;boom;0;1,1;Whirlpool;0;2,2;Vacancy;2;8 diff --git a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/MapItemCount.csv b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/MapItemCount.csv index e6cdfedb..bd773ee9 100644 --- a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/MapItemCount.csv +++ b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/MapItemCount.csv @@ -1,5 +1,2 @@ -锘垮湴鍥剧紪鍙,寮辨,寮烘,绮捐嫳,boss -100001,0;1;0;1;1;2,0;2;1;2;2;3,1;2;2;2;3;3,1;2;2;3;3;4 -100002,0;2;0;1;1;1,0;1;1;2;2;3,1;2;2;2;3;3,1;2;2;3;3;4 -100003,0;1;0;1;1;1,0;1;1;2;2;3,1;2;2;2;3;3,1;2;2;3;3;4 -100004,0;1;0;1;1;1,0;1;1;2;2;3,1;2;2;2;3;3,1;2;2;3;3;4 +锘垮湴鍥剧紪鍙,寮辨,,,寮烘,,,绮捐嫳,,,boss,, +30001,0;1;0;1;0;1,0;1;0;1;0;1,1;2;1;1;1;1,0;2;0;1;0;1,1;2;1;2;1;2,2;3;2;3;2;3,1;2;1;2;1;2,2;2;2;2;2;2,3;3;3;3;3;3,1;2;1;2;1;2,2;3;2;3;2;3,3;4;3;4;3;4