Difference between revisions of "2021 - Tile"
(→Things to note) |
(→Things to note) |
||
Line 69: | Line 69: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Things to note= | =Things to note= | ||
− | This is a containing class for Piece's. | + | This is a containing class for Piece's, ie the piece currently on this tile. |
Use of protected. | Use of protected. | ||
Use of public. | Use of public. |
Revision as of 11:52, 3 September 2020
Actual Code
class Tile
{
protected string terrain;
protected int x, y, z;
protected Piece pieceInTile;
protected List<Tile> neighbours = new List<Tile>();
public Tile(int xcoord, int ycoord, int zcoord)
{
x = xcoord;
y = ycoord;
z = zcoord;
terrain = " ";
pieceInTile = null;
}
public int GetDistanceToTileT(Tile t)
{
return Math.Max(Math.Max(Math.Abs(Getx() - t.Getx()), Math.Abs(Gety() - t.Gety())), Math.Abs(Getz() - t.Getz()));
}
public void AddToNeighbours(Tile n)
{
neighbours.Add(n);
}
public List<Tile> GetNeighbours()
{
return neighbours;
}
public void SetPiece(Piece thePiece)
{
pieceInTile = thePiece;
}
public void SetTerrain(string t)
{
terrain = t;
}
public int Getx()
{
return x;
}
public int Gety()
{
return y;
}
public int Getz()
{
return z;
}
public string GetTerrain()
{
return terrain;
}
public Piece GetPieceInTile()
{
return pieceInTile;
}
}
Things to note
This is a containing class for Piece's, ie the piece currently on this tile.
Use of protected.
Use of public.