如果字符串数据数组与C#(单位)不同,则增加位置
我需要帮助制作记分牌。这是我想要实现的计分牌: 我实际上有四个表,每个表都有自己的记分板,但是对于这个问题,只有表1是我需要的,所以我现在就来创建这种记分板 到目前为止,我已经做到了:如果字符串数据数组与C#(单位)不同,则增加位置,c#,android,unity3d,C#,Android,Unity3d,我需要帮助制作记分牌。这是我想要实现的计分牌: 我实际上有四个表,每个表都有自己的记分板,但是对于这个问题,只有表1是我需要的,所以我现在就来创建这种记分板 到目前为止,我已经做到了: if (gametable_no == 1) { for (int i = 0; i < tzPlayInfo.Instance.bc_gametable_history_list.Count; i++) { newString[0] += tzPlayInfo.Insta
if (gametable_no == 1)
{
for (int i = 0; i < tzPlayInfo.Instance.bc_gametable_history_list.Count; i++)
{
newString[0] += tzPlayInfo.Instance.bc_gametable_history_list[i].r;
newString[0] += ",";
}
string[] groupedString = newString[0].Split(',');
foreach (string allchars in groupedString)
{
int x = 0;
int y = 0;
GameObject o = Instantiate(prefab_big_road[0]) as GameObject;
o.transform.SetParent(pos_big_road[0]);
o.transform.localScale = Vector3.one;
o.transform.localPosition = new Vector3(2.0f, -5.0f, 0f);
o.transform.localPosition = new Vector3(o.transform.localPosition.x + x,
o.transform.localPosition.y + y, o.transform.localPosition.z);
if (allchars.Contains(playerwinnopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_player_bigline-01";
NGUITools.SetActive(o, true);
}
if (allchars.Contains(bankerwinnopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_banker_bigline-01";
NGUITools.SetActive(o, true);
}
if (allchars.Contains(tienopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_tie_bigline-01";
NGUITools.SetActive(o, true);
}
}
}
我需要知道角色在游戏表1历史数据中是否正在更改
例如:输出必须如下所示
如果该值没有像p,p,p
那样改变,则该位置将仅在y轴上增加,然后如果下一个值不同,如B,
,则它将移动到x轴
有没有办法检测字符串数组中的字符是否与其他值不同
已编辑
string[] newString = new string[4];
string[,] table = new string[70, 70];
string previousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;
// First table
if (gametable_no == 1)
{
for (int i = 0; i < tzPlayInfo.Instance.bc_gametable_history_list.Count; i++)
{
newString[0] += tzPlayInfo.Instance.bc_gametable_history_list[i].r;
newString[0] += ",";
}
//string[] groupedString = GroupString(newString[0]);
string[] groupedString = newString[0].Split(',');
foreach (var allchars in groupedString)
{
GameObject o = Instantiate(prefab_big_road[0]) as GameObject;
o.transform.SetParent(pos_big_road[0]);
o.transform.localScale = Vector3.one;
if (table.GetLength(0) < xIndex)
{
break;
}
if (allchars.Equals(previousValue) && table.GetLength(1) < yIndex)
{
yIndex += 15;
table[xIndex, yIndex] = allchars;
}
else
{
xIndex += 15;
yIndex = 0;
table[xIndex, yIndex] = allchars;
}
previousValue = allchars;
o.transform.localPosition = new Vector3(xIndex, yIndex, 0f);
// Match the sprites
if (previousValue.Contains(playerwinnopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_player_bigline-01";
NGUITools.SetActive(o, true);
}
if (previousValue.Contains(bankerwinnopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_banker_bigline-01";
NGUITools.SetActive(o, true);
}
if (previousValue.Contains(tienopairboth))
{
o.GetComponent<UISprite>().spriteName = "layout_tie_bigline-01";
NGUITools.SetActive(o, true);
}
}
string[]newString=新字符串[4];
字符串[,]表=新字符串[70,70];
字符串previousValue=“占位符”;
int xIndex=-1;
int-yIndex=0;
//第一桌
如果(游戏表_no==1)
{
对于(int i=0;i
它只生成很少的预制件:
虽然我已经生成了这些数据:
在我的UI中,它仅显示两个:
我建议使用多维数组作为表。
也许是这样的
string[,] table = new string[30, 6];
string previousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;
foreach (var value in groupedString)
{
if (table.GetLength(0) < xIndex)
{
break;
}
if (value.Equals(previousValue) && yIndex < table.GetLength(1))
{
yIndex += 1;
table[xIndex, yIndex] = value;
}
else
{
xIndex += 1;
yIndex = 0;
table[xIndex, yIndex] = value;
}
previousValue = value;
}
string[,]table=新字符串[30,6];
字符串previousValue=“占位符”;
int xIndex=-1;
int-yIndex=0;
foreach(groupedString中的var值)
{
if(表.GetLength(0)
现在,您应该有一个包含所有值的表,您可以在UI上显示这些值,并相应地匹配正确的精灵。谢谢您,它实际上是正确的,但缺少以下条件:
if (table.GetLength(0) < xIndex)
{
break;
}
if (previousValue.Equals(newPreviousValue) && yIndex < table.GetLength(1))
{
yIndex += 1;
table[xIndex, yIndex] = previousValue;
}
else
{
xIndex += 1;
yIndex = 0;
table[xIndex, yIndex] = previousValue;
}
newPreviousValue = previousValue;
if(table.GetLength(0)
因此,它必须是yIndex
,而不是table.GetLength(1)
,我可以先问一下这是什么吗,先生,对不起string[,]table=新字符串[6,30]
和string previousValue=“placeholder”
?字符串[,]是一个多维数组。如果将其可视化,它将类似于您上载的图像。如果键入table[0,0],您将访问左上角的单元格。table[1,0]是下面的一个。table[0,1]是第二行,第一个单元格,依此类推。数组初始化中的数字(第一行)应该是表的维度。在我的示例中,它是6深30长。“占位符”是一个占位符,在第一次foreach迭代中被上一个值覆盖。它的第一个值应该是任何值,只要它不是groupedString中包含的值。我编辑了我的问题,所以我的代码应该是这样的。
if (table.GetLength(0) < xIndex)
{
break;
}
if (previousValue.Equals(newPreviousValue) && yIndex < table.GetLength(1))
{
yIndex += 1;
table[xIndex, yIndex] = previousValue;
}
else
{
xIndex += 1;
yIndex = 0;
table[xIndex, yIndex] = previousValue;
}
newPreviousValue = previousValue;