//导入真实数据,根据难度定义所有数据包括横向和纵向的拼图数量,定义拼图的当前数据和真实数据 public void Init() { switch (difficultLevel) { case 1: horizontalNum = 5; verticalNum = 5; break; case 2: horizontalNum = 6; verticalNum = 6; break; case 3: horizontalNum = 8; verticalNum = 8; break; } spriteNum = horizontalNum * verticalNum; UIManager._instance.Init(difficultLevel, horizontalNum, verticalNum); realDatas = new SripteData[spriteNum]; for (int i = 0; i < spriteNum; i++) { SripteData sripte = new SripteData(i, i); realDatas[i] = sripte; } }
public void ExchangeData(int fromIndex, int toIndex) //交换两个拼图的图片 { SripteData[] moveSriptes = new SripteData[2]; SripteData temp = realDatas[fromIndex]; realDatas[fromIndex] = realDatas[toIndex]; realDatas[toIndex] = temp; realDatas[fromIndex].ExchangeIndex(fromIndex); realDatas[toIndex].ExchangeIndex(toIndex); moveSriptes[0] = realDatas[fromIndex]; moveSriptes[1] = realDatas[toIndex]; SpriteMoveIsDone(moveSriptes); //for (int i = 0; i < realDatas.Length; i++) //{ // Debug.Log(realDatas[i].realIndex); //} CheckWin(); }
public void RandomSpritePosition() //随机打乱所有拼图 { for (int i = 0; i < spriteNum; i++) { int rollIndex = Random.Range(0, spriteNum); SripteData temp = realDatas[i]; realDatas[i] = realDatas[rollIndex]; realDatas[rollIndex] = temp; realDatas[rollIndex].ExchangeIndex(rollIndex); realDatas[i].ExchangeIndex(i); } //for (int i = 0; i < realDatas.Length; i++) //{ // Debug.Log(realDatas[i].realIndex); //} //Debug.Log("==================================="); //TODO 此处应检查是否已经赢了 AllSpriteIsDone(realDatas); }