将X轴移动到';s大于6 C#Unity

将X轴移动到';s大于6 C#Unity,c#,android,unity3d,C#,Android,Unity3d,目前我做这件事有困难 发生在我身上的是 这是我的密码 string[,] table = new string[104, 6]; int xIndex = -1; int yIndex = 0; int counter = 0; if (table.GetLength(0) < xIndex) { break; } if (result.Equals(newPreviousValue) && yIndex < table.G

目前我做这件事有困难

发生在我身上的是

这是我的密码

string[,] table = new string[104, 6];
int xIndex = -1;
int yIndex = 0;
int counter = 0;


if (table.GetLength(0) < xIndex)
{
     break;
}
            
if (result.Equals(newPreviousValue) && yIndex < table.GetLength(1))
{
     yIndex += 1;
     counter++;
     table[xIndex, yIndex] = result;
}
else
{
      xIndex += 1;
      yIndex = 0;
      counter = 0;
      table[xIndex, yIndex] = result;
}
if (result.Equals("T") && yIndex < table.GetLength(1))
{
    yIndex += 1;
    table[xIndex, yIndex] = result;
}
     newPreviousValue = result;
     //new position
 if (counter < 6) { 
     bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
 }
 else
 {
      bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -95, 0f);
 }
string[,]table=新字符串[104,6];
int xIndex=-1;
int-yIndex=0;
int计数器=0;
if(表.GetLength(0)
我想要的是,如果newPrevious(由蓝色、红色和绿色组成)的值为蓝色/红色/绿色,并且超过了6,它将自动在X轴上移动一个值,但在同一行中移动一个值

谁能帮帮我吗

编辑 我使用Ignacio的代码

if (counter > 6)
{
     xIndex2 += 1;
     yIndex2 = 0;
     table[xIndex2, yIndex2] = result;
}

if (counter < 6)
{
    bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
}
else
{
    int reminder = counter % 6;
    bigroad.transform.localPosition = new Vector3((xIndex2 + reminder) * 19, -95, 0f);
}
if(计数器>6)
{
xIndex2+=1;
yIndex2=0;
表[xIndex2,yIndex2]=结果;
}
如果(计数器<6)
{
bigroad.transform.localPosition=新向量3(xIndex*19,yIndex*-19,0f);
}
其他的
{
int提醒=计数器%6;
bigroad.transform.localPosition=新矢量3((xIndex2+提醒)*19,-95,0f);
}
但它给了我这个


如果你仔细看,它有一个预制件在同一个位置,先生。

所以问题的根源在这里:

if (counter < 6) { 
     bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
 }
 else
 {
      bigroad.transform.localPosition = new Vector3(xIndex2 * 19, yIndex2 * -95, 0f);
 }
编辑2:

我不确定您的第一个位置是在yIndex=0还是在yIndex=1时。我假设第一个是当yIndex=1时。如果是在yIndex=0时,请告诉我

if (counter < 6) { 
         bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
     }
     else
     {
          int reminder = counter % 6;
          bigroad.transform.localPosition = new Vector3((xIndex2 + reminder) * 19, -19, 0f);
     }

因此,问题的根源在于:

if (counter < 6) { 
     bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
 }
 else
 {
      bigroad.transform.localPosition = new Vector3(xIndex2 * 19, yIndex2 * -95, 0f);
 }
编辑2:

我不确定您的第一个位置是在yIndex=0还是在yIndex=1时。我假设第一个是当yIndex=1时。如果是在yIndex=0时,请告诉我

if (counter < 6) { 
         bigroad.transform.localPosition = new Vector3(xIndex * 19, yIndex * -19, 0f);
     }
     else
     {
          int reminder = counter % 6;
          bigroad.transform.localPosition = new Vector3((xIndex2 + reminder) * 19, -19, 0f);
     }


好的,在你的棋盘里用坐标说话。对于位于以下位置(x=8,y=2)的对象,您希望使用什么位置作为替代?@IgnacioAlorre基于上图。如果它超过6,我希望它的形式像字母L,所以您希望这些块保留在最后一行(第6行),但移动到下一列(右侧)。不是吗?@IgnacioAlorre是的,没错。我需要把这两个方块移到右边,因为它超过了6ok,还有那些神奇的数字:19和95,你用它们来设置方块的大小?或者他们的意思是什么?顺便说一下,我建议您将它们作为变量写在代码之上,这样更容易理解。因为即使对你来说,将来知道你为什么设置这些值也可能会让人困惑。对于位于以下位置(x=8,y=2)的对象,您希望使用什么位置作为替代?@IgnacioAlorre基于上图。如果它超过6,我希望它的形式像字母L,所以您希望这些块保留在最后一行(第6行),但移动到下一列(右侧)。不是吗?@IgnacioAlorre是的,没错。我需要把这两个方块移到右边,因为它超过了6ok,还有那些神奇的数字:19和95,你用它们来设置方块的大小?或者他们的意思是什么?顺便说一下,我建议您将它们作为变量写在代码之上,这样更容易理解。因为即使对你来说,将来知道为什么要设置这些值也可能会让人困惑。我会试试:)好的,让我知道。我知道你用bigroad.transform.localPosition设置了块的位置是的,等一下,先生:)对我来说,你似乎在某处增加了yIndex 2,但如果yIndex大于6,它不应该增加。但我无法在你的代码中找到确切的位置。尝试使用这些新编辑,只需删除case counter>6中的yIndex2。确切的问题是什么?你能用当前输出添加一个新图像吗?我会试试:)好的,让我知道。我知道你用bigroad.transform.localPosition设置了块的位置是的,等一下,先生:)对我来说,你似乎在某处增加了yIndex 2,但如果yIndex大于6,它不应该增加。但我无法在你的代码中找到确切的位置。尝试使用这些新编辑,只需删除case counter>6中的yIndex2。确切的问题是什么?您可以使用当前输出添加新图像吗?
if (counter > 6)
{
     xIndex2 = 0; //Here you were adding + 1
     yIndex2 = 0;
     table[xIndex2, yIndex2] = result;
}