Hausmeisterarbeiten

This commit is contained in:
2014-04-03 11:47:37 +02:00
parent b4a84997fe
commit 06e069c052
10 changed files with 265 additions and 330 deletions

View File

@@ -52,10 +52,11 @@
<Compile Include="src\DefaultGui\test\MapCell.cs" /> <Compile Include="src\DefaultGui\test\MapCell.cs" />
<Compile Include="src\Dragon.cs" /> <Compile Include="src\Dragon.cs" />
<Compile Include="src\Map.cs" /> <Compile Include="src\Map.cs" />
<Compile Include="src\Player.cs" />
<Compile Include="src\Program.cs" /> <Compile Include="src\Program.cs" />
<Compile Include="src\Start.cs" /> <Compile Include="src\Start.cs" />
<Compile Include="src\Tile.cs" /> <Compile Include="src\Tile.cs" />
<Compile Include="src\Entity.cs" />
<Compile Include="src\Player.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="src\DefaultGui\" /> <Folder Include="src\DefaultGui\" />

View File

@@ -1,22 +1,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Frontend namespace Frontend
{ {
static class Program static class Program
{ {
/// <summary> /// <summary>
/// Der Haupteinstiegspunkt für die Anwendung. /// Der Haupteinstiegspunkt für die Anwendung.
/// </summary> /// </summary>
[STAThread] //[STAThread]
static void Main() //static void Main()
{ //{
Application.EnableVisualStyles(); // Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); // Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new DefaultGui(new Backend())); // Application.Run(new DefaultGui(new Backend()));
} //}
} }
} }

View File

@@ -4,86 +4,13 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WorldOfPeacecraft
public class Dragon {
public class Dragon : Entity
{ {
public int id; public Dragon(int id, int posX, int posY, string desc, bool busy) : base(id, posX, posY, desc, busy)
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)
{ {
this.setId(id); // Nothing to do
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;
}
}

73
src/Entity.cs Normal file
View File

@@ -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;
}
}
}

View File

@@ -1,28 +1,28 @@
using System; 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 void setTile (Tile t)
{ {
public Tile[,] map; int x = t.getX ();
int y = t.getY ();
map [x, y] = t;
}
public Map(int height, int width) public Tile getTile (int x, int y)
{ {
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)
{
return map[x,y]; return map [x, y];
} }
}
} }

View File

@@ -1,89 +1,22 @@
using System; namespace WorldOfPeacecraft
using System.Collections.Generic; {
using System.Linq; public class Player : Entity
using System.Text; {
using System.Threading.Tasks; 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 void SetScore(int score)
{ {
public int id; this.Score = score;
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 int GetScore ()
{
return Score;
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System; using System;
using WorldOfPeacecraft;
public class Program public class Program
{ {
@@ -9,11 +10,11 @@ public class Program
private Thread SenderThread; private Thread SenderThread;
private Thread ReceiverThread; private Thread ReceiverThread;
//public static void Main () public static void Main ()
//{ {
// Program program = new Program(); Program program = new Program();
// program.StartThreads(); program.StartThreads();
//} }
public Program () public Program ()
{ {

View File

@@ -2,20 +2,22 @@ using System;
using System.IO; using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
class Receiver namespace WorldOfPeacecraft
{ {
private TcpClient Client; class Receiver
private StreamReader Reader;
public Receiver (TcpClient client)
{ {
this.Client = client; private TcpClient Client;
this.Reader = new StreamReader(Client.GetStream()); private StreamReader Reader;
}
public string Receive () public Receiver (TcpClient client)
{ {
return Reader.ReadLine(); this.Client = client;
} this.Reader = new StreamReader (Client.GetStream ());
}
public string Receive ()
{
return Reader.ReadLine ();
}
}
} }

View File

@@ -3,19 +3,22 @@ using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
public class Sender namespace WorldOfPeacecraft
{ {
private TcpClient Client; public class Sender
public Sender (TcpClient client)
{ {
this.Client = client; private TcpClient Client;
}
public void Send (String message) public Sender (TcpClient client)
{ {
StreamWriter writer = new StreamWriter(Client.GetStream()); this.Client = client;
writer.WriteLine(message); }
writer.Flush();
public void Send (String message)
{
StreamWriter writer = new StreamWriter (Client.GetStream ());
writer.WriteLine (message);
writer.Flush ();
}
} }
} }

View File

@@ -1,111 +1,106 @@
using System; 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 void setX (int x)
{ {
public int x; this.x = x;
public int y; }
public Dragon drag;
public Player playr;
public bool isWalkable;
public bool isForest;
public bool isHuntable;
public bool isWater;
public Tile(int posX, int posY, bool walkable, bool forest, bool huntable, bool water) public int getX ()
{ {
this.setX(posX); return x;
this.setY(posY); }
this.setWalkable(walkable);
this.setForest(forest);
this.setHuntable(huntable);
this.setWater(water);
}
public void setX(int x) public int getXPosition ()
{ {
this.x = x; return x;
} }
public int getX() public void setY (int y)
{ {
return x; this.y = y;
} }
public void setY(int y) public int getY ()
{ {
this.y = y; return y;
} }
public int getY() public int getYPosition ()
{ {
return y; return y;
} }
public void setDragon(Dragon drag) public void setEntity (Entity entity)
{ {
this.drag = drag; this.entity = entity;
} }
public Dragon getDragon() public Entity getEntity ()
{ {
return drag; return entity;
} }
public void setPlayer(Player playr) public void setWalkable (bool walkable)
{ {
this.playr = playr; this.walkable = walkable;
} }
public Player getPlayer() public bool isWalkable ()
{ {
return playr; return walkable;
} }
public void setWalkable(bool walkable) public void setForest (bool forest)
{ {
this.isWalkable = walkable; this.forest = forest;
} }
public bool getWalkable() public bool isForest ()
{ {
return isWalkable; return forest;
} }
public void setForest(bool forest) public void setHuntable (bool huntable)
{ {
this.isForest = forest; this.huntable = huntable;
} }
public bool getForest() public bool isHuntable ()
{ {
return isForest; return huntable;
} }
public void setHuntable(bool huntable) public void setWater (bool water)
{ {
this.isHuntable = huntable; this.water = water;
} }
public bool getHuntable()
{
return isHuntable;
}
public void setWater(bool water)
{
this.isWater = water;
}
public bool getWater()
{
return isWater;
}
}
public bool isWater ()
{
return water;
}
}
}