Interfaces der DefaultGui angepasst

This commit is contained in:
2014-04-04 17:28:53 +02:00
parent 1ac2fd448e
commit 24612b0901
3 changed files with 17 additions and 18 deletions

View File

@@ -17,17 +17,17 @@ namespace Frontend
Rec = new Receiver(Client, Parse); Rec = new Receiver(Client, Parse);
} }
public List<IPositionable> getDragons() public IEnumerable<IPositionable> getDragons()
{ {
return null; return null;
} }
public List<IPositionable> getPlayers() public IEnumerable<IPositionable> getPlayers()
{ {
return null; return null;
} }
public ITile[][] getMap() public ITile[,] getMap()
{ {
return null; return null;
} }

View File

@@ -120,14 +120,13 @@ namespace Frontend
/// <param name="e"></param> /// <param name="e"></param>
private void board_PaintMap(object sender, System.Windows.Forms.PaintEventArgs e) { private void board_PaintMap(object sender, System.Windows.Forms.PaintEventArgs e) {
Size tileSize = this.getTileSize(); Size tileSize = this.getTileSize();
ITile[][] cells = this.backend.getMap(); ITile[,] cells = this.backend.getMap();
// validity checked beforehand in getTileSize // validity checked beforehand in getTileSize
Debug.Assert(cells != null); Debug.Assert(cells != null);
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle); BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle);
Graphics g = this.CreateGraphics(); for(int x = 0; x < cells.GetLength(0); x++) {
for(int x = 0; x < cells.Length; x++) { for(int y = 0; y < cells.GetLength(1); y++) {
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);
this.drawMapTile(buffer.Graphics, cells[x][y], x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height);
} }
} }
buffer.Render(); buffer.Render();
@@ -140,12 +139,12 @@ namespace Frontend
/// <param name="e"></param> /// <param name="e"></param>
private void board_PaintEntities(object sender, System.Windows.Forms.PaintEventArgs e) 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) foreach (IPositionable dragon in dragons)
{ {
this.drawDragon(e.Graphics, dragon); this.drawDragon(e.Graphics, dragon);
} }
List<IPositionable> players = this.backend.getPlayers(); IEnumerable<IPositionable> players = this.backend.getPlayers();
foreach (IPositionable player in players) foreach (IPositionable player in players)
{ {
this.drawPlayer(e.Graphics, player); 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> /// <returns>the size of one tile to fit the whole map on the board</returns>
protected Size getTileSize() protected Size getTileSize()
{ {
IPositionable[][] cells = this.backend.getMap(); IPositionable[,] cells = this.backend.getMap();
if (cells == null) if (cells == null)
{ {
throw new ArgumentNullException("backend returned null as map"); 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"); 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"); throw new IndexOutOfRangeException("inner dimension of the retrieved map has length 0");
} }
int cellWidth = this.board.Size.Width / cells.Length; int cellWidth = this.board.Size.Width / cells.GetLength(0);
int cellHeight = this.board.Size.Height / cells[0].Length; int cellHeight = this.board.Size.Height / cells.GetLength(1);
return new Size(cellWidth, cellHeight); return new Size(cellWidth, cellHeight);
} }

View File

@@ -15,18 +15,18 @@ namespace Frontend
/// Method to get an arbitrary collection of dragons /// Method to get an arbitrary collection of dragons
/// </summary> /// </summary>
/// <returns>a list of dragons that are currently on the map</returns> /// <returns>a list of dragons that are currently on the map</returns>
List<IPositionable> getDragons(); IEnumerable<IPositionable> getDragons();
/// <summary> /// <summary>
/// Method to get an arbitrary collection of players /// Method to get an arbitrary collection of players
/// </summary> /// </summary>
/// <returns>list of players that are currently on the map</returns> /// <returns>list of players that are currently on the map</returns>
List<IPositionable> getPlayers(); IEnumerable<IPositionable> getPlayers();
/// <summary> /// <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 /// 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. /// somehow be able to convert it into one.
/// </summary> /// </summary>
/// <returns>a 2d-array of ITiles, representing the map</returns> /// <returns>a 2d-array of ITiles, representing the map</returns>
ITile[][] getMap(); ITile[,] getMap();
/// <summary> /// <summary>
/// Sends a command to the server (such as ask:mv:dwn) /// Sends a command to the server (such as ask:mv:dwn)
/// </summary> /// </summary>