Browse Source

地块涂色完善

pull/78/head
45 1 year ago
parent
commit
58548899e7
  1. 3
      ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset
  2. 61
      ColorlessWorld-2024-4-2/Assets/Scripts/GameManager.cs
  3. 43
      ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs
  4. 1
      ColorlessWorld-2024-4-2/Assets/StreamingAssets/card_data_4.csv

3
ColorlessWorld-2024-4-2/Assets/GameDate/cardDeckList.asset

@ -20,3 +20,6 @@ MonoBehaviour:
- 2002
- 2002
- 2002
- 1004
- 1004
- 1004

61
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<GameManager>
}
yield return null;*/
List<int> colorCount = PlayerStatsManager.Instance.GetCardDeckColor(PlayerStatsManager.Instance.cardDeck.cardDeckList);
List<MapUnity> whiteMapUnities = new List<MapUnity>();
for(int i=0;i< X .Count;i++)
{
@ -637,18 +640,60 @@ public class GameManager : Singleton<GameManager>
}
}
}
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;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;
}
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)

43
ColorlessWorld-2024-4-2/Assets/Scripts/PlayerManager/PlayerStatsManager.cs

@ -43,6 +43,7 @@ public class PlayerStatsManager : Singleton <PlayerStatsManager>
ReadItemInforCsv(itemCsvFilePath);
ReadItemLimitCsv(itemLimitCsvFilePath);
}
//选项效果==加一个同步UI的订阅系统
@ -201,4 +202,46 @@ public class PlayerStatsManager : Singleton <PlayerStatsManager>
}
}
}
//获取卡牌颜色比例
public List<int> GetCardDeckColor(List<string> cards)
{
List <int> colorCountList = new List<int>() { 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<int> colorResults = new List<int>() { 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;
}
}

1
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,射击

1 ID 费用类型 费用 施法范围 作用范围 条件 功能 数值 地块标记 地块颜色 图片路径 名称
2 1001 1 1 2 3_1 none 1 5 0_0;1_0;2_0 white;white;white CardIcon/1010 射击
3 1002 1 1 2 3_1 none 2 4 0_0;-1_1;-1_-1 white;white;white CardIcon/1010 屏障
4 1003 1 1 2 3_1 none 0_0;1_0;2_0;3_0;4_0 white;white;white;white;white CardIcon/1010 喷射
5 1004 1 3 2 3_1 none 1 5 0_0;1_0;2_0 red;red;red CardIcon/1010 射击
Loading…
Cancel
Save