Entities werden nun auf die Map gezeichnet
This commit is contained in:
@@ -27,15 +27,16 @@ namespace WorldOfPeacecraft
|
||||
Parse = new Parser (this, receiverBuffer);
|
||||
Rec = new Receiver (Client, receiverBuffer);
|
||||
Send = new Sender (Client, SenderBuffer);
|
||||
SenderBuffer.AddLine("get:map");
|
||||
SenderBuffer.AddLine ("get:map");
|
||||
SenderBuffer.AddLine ("get:ents");
|
||||
}
|
||||
|
||||
public IEnumerable<IPositionable> getDragons ()
|
||||
public IEnumerable<IPositionable> GetDragons ()
|
||||
{
|
||||
return Dragons.Values;
|
||||
}
|
||||
|
||||
public IEnumerable<IPositionable> getPlayers ()
|
||||
public IEnumerable<IPositionable> GetPlayers ()
|
||||
{
|
||||
return Players.Values;
|
||||
}
|
||||
|
||||
@@ -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