我有点问题。我有一个混合不同大小的对象数组。条件是以逐渐增加的形式对它们进行排序,从小到大。我按照下面的代码进行了安排,但现在我不知道如何检查它们是否已经订购。
foreach (GameObject palm in thisPalms)
palm.GetOrAddComponent<MouseEventSystem>().MouseEvent += thePalmHasClicked;
private void thePalmHasClicked(GameObject target, MouseEventType type)
{
if (type == MouseEventType.CLICK && canClick)
{
int targetIndex = System.Array.IndexOf(thisPalms, target);
if (targetIndex != lastTargetIndex && lastTargetIndex != -1)
{
canClick = false;
thisPalms[lastTargetIndex].transform.DOMove(thisPalms[targetIndex].transform.position, 1f).SetDelay(0.5f);
thisPalms[targetIndex].transform.DOMove(thisPalms[lastTargetIndex].transform.position, 1f).SetDelay(0.5f).OnComplete(() =>
{
canClick = true;
lastTargetIndex = -1;
moveIndex -= 38;
levelIndex++;
//Here I have to check if they are ordered or not
//if is ordered => DoNext();
//else => DoBad();
});
}
lastTargetIndex = targetIndex;
}
}
物体是不同大小的棕榈树。如果有人知道该使用什么以及如何使用,谢谢。