public void CheckClickedTile(int index) { thisGameMoves++; List <Tile> SimilarTilesList = new List <Tile>(); boardAudioSource1.clip = wrongClickSnd; boardAudioSource1.Play(); //add the selected tile itself to the list of objects to change SimilarTilesList.Add(tileList[index]); tileList[index].isChecked = true; int type = tileList[index].TileType; //checks if adjacent tiles have the same type SimilarTilesList.AddRange(ListOfSimilarAdjacentTilesObj(index, type)); tileList[index].isChecked = false; //Debug.Log("Selected Tiles indexes: "); //foreach (GameObject simGameObject in SimilarTilesList) //{ // Debug.Log((simGameObject.GetComponent<Tile>().myIndex)); //} //check if there are 3 adjacent similar tiles if (SimilarTilesList.Count >= 2) { boardAudioSource1.clip = madeAMatchSnd; boardAudioSource1.Play(); blockingObj.SetActive(true); StartCoroutine("DisableBlocker"); //Debug.Log("Type: " + type + " index: " + index + " Similar Tiles: " + SimilarTilesList.Count); //sorting game object in the list based on their index SimilarTilesList.Sort(SortDesByIndex); //Debug.Log("Sorted Selected Tiles indexes: "); //foreach (GameObject simGameObject in SimilarTilesList) //{ // Debug.Log((simGameObject.GetComponent<Tile>().myIndex)); //} gameLogicManager.CountDestroyedTilesByType(SimilarTilesList.Count, ingredients[type]); bool wasSomthingFromOrder = orderHandler.ChangeRequirementsAmount(SimilarTilesList.Count, ingredients[type]); //changing the type and sprite of matching tiles foreach (Tile adjacent in SimilarTilesList) { //playing flying animation if (wasSomthingFromOrder) { ingredientsFly.MoveTileToTarget(adjacent.myIndex, type); boardAudioSource1.clip = IngredientItemSnd; boardAudioSource1.Play(); } //check how many similar tiles are upon this one to set the right animation in the next step int upperSimilarTiles = 0; for (int i = adjacent.myIndex - boardColCount; i >= 0 && adjacent.TileType == tileList[i].TileType; i -= boardColCount) { upperSimilarTiles++; } adjacent.upperSimilarTiles = upperSimilarTiles; //check how many similar tiles are down this one to set the right animation in the next step int belowSimilarTiles = 0; for (int i = adjacent.myIndex + boardColCount; i < tileListSize && adjacent.TileType == tileList[i].TileType; i += boardColCount) { belowSimilarTiles++; } adjacent.belowSimilarTiles = belowSimilarTiles; //Debug.Log("Index: " + adjacent.myIndex + " | upper similar tiles amount: " + upperSimilarTiles // + " | down similar tiles amount: " + belowSimilarTiles); } SimilarTilesList.Sort(SortAscByIndex); foreach (Tile adjacent in SimilarTilesList) { ChangeTiles(adjacent); } if (CheckForDeadend()) { string message = string.Format("<color=red><b>-------------GOING TO SHUFFLE AFTER SOME SECONDS-------------</b></color>"); Debug.Log(message); Invoke("ShuffleTiles", 100 * Time.deltaTime); //ShuffleTiles(); } orderHandler.ChangeCustomerMood(); levelManager.MadeAMove(); } }