private void generatePostItemReveal(LevelTile.TileType tileType) { foreach (LevelGenerator lgen in Level.postRevealLevelGenerators) { lgen.generatePostReveal(tileMap, tileType); } }
public override void generatePostReveal(GameObject[,] tileMap, LevelTile.TileType tileType) { if (tileType == LevelTile.TileType.MAP) { mapLineSegmentRevealedCount++; onMapSegmentRevealed?.Invoke(this, mapLineSegmentRevealedCount); } }
/// <summary> /// Returns the number of tiles of the given type are surrounding the given tile, /// not including the tile itself /// </summary> /// <param name="lt"></param> /// <param name="tileType"></param> /// <param name="notTheType">True to get the amount that is NOT the given type</param> /// <returns></returns> public static int getAdjacentCount(LevelTile lt, LevelTile.TileType tileType, bool notTheType = false) { int count = 0; foreach (LevelTile levelTile in getSurroundingTiles(lt)) { if ((levelTile.tileType == tileType) != notTheType) { count++; } } return(count); }
public override void generatePostReveal(GameObject[,] tileMap, LevelTile.TileType tileType) { throw new System.NotImplementedException(); }
public abstract void generatePostReveal(GameObject[,] tileMap, LevelTile.TileType tileType);
public override void generatePostReveal(GameObject[,] tileMap, LevelTile.TileType tileType) { convert(tileMap); }
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); } } } } }