Aktuelle Version der DefaultGui

This commit is contained in:
2014-04-01 11:07:06 +02:00
parent a7a6c36aa8
commit 4a2a01853a
10 changed files with 631 additions and 587 deletions

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Frontend
{
/// <summary>
/// All classes in the test-directory are just classes to illustrate the concept of the frontend and its interfaces.
/// They are undocumented and not very well written and are using dummy-data with no connection to the actual server.
/// On purpose. Because you should come up with your own implementation. :)
/// </summary>
public class Backend : IBackend
{
public void sendCommand(string command)
{
Console.WriteLine("received command " + command);
}
public void sendChat(string message)
{
Console.WriteLine("received chatmessage " + message);
}
public List<IPositionable> getDragons() {
List<IPositionable> dragons = new List<IPositionable>();
dragons.Add(new Entity(0,1));
return dragons;
}
public List<IPositionable> getPlayers() {
List<IPositionable> players = new List<IPositionable>();
players.Add(new Entity(1, 1));
return players;
}
public ITile[][] getMap()
{
int size = 10;
// init
ITile[][] map = new ITile[size][];
for (int i = 0; i < size; i++)
{
map[i] = new ITile[size];
}
Random r = new Random();
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size; y++)
{
List<MapCellAttribute> attr = new List<MapCellAttribute>();
switch (r.Next(0, 5))
{
case 0:
attr.Add(MapCellAttribute.WATER);
break;
case 1:
attr.Add(MapCellAttribute.HUNTABLE);
attr.Add(MapCellAttribute.FOREST);
break;
case 2:
attr.Add(MapCellAttribute.FOREST);
break;
case 3:
attr.Add(MapCellAttribute.UNWALKABLE);
break;
case 4:
break;
}
map[x][y] = new MapCell(x, y, attr);
}
}
return map;
}
}
}

28
DefaultGui/test/Entity.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Frontend
{
public class Entity : IPositionable
{
int x, y;
public Entity(int x, int y)
{
this.x = x;
this.y = y;
}
public int getXPosition()
{
return this.x;
}
public int getYPosition()
{
return this.y;
}
}
}

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Frontend
{
public class MapCell : ITile
{
private int x,y;
private List<MapCellAttribute> attributes;
public MapCell(int x, int y, List<MapCellAttribute> attributes)
{
this.x = x;
this.y = y;
this.attributes = new List<MapCellAttribute>();
this.attributes.AddRange(attributes);
}
public int getXPosition()
{
return this.x;
}
public int getYPosition()
{
return this.y;
}
public bool isWalkable()
{
return !this.attributes.Contains(MapCellAttribute.UNWALKABLE);
}
public bool isForest()
{
return this.attributes.Contains(MapCellAttribute.FOREST);
}
public bool isHuntable()
{
return this.attributes.Contains(MapCellAttribute.HUNTABLE);
}
public bool isWater()
{
return this.attributes.Contains(MapCellAttribute.WATER);
}
}
public enum MapCellAttribute {UNWALKABLE, WATER, FOREST, HUNTABLE}
}