把012围成一个圈,不管自身玩家在几号位,把它转到下面就行了,保持:1在0的右边,2在1的右边,0在2的右边。
感觉先排序,再判断2是否存在,会更有助于理解,所以我是这样写得:
public void ResetPostion(int myUserId)
{
LeftPlayerId = -1;
RightPlayerId = -1;
if (enterOrderUserIdList[0] == myUserId)
{
RightPlayerId = enterOrderUserIdList[1];
if (enterOrderUserIdList.Count == 3) { LeftPlayerId = enterOrderUserIdList[2]; }
}
else if (enterOrderUserIdList[1] == myUserId)
{
LeftPlayerId = enterOrderUserIdList[0];
if (enterOrderUserIdList.Count == 3) { RightPlayerId = enterOrderUserIdList[2]; }
}
else if (enterOrderUserIdList[2] == myUserId)
{
RightPlayerId = enterOrderUserIdList[0];
if (enterOrderUserIdList.Count == 3) { LeftPlayerId = enterOrderUserIdList[1]; }
}
}