public void Shuffle(bool isAnim = false, bool shuflleButton = false) { while (GameController.instance.matchController.CheckMatchHorizontal() || GameController.instance.matchController.CheckMatchVertical() || GameController.instance.matchController.CheckMatchCube() || shuflleButton == true) { shuflleButton = false; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (matrix[i, j].swipeElement.gemElement.index != 99) { SwipeElement item = matrix[i, j].swipeElement; Vector2 _tempPos = ChoosePos(); matrix[i, j].swipeElement = matrix[(int)_tempPos.x, (int)_tempPos.y].swipeElement; matrix[(int)_tempPos.x, (int)_tempPos.y].swipeElement = item; } } } } for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { matrix[i, j].GetGemToPosition(0.7f, isAnim); } } }
public void CallGemBack(GridElement item) { gridElementsList[1].GetGemToPosition(0.9f, true, false); gridElementsList[0].GetGemToPosition(0.9f, true, false); SwipeElement _temp1 = gridElementsList[1].swipeElement; gridElementsList[1].swipeElement = gridElementsList[0].swipeElement; gridElementsList[0].swipeElement = _temp1; }
public void ClickCalc(GridElement item) { if (gridElementsList.Count == 1) { if (gridElementsList[0] == item) { return; } } gridElementsList.Add(item); if (gridElementsList.Count == 2) { if (Vector2.Distance(gridElementsList[0].positionVecor2, gridElementsList[1].positionVecor2) == 1) { SwipeElement _temp = gridElementsList[0].swipeElement; gridElementsList[0].swipeElement = gridElementsList[1].swipeElement; gridElementsList[1].swipeElement = _temp; mHor = GameController.instance.matchController.CheckMatchHorizontal(); mVer = GameController.instance.matchController.CheckMatchVertical(); mCub = GameController.instance.matchController.CheckMatchCube(); if (!mHor && !mVer && !mCub) { CallGemBack(item); gridElementsList = new List <GridElement>(); } else if (mHor || mVer || mCub) { gridElementsList[0].GetGemToPosition(0.3f); gridElementsList[1].GetGemToPosition(0.3f); GameController.instance.conditionController.CheckMoves(); GameController.instance.matchController.CheckMatch(); } } else { gridElementsList = new List <GridElement>(); gridElementsList.Add(item); } } if (gridElementsList.Count > 2) { gridElementsList = new List <GridElement>(); gridElementsList.Add(item); } }
public void CreateBombVertical(List <GridElement> list) { SwipeElement _tempswipe = list[0].swipeElement; GridElement _turnToBomb; if (GameController.instance.gridController.gridElementsList.Count != 0) { _turnToBomb = GameController.instance.matchController.CheckTransformBomb(GameController.instance.gridController.gridElementsList, list); } else { _turnToBomb = list[Random.Range(0, list.Count)]; } _turnToBomb.swipeElement.gemElement.index = 99; _turnToBomb.swipeElement.bombElement.index = 1; list[0].swipeElement = _turnToBomb.swipeElement; _turnToBomb.swipeElement = _tempswipe; list[0].GetGemToPosition(0.7f); list.Remove(list[0]); }
public void CreateBombHorizontal(SwipeElement swiper) { swiper.gemElement.index = 99; swiper.bombElement.index = 2; }