-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Volume change on ambient sounds based on proximity to sound tiles
- Loading branch information
1 parent
ab1b045
commit ba4c6df
Showing
4 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using EOLib.Domain.Map; | ||
using EOLib.IO.Map; | ||
using System; | ||
|
||
namespace EOLib.Domain.Extensions | ||
{ | ||
public static class MapExtensions | ||
{ | ||
public static int GetDistanceToClosestTileSpec(this IMapFile map, TileSpec spec, MapCoordinate source) | ||
{ | ||
var shortestDistance = int.MaxValue; | ||
for (int row = 0; row < map.Properties.Height; row++) | ||
{ | ||
for (int col = 0; col < map.Properties.Width; col++) | ||
{ | ||
if (map.Tiles[row, col] != spec) | ||
continue; | ||
|
||
var distance = Math.Abs(source.X - col) + Math.Abs(source.Y - row); | ||
if (distance < shortestDistance) | ||
shortestDistance = distance; | ||
} | ||
} | ||
|
||
return shortestDistance; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters