From 06e069c0523ffccf11a6418dafea7884d1355b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 3 Apr 2014 11:47:37 +0200 Subject: [PATCH] Hausmeisterarbeiten --- inf3.csproj | 3 +- src/DefaultGui/Program.cs | 44 +++++----- src/Dragon.cs | 87 ++---------------- src/Entity.cs | 73 ++++++++++++++++ src/Map.cs | 42 ++++----- src/Player.cs | 105 ++++------------------ src/Program.cs | 11 +-- src/Receiver.cs | 26 +++--- src/Sender.cs | 25 +++--- src/Tile.cs | 179 ++++++++++++++++++-------------------- 10 files changed, 265 insertions(+), 330 deletions(-) create mode 100644 src/Entity.cs diff --git a/inf3.csproj b/inf3.csproj index 8f75b8b..2be5ef3 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -52,10 +52,11 @@ - + + diff --git a/src/DefaultGui/Program.cs b/src/DefaultGui/Program.cs index e79b1c8..21fb1f9 100644 --- a/src/DefaultGui/Program.cs +++ b/src/DefaultGui/Program.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Frontend -{ - static class Program - { - /// - /// Der Haupteinstiegspunkt für die Anwendung. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new DefaultGui(new Backend())); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Frontend +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + //[STAThread] + //static void Main() + //{ + // Application.EnableVisualStyles(); + // Application.SetCompatibleTextRenderingDefault(false); + // Application.Run(new DefaultGui(new Backend())); + //} + } +} diff --git a/src/Dragon.cs b/src/Dragon.cs index 7316de7..ea31469 100644 --- a/src/Dragon.cs +++ b/src/Dragon.cs @@ -4,86 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; - - public class Dragon +namespace WorldOfPeacecraft +{ + public class Dragon : Entity { - public int id; - public int posX; - public int posY; - public int points; - public string type; - public bool busy; - - public Dragon(int id, int posX, int posY, int points, string type, bool busy) + public Dragon(int id, int posX, int posY, string desc, bool busy) : base(id, posX, posY, desc, busy) { - this.setId(id); - this.setPosX(posX); - this.setPosY(posY); - this.setPoints(points); - this.setType(type); - this.setBusy(busy); + // Nothing to do } - - - public void setId(int id) - { - this.id = id; - } - - public int getId() - { - return id; - } - - public void setPosX(int x) - { - this.posX = x; - } - - public int getPosX() - { - return posX; - } - - public void setPosY(int y) - { - this.posY = y; - } - - public int getPosY() - { - return posY; - } - - public void setPoints(int points) - { - this.points = points; - } - - public int getPoints() - { - return points; - } - - public void setType(string type) - { - this.type = type; - } - - public string getType() - { - return type; - } - - public void setBusy(bool busy) - { - this.busy = busy; - } - - public bool getBusy() - { - return busy; - } - - } - + } +} diff --git a/src/Entity.cs b/src/Entity.cs new file mode 100644 index 0000000..a35766e --- /dev/null +++ b/src/Entity.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Frontend; + +namespace WorldOfPeacecraft +{ + public abstract class Entity : IPositionable + { + 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); + } + + public void setId (int id) + { + this.id = id; + } + + public int getId () + { + return id; + } + + public void setPosX (int x) + { + this.posX = x; + } + + public int getXPosition () + { + return posX; + } + + public void setPosY (int y) + { + this.posY = y; + } + + public int getYPosition () + { + return posY; + } + + public void setDesc (string desc) + { + this.desc = desc; + } + + public void setBusy (bool busy) + { + this.busy = busy; + } + + public bool getBusy () + { + return busy; + } + + } +} diff --git a/src/Map.cs b/src/Map.cs index ae376f2..260958e 100644 --- a/src/Map.cs +++ b/src/Map.cs @@ -1,28 +1,28 @@ using System; +namespace WorldOfPeacecraft +{ + public class Map + { + public Tile[,] map; + public Map (int height, int width) + { + map = new Tile[height, width]; + } - public class Map - { - public Tile[,] map; + public void setTile (Tile t) + { + int x = t.getX (); + int y = t.getY (); + map [x, y] = t; + } - public Map(int height, int width) - { - map = new Tile[height, width]; - } - - 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 getTile (int x, int y) + { - return map[x,y]; - } - - } + return map [x, y]; + } + } +} diff --git a/src/Player.cs b/src/Player.cs index aa80a0e..882d11f 100644 --- a/src/Player.cs +++ b/src/Player.cs @@ -1,89 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace WorldOfPeacecraft +{ + public class Player : Entity + { + private int Score; + public Player (int id, int posX, int posY, string desc, bool busy, int score) : base(id, posX, posY, desc, busy) + { + this.SetScore(score); + } - public class Player - { - public int id; - public int posX; - public int posY; - public int points; - public string type; - public bool busy; - - public Player(int id, int posX, int posY, int points, string type, bool busy) - { - this.setId(id); - this.setPosX(posX); - this.setPosY(posY); - this.setPoints(points); - this.setType(type); - this.setBusy(busy); - } - - - public void setId(int id) - { - this.id = id; - } - - public int getId() - { - return id; - } - - public void setPosX(int x) - { - this.posX = x; - } - - public int getPosX() - { - return posX; - } - - public void setPosY(int y) - { - this.posY = y; - } - - public int getPosY() - { - return posY; - } - - public void setPoints(int points) - { - this.points = points; - } - - public int getPoints() - { - return points; - } - - public void setType(string type) - { - this.type = type; - } - - public string getType() - { - return type; - } - - public void setBusy(bool busy) - { - this.busy = busy; - } - - public bool getBusy() - { - return busy; - } - - } + public void SetScore(int score) + { + this.Score = score; + } + public int GetScore () + { + return Score; + } + } +} diff --git a/src/Program.cs b/src/Program.cs index 25b5cfb..d9cb985 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,6 +1,7 @@ using System.Net.Sockets; using System.Threading; using System; +using WorldOfPeacecraft; public class Program { @@ -9,11 +10,11 @@ public class Program private Thread SenderThread; private Thread ReceiverThread; - //public static void Main () - //{ - // Program program = new Program(); - // program.StartThreads(); - //} + public static void Main () + { + Program program = new Program(); + program.StartThreads(); + } public Program () { diff --git a/src/Receiver.cs b/src/Receiver.cs index 52e3678..2043b3f 100644 --- a/src/Receiver.cs +++ b/src/Receiver.cs @@ -2,20 +2,22 @@ using System; using System.IO; using System.Net.Sockets; -class Receiver +namespace WorldOfPeacecraft { - private TcpClient Client; - private StreamReader Reader; - - public Receiver (TcpClient client) + class Receiver { - this.Client = client; - this.Reader = new StreamReader(Client.GetStream()); - } + private TcpClient Client; + private StreamReader Reader; - public string Receive () - { - return Reader.ReadLine(); - } + public Receiver (TcpClient client) + { + this.Client = client; + this.Reader = new StreamReader (Client.GetStream ()); + } + public string Receive () + { + return Reader.ReadLine (); + } + } } diff --git a/src/Sender.cs b/src/Sender.cs index a731aed..b61dd1e 100644 --- a/src/Sender.cs +++ b/src/Sender.cs @@ -3,19 +3,22 @@ using System.IO; using System.Net.Sockets; using System.Text; -public class Sender +namespace WorldOfPeacecraft { - private TcpClient Client; - - public Sender (TcpClient client) + public class Sender { - this.Client = client; - } + private TcpClient Client; - public void Send (String message) - { - StreamWriter writer = new StreamWriter(Client.GetStream()); - writer.WriteLine(message); - writer.Flush(); + public Sender (TcpClient client) + { + this.Client = client; + } + + public void Send (String message) + { + StreamWriter writer = new StreamWriter (Client.GetStream ()); + writer.WriteLine (message); + writer.Flush (); + } } } \ No newline at end of file diff --git a/src/Tile.cs b/src/Tile.cs index 2b92d6b..5e7966f 100644 --- a/src/Tile.cs +++ b/src/Tile.cs @@ -1,111 +1,106 @@ using System; +using Frontend; +namespace WorldOfPeacecraft +{ + public class Tile : ITile + { + public int x; + public int y; + public Entity entity; + public bool walkable; + public bool forest; + public bool huntable; + public bool water; + public Tile (int posX, int posY, bool walkable, bool forest, bool huntable, bool water) + { + this.setX (posX); + this.setY (posY); + this.setWalkable (walkable); + this.setForest (forest); + this.setHuntable (huntable); + this.setWater (water); + } - public class Tile - { - public int x; - public int y; - public Dragon drag; - public Player playr; - public bool isWalkable; - public bool isForest; - public bool isHuntable; - public bool isWater; + public void setX (int x) + { + this.x = x; + } - public Tile(int posX, int posY, bool walkable, bool forest, bool huntable, bool water) - { - this.setX(posX); - this.setY(posY); - this.setWalkable(walkable); - this.setForest(forest); - this.setHuntable(huntable); - this.setWater(water); - } + public int getX () + { + return x; + } - public void setX(int x) - { - this.x = x; - } + public int getXPosition () + { + return x; + } - public int getX() - { - return x; - } + public void setY (int y) + { + this.y = y; + } - public void setY(int y) - { - this.y = y; - } + public int getY () + { + return y; + } - public int getY() - { - return y; - } + public int getYPosition () + { + return y; + } - public void setDragon(Dragon drag) - { - this.drag = drag; - } + public void setEntity (Entity entity) + { + this.entity = entity; + } - public Dragon getDragon() - { - return drag; - } + public Entity getEntity () + { + return entity; + } - public void setPlayer(Player playr) - { - this.playr = playr; - } + public void setWalkable (bool walkable) + { + this.walkable = walkable; + } - public Player getPlayer() - { - return playr; - } + public bool isWalkable () + { + return walkable; + } - public void setWalkable(bool walkable) - { - this.isWalkable = walkable; - } + public void setForest (bool forest) + { + this.forest = forest; + } - public bool getWalkable() - { - return isWalkable; - } + public bool isForest () + { + return forest; + } - public void setForest(bool forest) - { - this.isForest = forest; - } + public void setHuntable (bool huntable) + { + this.huntable = huntable; + } - public bool getForest() - { - return isForest; - } + public bool isHuntable () + { + return huntable; + } - public void setHuntable(bool huntable) - { - this.isHuntable = huntable; - } - - public bool getHuntable() - { - return isHuntable; - } - - public void setWater(bool water) - { - this.isWater = water; - } - - public bool getWater() - { - return isWater; - } - - - - - - } + public void setWater (bool water) + { + this.water = water; + } + public bool isWater () + { + return water; + } + } +} \ No newline at end of file