From 202cd1638e45731560987e49ab7001fb4fb7d2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Sat, 5 Apr 2014 13:55:18 +0200 Subject: [PATCH] =?UTF-8?q?Setter=20f=C3=BCr=20das=20Backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Backend.cs | 26 ++++++++++++++++++++--- src/Entity.cs | 56 +++++++++++++++++++++++++------------------------- src/Map.cs | 7 +++---- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/Backend.cs b/src/Backend.cs index 3b3ab0d..d913075 100644 --- a/src/Backend.cs +++ b/src/Backend.cs @@ -9,27 +9,47 @@ namespace Frontend private Receiver Rec; private Parser Parse; private TcpClient Client; + private Dictionary Dragons; + private Dictionary Players; + private Map Map; public Backend () { Parse = new Parser(); Client = new TcpClient("localhost",9999); Rec = new Receiver(Client, Parse); + Dragons = new Dictionary(); + Players = new Dictionary(); } public IEnumerable getDragons() { - return null; + return Dragons.Values; } public IEnumerable getPlayers() { - return null; + return Players.Values; + } + + public void SetDragon (Dragon dragon) + { + Dragons[dragon.GetId()] = dragon; + } + + public void SetPlayer (Player player) + { + Players[player.GetId()] = player; + } + + public void SetMap (Map map) + { + this.Map = map; } public ITile[,] getMap() { - return null; + return Map.GetTiles(); } public void sendCommand(string command) diff --git a/src/Entity.cs b/src/Entity.cs index a35766e..b9a1b14 100644 --- a/src/Entity.cs +++ b/src/Entity.cs @@ -9,64 +9,64 @@ namespace WorldOfPeacecraft { public abstract class Entity : IPositionable { - public int id; - public int posX; - public int posY; - public string desc; - public bool busy; + public int Id; + public int PosX; + public int PosY; + public string Desc; + public bool Busy; public Entity (int id, int posX, int posY, string desc, bool busy) { - this.setId (id); - this.setPosX (posX); - this.setPosY (posY); - this.setDesc (desc); - this.setBusy (busy); + this.SetId (id); + this.SetPosX (posX); + this.SetPosY (posY); + this.SetDesc (desc); + this.SetBusy (busy); } - public void setId (int id) + public void SetId (int id) { - this.id = id; + this.Id = id; } - public int getId () + public int GetId () { - return id; + return Id; } - public void setPosX (int x) + public void SetPosX (int x) { - this.posX = x; + this.PosX = x; } - public int getXPosition () + public int GetXPosition () { - return posX; + return PosX; } - public void setPosY (int y) + public void SetPosY (int y) { - this.posY = y; + this.PosY = y; } - public int getYPosition () + public int GetYPosition () { - return posY; + return PosY; } - public void setDesc (string desc) + public void SetDesc (string desc) { - this.desc = desc; + this.Desc = desc; } - public void setBusy (bool busy) + public void SetBusy (bool busy) { - this.busy = busy; + this.Busy = busy; } - public bool getBusy () + public bool GetBusy () { - return busy; + return Busy; } } diff --git a/src/Map.cs b/src/Map.cs index 260958e..65f368e 100644 --- a/src/Map.cs +++ b/src/Map.cs @@ -11,17 +11,16 @@ namespace WorldOfPeacecraft map = new Tile[height, width]; } - public void setTile (Tile t) + public void SetTile (Tile t) { int x = t.getX (); int y = t.getY (); map [x, y] = t; } - public Tile getTile (int x, int y) + public Tile[,] GetTiles () { - - return map [x, y]; + return map; } } }