/* * Makes Avatar tile */ public void MakeAvatarTileCheck() { if (gameBoard.currentTile) { // Turn current tile into Avatar if (gameBoard.currentTile.GetHasMatched() && gameBoard.currentTile.GetTileType() == TileType.Normal) { gameBoard.currentTile.SetHasMatched(false); currentMatches.Remove(gameBoard.currentTile.gameObject); gameBoard.currentTile.GenerateAvatarTile(); } // Turn other tile into Avatar else if (gameBoard.currentTile.GetOtherTile()) { if (gameBoard.currentTile.GetOtherTile().GetComponent <GameTileBase>()) { GameTileBase otherTile = gameBoard.currentTile.GetOtherTile().GetComponent <GameTileBase>(); if (otherTile.GetHasMatched() && otherTile.GetTileType() == TileType.Normal) { otherTile.SetHasMatched(false); otherTile.GenerateAvatarTile(); } } } } }
/* * Match single Glider Tile * * @param tiles */ private void MatchGliderTile(GameObject tile) { if (tile) { if (tile.GetComponent <GameTileBase>()) { GameTileBase tempTile = tile.GetComponent <GameTileBase>(); if (tempTile.GetTileType() == TileType.Glider) { GetGliderMatches(tile, tempTile.currentCol, tempTile.currentRow); } } } }
/* * Makes char tile * */ public void MakeCharTileCheck() { if (gameBoard.currentTile) { // Turn current tile into Char if (gameBoard.currentTile.GetHasMatched() && gameBoard.currentTile.GetTileType() == TileType.Normal) { gameBoard.currentTile.SetHasMatched(false); currentMatches.Remove(gameBoard.currentTile.gameObject); if (gameBoard.currentTile.swipeDirection == SwipeDirection.Left || gameBoard.currentTile.swipeDirection == SwipeDirection.Right) { gameBoard.currentTile.GenerateCharTile(true); } else { gameBoard.currentTile.GenerateCharTile(false); } } // Turn other tile into Char else if (gameBoard.currentTile.GetOtherTile()) { if (gameBoard.currentTile.GetOtherTile().GetComponent <GameTileBase>()) { GameTileBase otherTile = gameBoard.currentTile.GetOtherTile().GetComponent <GameTileBase>(); if (otherTile.GetHasMatched() && otherTile.GetTileType() == TileType.Normal) { otherTile.SetHasMatched(false); currentMatches.Remove(gameBoard.currentTile.gameObject); if (gameBoard.currentTile.swipeDirection == SwipeDirection.Left || gameBoard.currentTile.swipeDirection == SwipeDirection.Right) { gameBoard.currentTile.GenerateCharTile(true); } else { gameBoard.currentTile.GenerateCharTile(false); } } } } } }
/* * Finds tiles to destroy by Avatar tile */ private List <GameObject> GetAvatarMatches(GameObject tile) { GameTileBase tileScript = tile.GetComponent <GameTileBase>(); List <GameObject> tiles = new List <GameObject>(); if (!tile) { return(tiles); } GameTileType gameTileType = tileScript.GetGameTileType(); print("Bending " + tile + " and " + gameTileType); for (int i = 0; i < gameBoard.width; i++) { for (int j = 0; j < gameBoard.height; j++) { // Checks for the avatar tile in list if (tileScript == gameBoard.allGameTiles[i, j].GetComponent <GameTileBase>()) { tiles.Add(gameBoard.allGameTiles[i, j]); gameBoard.allGameTiles[tileScript.currentCol, tileScript.currentRow].GetComponent <GameTileBase>().SetHasMatched(true); } // Finds tiles of same game tile type if (gameBoard.allGameTiles[i, j].GetComponent <GameTileBase>().GetGameTileType() == gameTileType) { tiles.Add(gameBoard.allGameTiles[i, j]); gameBoard.allGameTiles[i, j].GetComponent <GameTileBase>().SetHasMatched(true); } // All tiles, if both are avtar else if (tileScript.GetTileType() == TileType.Avatar && tileScript.GetOtherTile().GetComponent <GameTileBase>().GetTileType() == TileType.Avatar) { tiles.Add(gameBoard.allGameTiles[i, j]); gameBoard.allGameTiles[i, j].GetComponent <GameTileBase>().SetHasMatched(true); } } } return(tiles); }