Entities werden nun auf die Map gezeichnet
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -54,6 +55,7 @@ namespace WorldOfPeacecraft
|
||||
Graphics g = buffer.Graphics;
|
||||
lock (Backend) {
|
||||
PaintMap (g);
|
||||
PaintEntities (g);
|
||||
}
|
||||
buffer.Render();
|
||||
}
|
||||
@@ -95,11 +97,34 @@ namespace WorldOfPeacecraft
|
||||
g.FillRectangle(new SolidBrush(color), posx, posy, tileSize, tileSize);
|
||||
}
|
||||
|
||||
public void PaintEntities (Graphics g)
|
||||
{
|
||||
IEnumerable<IPositionable> dragons = Backend.GetDragons ();
|
||||
IEnumerable<IPositionable> players = Backend.GetPlayers ();
|
||||
foreach (IPositionable dragon in dragons) {
|
||||
PaintEntity (g, dragon);
|
||||
}
|
||||
foreach (IPositionable player in players) {
|
||||
PaintEntity (g, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void PaintEntity (Graphics g, IPositionable entity)
|
||||
{
|
||||
int x = entity.GetX () * tileSize + tileSize / 2 - entitySize / 2;
|
||||
int y = entity.GetY () * tileSize + tileSize / 2 - entitySize / 2;
|
||||
g.FillRectangle (new SolidBrush (Color.Red), x, y, entitySize, entitySize);
|
||||
g.DrawRectangle (new Pen( new SolidBrush (Color.Black)), x, y, entitySize, entitySize);
|
||||
}
|
||||
|
||||
public void PerformRefresh ()
|
||||
{
|
||||
this.BeginInvoke(new MethodInvoker(delegate
|
||||
{
|
||||
ITile[,] map = Backend.GetMap();
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
int mapWidth = (map.GetLength(0)) * tileSize;
|
||||
int mapHeight = (map.GetLength(1)) * tileSize;
|
||||
this.SuspendLayout();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WorldOfPeacecraft
|
||||
{
|
||||
@@ -5,6 +6,10 @@ namespace WorldOfPeacecraft
|
||||
{
|
||||
ITile[,] GetMap();
|
||||
|
||||
IEnumerable<IPositionable> GetPlayers();
|
||||
|
||||
IEnumerable<IPositionable> GetDragons();
|
||||
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user