Skip to content

Instantly share code, notes, and snippets.

@Coditivity
Created November 27, 2018 10:37
Show Gist options
  • Save Coditivity/7c69606f75286d0c7f2b9ad60eb9e21d to your computer and use it in GitHub Desktop.
Save Coditivity/7c69606f75286d0c7f2b9ad60eb9e21d to your computer and use it in GitHub Desktop.
class WorldMap
{
public Tile[,] worldTiles = new Tile[150, 150];
/// <summary>
/// Check if the given tile is owned by the given player
/// </summary>
/// <param name="x">The x co-ordinate of the tile</param>
/// <param name="y">The y co-ordinate of the tile</param>
/// <param name="playerId">The id of the player</param>
/// <returns></returns>
bool CheckIfTileOwnedByPlayer(int x, int y, int playerId)
{
if(worldTiles[x, y].ownedPlayerId == playerId)
{
return true;//Yes, the player owns tile[x, y]
}
else
{
return false; //No, this player doesn't own this tile
}
}
/// <summary>
/// Check if the given tile is in the path of the given player
/// </summary>
/// <param name="x">The x co-ordinate of the tile</param>
/// <param name="y">The y co-ordinate of the tile</param>
/// <param name="playerId">The id of the player</param>
/// <returns></returns>
bool CheckIfTileInPath(int x, int y, int playerId)
{
if(worldTiles[x, y].pathPlayerId == playerId)
{
return true;//Yes, this tile is in the path of the player
}
else
{
return false;//No, the tile is not in the path of this player
}
}
/// <summary>
/// Set the tile to be owned by this player
/// </summary>
/// <param name="x">The x co-ordinate of the tile</param>
/// <param name="y">The y co-ordinate of the tile</param>
/// <param name="playerId">The id of the player</param>
void SetAsOwnedByPlayer(int x, int y, int playerId)
{
worldTiles[x, y].ownedPlayerId = playerId;
}
/// <summary>
/// Set the tile to be in the path of the player
/// </summary>
/// <param name="x">The x co-ordinate of the tile</param>
/// <param name="y">The y co-ordinate of the tile</param>
/// <param name="playerId">The id of the player</param>
void SetAsInPathOfPlayer(int x, int y, int playerId)
{
worldTiles[x, y].pathPlayerId = playerId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment