Interfaces der DefaultGui angepasst
This commit is contained in:
@@ -17,17 +17,17 @@ namespace Frontend
|
||||
Rec = new Receiver(Client, Parse);
|
||||
}
|
||||
|
||||
public List<IPositionable> getDragons()
|
||||
public IEnumerable<IPositionable> getDragons()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<IPositionable> getPlayers()
|
||||
public IEnumerable<IPositionable> getPlayers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public ITile[][] getMap()
|
||||
public ITile[,] getMap()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -120,14 +120,13 @@ namespace Frontend
|
||||
/// <param name="e"></param>
|
||||
private void board_PaintMap(object sender, System.Windows.Forms.PaintEventArgs e) {
|
||||
Size tileSize = this.getTileSize();
|
||||
ITile[][] cells = this.backend.getMap();
|
||||
ITile[,] cells = this.backend.getMap();
|
||||
// validity checked beforehand in getTileSize
|
||||
Debug.Assert(cells != null);
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle);
|
||||
Graphics g = this.CreateGraphics();
|
||||
for(int x = 0; x < cells.Length; x++) {
|
||||
for(int y = 0; y < cells[x].Length; y++) {
|
||||
this.drawMapTile(buffer.Graphics, cells[x][y], x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height);
|
||||
for(int x = 0; x < cells.GetLength(0); x++) {
|
||||
for(int y = 0; y < cells.GetLength(1); y++) {
|
||||
this.drawMapTile(buffer.Graphics, cells[x,y], x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height);
|
||||
}
|
||||
}
|
||||
buffer.Render();
|
||||
@@ -140,12 +139,12 @@ namespace Frontend
|
||||
/// <param name="e"></param>
|
||||
private void board_PaintEntities(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||
{
|
||||
List<IPositionable> dragons = this.backend.getDragons();
|
||||
IEnumerable<IPositionable> dragons = this.backend.getDragons();
|
||||
foreach (IPositionable dragon in dragons)
|
||||
{
|
||||
this.drawDragon(e.Graphics, dragon);
|
||||
}
|
||||
List<IPositionable> players = this.backend.getPlayers();
|
||||
IEnumerable<IPositionable> players = this.backend.getPlayers();
|
||||
foreach (IPositionable player in players)
|
||||
{
|
||||
this.drawPlayer(e.Graphics, player);
|
||||
@@ -234,21 +233,21 @@ namespace Frontend
|
||||
/// <returns>the size of one tile to fit the whole map on the board</returns>
|
||||
protected Size getTileSize()
|
||||
{
|
||||
IPositionable[][] cells = this.backend.getMap();
|
||||
IPositionable[,] cells = this.backend.getMap();
|
||||
if (cells == null)
|
||||
{
|
||||
throw new ArgumentNullException("backend returned null as map");
|
||||
}
|
||||
if (cells.Length == 0)
|
||||
if (cells.GetLength(0) == 0)
|
||||
{
|
||||
throw new IndexOutOfRangeException("outer dimension of the retrieved map has length 0");
|
||||
}
|
||||
if (cells[0].Length == 0)
|
||||
if (cells.GetLength(1) == 0)
|
||||
{
|
||||
throw new IndexOutOfRangeException("inner dimension of the retrieved map has length 0");
|
||||
}
|
||||
int cellWidth = this.board.Size.Width / cells.Length;
|
||||
int cellHeight = this.board.Size.Height / cells[0].Length;
|
||||
int cellWidth = this.board.Size.Width / cells.GetLength(0);
|
||||
int cellHeight = this.board.Size.Height / cells.GetLength(1);
|
||||
return new Size(cellWidth, cellHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,18 +15,18 @@ namespace Frontend
|
||||
/// Method to get an arbitrary collection of dragons
|
||||
/// </summary>
|
||||
/// <returns>a list of dragons that are currently on the map</returns>
|
||||
List<IPositionable> getDragons();
|
||||
IEnumerable<IPositionable> getDragons();
|
||||
/// <summary>
|
||||
/// Method to get an arbitrary collection of players
|
||||
/// </summary>
|
||||
/// <returns>list of players that are currently on the map</returns>
|
||||
List<IPositionable> getPlayers();
|
||||
IEnumerable<IPositionable> getPlayers();
|
||||
/// <summary>
|
||||
/// Method to get a 2d-grid-representation of the map. The map doesn't actually has to be a 2d-array, but you should
|
||||
/// somehow be able to convert it into one.
|
||||
/// </summary>
|
||||
/// <returns>a 2d-array of ITiles, representing the map</returns>
|
||||
ITile[][] getMap();
|
||||
ITile[,] getMap();
|
||||
/// <summary>
|
||||
/// Sends a command to the server (such as ask:mv:dwn)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user