public void processTapGesture(Vector2 tapPos) { if (foundItem && Managers.Player.Alive) { recalculateNumbers(); LevelTile foundLT = foundItem.levelTile; if (foundLT.tileType != LevelTile.TileType.MAP) { //Reveal the found LT revealTile(foundLT, true); //Reveal the tiles around the found LT foreach (LevelTile levelTile in getSurroundingTiles(foundLT)) { if (levelTile.Revealed) { revealTile(levelTile, true); } } //Check if goals have been achieved if (Managers.Player.GoalAchieved) { //Check if map has been completed if (Managers.Player.completedMap()) { //Go to latest revealed location Managers.Camera.moveTo( FindObjectOfType <MapLineUpdater>().LastRevealedSpot ); } else { //Go to start Managers.Camera.moveTo(Managers.Start); } } } else { //Check if map has been completed if (Managers.Player.completedMap()) { //Go to latest revealed location Managers.Camera.moveTo( FindObjectOfType <MapLineUpdater>().LastRevealedSpot ); } } foundItem.retire(); foundItem = null; return; } if (checkReset(tapPos)) { return; } LevelTile lt = getTile(tapPos); if (lt != null) { //If it's revealed if (lt.Revealed) { //Auto-Reveal //If the count of surrounding flags equals //the count of surrounding trap tiles, int itemCount = getAdjacentCount(lt, LevelTile.TileType.TRAP); itemCount += getAdjacentCount(lt, LevelTile.TileType.TREASURE); if (lt.Empty && lt.tileType != LevelTile.TileType.MAP && getAdjacentFlagCount(lt) == itemCount) { //Reveal the surrounding non-flagged tiles foreach (LevelTile neighbor in getSurroundingTiles(lt)) { if (!neighbor.Flagged && !neighbor.Revealed) { if (neighbor.tileType == LevelTile.TileType.TRAP) { Managers.Player.takeHit(); } if (neighbor.tileType == LevelTile.TileType.TREASURE) { Managers.Player.findTrophy(); } revealTile(neighbor); } } if (!Managers.Player.Alive) { revealBoard(); } } //Auto-Flag //If the count of surrounding unrevealed tiles equals //the count of surrounding trap tiles, if (lt.Empty && lt.tileType != LevelTile.TileType.MAP && getAdjacentRevealedCount(lt, true) == itemCount) { //Flag the surrounding non-revealed tiles foreach (LevelTile neighbor in getSurroundingTiles(lt)) { if (!neighbor.Flagged && !neighbor.Revealed) { //Flag it processFlagGesture(neighbor.transform.position); } } } } //If it's not flagged if (!lt.Flagged) { if (!anyRevealed) { generateLevelPostTap(tapPos); anyRevealed = true; } if ((!lt.Revealed) || lt.DetectedAny) { Managers.Effect.highlightChange(lt); } LevelTile.TileType revealedItem = LevelTile.TileType.EMPTY; bool shouldRevealBoard = false; bool prevRevealed = lt.Revealed; if (lt.tileType == LevelTile.TileType.TRAP) { revealedItem = LevelTile.TileType.TRAP; if (!Managers.Player.takeHit()) { shouldRevealBoard = true; } } if (lt.tileType == LevelTile.TileType.TREASURE) { revealedItem = LevelTile.TileType.TREASURE; Managers.Player.findTrophy(); } if (!LevelTile.empty(revealedItem)) { lt.Revealed = true; Managers.Effect.highlightChange(lt); if (shouldRevealBoard) { revealBoard(); } generatePostItemReveal(revealedItem); } else { revealTile(lt); } if (lt.tileType == LevelTile.TileType.MAP) { //if it's already been revealed //but not activated yet if (prevRevealed && !lt.Activated) { lt.Activated = true; Managers.Effect.highlightChange(lt); generatePostItemReveal(LevelTile.TileType.MAP); } } } } }