diff --git a/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset b/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset index c3ab45f0..d7940cc2 100644 --- a/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset +++ b/ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset @@ -20,3 +20,6 @@ MonoBehaviour: - 2002 - 2002 - 2002 + - 1004 + - 1004 + - 1004 diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs index f3a3ccdb..6aa1d23a 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs @@ -1,6 +1,8 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; +using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.UI; @@ -626,6 +628,7 @@ public class GameManager : Singleton } yield return null;*/ + List colorCount = PlayerStatsManager.Instance.GetCardDeckColor(PlayerStatsManager.Instance.cardDeck.cardDeckList); List whiteMapUnities = new List(); for(int i=0;i< X .Count;i++) { @@ -637,18 +640,60 @@ public class GameManager : Singleton } } } - - for(int i = 0; i < playerState.canColorCount ; i++) + if(colorCount[0]<=whiteMapUnities .Count) { - if (whiteMapUnities.Count <= 0) + for (int i = 0; i < colorCount[0]; i++) { - break; + if (whiteMapUnities.Count <= 0) + { + break; + } + for(int j=1;j0) + { + int index = UnityEngine.Random.Range(0, whiteMapUnities.Count); + whiteMapUnities[index].switchColor(j); + colorCount[j] -= 1; + whiteMapUnities.RemoveAt(index); + break; + } + } + + yield return null; } - int index = UnityEngine.Random.Range(0, whiteMapUnities.Count ); - whiteMapUnities[index].switchColor(PlayerStatsManager.Instance.colorSortList[UnityEngine.Random.Range(0, 3)]); - whiteMapUnities.RemoveAt(index); - yield return null; } + else + { + //当涂色数大于地块数时按照比例转化 + float multiplier = (float)whiteMapUnities.Count / (float)colorCount[0]; + for (int i=0;i< colorCount.Count;i++ ) + { + colorCount[i] = (int)(colorCount[i] * multiplier); + } + + for (int i = 0; i < colorCount[0]; i++) + { + if (whiteMapUnities.Count <= 0) + { + break; + } + for (int j = 1; j < colorCount.Count; j++) + { + if (colorCount[j] > 0) + { + int index = UnityEngine.Random.Range(0, whiteMapUnities.Count); + whiteMapUnities[index].switchColor(j); + colorCount[j] -= 1; + whiteMapUnities.RemoveAt(index); + break; + } + } + + yield return null; + } + } + for (int i = 0; i < 20; i++) { if(whiteMapUnities.Count<=0) diff --git a/ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs b/ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs index e42147b0..5e69e167 100644 --- a/ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs +++ b/ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs @@ -43,6 +43,7 @@ public class PlayerStatsManager : Singleton ReadItemInforCsv(itemCsvFilePath); ReadItemLimitCsv(itemLimitCsvFilePath); + } //选项效果==加一个同步UI的订阅系统 @@ -201,4 +202,46 @@ public class PlayerStatsManager : Singleton } } } + + //获取卡牌颜色比例 + public List GetCardDeckColor(List cards) + { + List colorCountList = new List() { 0, 0, 0, 0, 0, 0, 0 };//1red,2white,3blue,4green,5black,6matel,0是费用总数 + CardOriginalData cardOriginalData; + for (int i = 0; i < cards.Count; i++) + { + if (CardOriginalDataList.Instance.existCardOriginalDataList.TryGetValue(cards[i], out cardOriginalData) == true) + { + //统计颜色牌颜色和费用 + colorCountList[0] += cardOriginalData.Cost; + foreach (string color in cardOriginalData.nodesColor) + { + colorCountList[Name.stringColorToint(color)] += 1; + } + } + else//统计效果牌费用 + { + if (CardOriginalDataList.Instance.existEffectCardOriginalDataList.TryGetValue(cards[i], out cardOriginalData) == true) + { + + colorCountList[0] += cardOriginalData.Cost; + } + } + } + int colorTotalCount = 0;//计算颜色总数 + for (int i = 1; i < colorCountList.Count; i++) + { + colorTotalCount += colorCountList[i]; + } + //计算单个颜色占比有多少个 + List colorResults = new List() { 0, 0, 0, 0, 0, 0, 0 };//1red,2white,3blue,4green,5black,6matel,0是费用总数 + colorResults[0] = colorCountList [0]; + for (int i = 1; i < colorCountList.Count; i++) + { + colorResults[i] = (int)(((float)colorCountList[i]/ (float)colorTotalCount )*colorResults[0]); + Debug.Log("涂色" + i + ":"+ colorResults[i]); + } + Debug.Log("涂色总数:" + colorResults[0]); + return colorResults; + } } diff --git a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/card_data_4.csv b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/card_data_4.csv index 2c534d39..3d0ca054 100644 --- a/ColorlessWorld-2024-4-2/Assets/StreamingAssets/card_data_4.csv +++ b/ColorlessWorld-2024-4-2/Assets/StreamingAssets/card_data_4.csv @@ -2,3 +2,4 @@ 1001,1,1,2,3_1,none,1,5,0_0;1_0;2_0,white;white;white,CardIcon/1010,灏勫嚮 1002,1,1,2,3_1,none,2,4,0_0;-1_1;-1_-1,white;white;white,CardIcon/1010,灞忛殰 1003,1,1,2,3_1,none,,,0_0;1_0;2_0;3_0;4_0,white;white;white;white;white,CardIcon/1010,鍠峰皠 +1004,1,3,2,3_1,none,1,5,0_0;1_0;2_0,red;red;red,CardIcon/1010,灏勫嚮