Merge branch 'master' of manuel-voegele.de:inf3
This commit is contained in:
@@ -17,12 +17,23 @@ namespace WorldOfPeacecraft
|
|||||||
private Image Dragon2;
|
private Image Dragon2;
|
||||||
private Image Dragon3;
|
private Image Dragon3;
|
||||||
private Image Forest;
|
private Image Forest;
|
||||||
|
private Image ForestLeft;
|
||||||
|
private Image ForestRight;
|
||||||
|
private Image ForestTop;
|
||||||
|
private Image ForestBottom;
|
||||||
private Image Knight;
|
private Image Knight;
|
||||||
private Image Walkable;
|
private Image Walkable;
|
||||||
private Image Water;
|
private Image Water;
|
||||||
private Image Wall;
|
private Image Wall;
|
||||||
private Image Flowers;
|
private Image Flowers;
|
||||||
private Random random = new Random ();
|
private Image BeachTop;
|
||||||
|
private Image BeachBottom;
|
||||||
|
private Image BeachLeft;
|
||||||
|
private Image BeachRight;
|
||||||
|
private Image BeachTopLeft;
|
||||||
|
private Image BeachTopRight;
|
||||||
|
private Image BeachBottomLeft;
|
||||||
|
private Image BeachBottomRight;
|
||||||
private int FlowerCounter;
|
private int FlowerCounter;
|
||||||
|
|
||||||
public MapPanel (IBackend backend)
|
public MapPanel (IBackend backend)
|
||||||
@@ -35,11 +46,30 @@ namespace WorldOfPeacecraft
|
|||||||
Dragon2 = Image.FromFile (ImagesFolder + "dragon2.png");
|
Dragon2 = Image.FromFile (ImagesFolder + "dragon2.png");
|
||||||
Dragon3 = Image.FromFile (ImagesFolder + "dragon3.png");
|
Dragon3 = Image.FromFile (ImagesFolder + "dragon3.png");
|
||||||
Forest = Image.FromFile (ImagesFolder + "forest.png");
|
Forest = Image.FromFile (ImagesFolder + "forest.png");
|
||||||
|
ForestLeft = Image.FromFile (ImagesFolder + "forest_left.png");
|
||||||
|
ForestRight = Image.FromFile (ImagesFolder + "forest_right.png");
|
||||||
|
ForestTop = Image.FromFile (ImagesFolder + "forest_top.png");
|
||||||
|
ForestBottom = Image.FromFile (ImagesFolder + "forest_bottom.png");
|
||||||
Knight = Image.FromFile (ImagesFolder + "knight.png");
|
Knight = Image.FromFile (ImagesFolder + "knight.png");
|
||||||
Walkable = Image.FromFile (ImagesFolder + "walkable.jpg");
|
Walkable = Image.FromFile (ImagesFolder + "walkable.jpg");
|
||||||
Water = Image.FromFile (ImagesFolder + "water.jpg");
|
Water = Image.FromFile (ImagesFolder + "water.jpg");
|
||||||
Wall = Image.FromFile(ImagesFolder + "wall.jpg");
|
Wall = Image.FromFile(ImagesFolder + "wall.jpg");
|
||||||
Flowers = Image.FromFile(ImagesFolder + "flowers.png");
|
Flowers = Image.FromFile(ImagesFolder + "flowers.png");
|
||||||
|
BeachBottom = Image.FromFile (ImagesFolder + "beach.png");
|
||||||
|
BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone);
|
||||||
|
BeachTop = RotateFlipImage (BeachBottom, RotateFlipType.Rotate180FlipNone);
|
||||||
|
BeachRight = RotateFlipImage (BeachBottom, RotateFlipType.Rotate270FlipNone);
|
||||||
|
BeachBottomRight = Image.FromFile (ImagesFolder + "beachcorner.png");
|
||||||
|
BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone);
|
||||||
|
BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone);
|
||||||
|
BeachTopRight = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate270FlipNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image RotateFlipImage(Image image, RotateFlipType type)
|
||||||
|
{
|
||||||
|
Image rotated = new Bitmap(image);
|
||||||
|
rotated.RotateFlip (type);
|
||||||
|
return rotated;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLayout (LayoutEventArgs levent)
|
protected override void OnLayout (LayoutEventArgs levent)
|
||||||
@@ -96,9 +126,7 @@ namespace WorldOfPeacecraft
|
|||||||
FlowerCounter = 0;
|
FlowerCounter = 0;
|
||||||
for (int y = 0; y < map.GetLength(1); y++) {
|
for (int y = 0; y < map.GetLength(1); y++) {
|
||||||
for (int x = 0; x < map.GetLength(0); x++) {
|
for (int x = 0; x < map.GetLength(0); x++) {
|
||||||
int posx = x * TileSize;
|
PaintTile (g, map, x, y);
|
||||||
int posy = y * TileSize;
|
|
||||||
PaintTile (g, map [x, y], posx, posy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,23 +135,76 @@ namespace WorldOfPeacecraft
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PaintTile (Graphics g, ITile tile, int x, int y)
|
public void PaintTile (Graphics g, ITile[,] map, int locx, int locy)
|
||||||
{
|
{
|
||||||
|
ITile tile = map [locx, locy];
|
||||||
|
int x = locx * TileSize;
|
||||||
|
int y = locy * TileSize;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
if (tile.IsWater ()) {
|
if (tile.IsWater ()) {
|
||||||
image = Water;
|
PaintImage(g, x, y, Water);
|
||||||
} else if (tile.IsWall ()) {
|
} else if (tile.IsWall ()) {
|
||||||
image = Wall;
|
PaintImage (g, x, y, Wall);
|
||||||
} else {
|
} else {
|
||||||
image = Walkable;
|
PaintImage (g, x, y, Walkable);
|
||||||
}
|
bool beachPlaced = false;
|
||||||
if (image != null) {
|
if (locx > 0 && map[locx - 1,locy].IsWater()) {
|
||||||
PaintImage (g, x, y, image);
|
PaintImage(g, x, y, BeachLeft);
|
||||||
} else {
|
beachPlaced = true;
|
||||||
g.FillRectangle (new SolidBrush (Color.Red), x, y, TileSize, TileSize);
|
}
|
||||||
|
if (locx < map.GetLength(0) - 1 && map[locx + 1,locy].IsWater()) {
|
||||||
|
PaintImage (g, x, y, BeachRight);
|
||||||
|
beachPlaced = true;
|
||||||
|
}
|
||||||
|
if (locy > 0 && map[locx, locy - 1].IsWater()) {
|
||||||
|
PaintImage (g, x, y, BeachTop);
|
||||||
|
beachPlaced = true;
|
||||||
|
}
|
||||||
|
if (locy < map.GetLength(1) - 1 && map[locx, locy + 1].IsWater()) {
|
||||||
|
PaintImage (g, x, y, BeachBottom);
|
||||||
|
beachPlaced = true;
|
||||||
|
}
|
||||||
|
if (!beachPlaced)
|
||||||
|
{
|
||||||
|
if (locx > 0)
|
||||||
|
{
|
||||||
|
if (locy > 0 && map[locx - 1, locy - 1].IsWater())
|
||||||
|
{
|
||||||
|
PaintImage (g, x, y, BeachTopLeft);
|
||||||
|
}
|
||||||
|
else if (locy < map.GetLength(1) - 1 && map[locx - 1, locy + 1].IsWater())
|
||||||
|
{
|
||||||
|
PaintImage (g, x, y, BeachBottomLeft);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (locx < map.GetLength(0) - 1)
|
||||||
|
{
|
||||||
|
if (locy > 0 && map[locx + 1, locy - 1].IsWater())
|
||||||
|
{
|
||||||
|
PaintImage (g, x, y, BeachTopRight);
|
||||||
|
}
|
||||||
|
else if (locy < map.GetLength(1) - 1 && map[locx + 1, locy + 1].IsWater())
|
||||||
|
{
|
||||||
|
PaintImage (g, x, y, BeachBottomRight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tile.IsForest ()) {
|
if (tile.IsForest ()) {
|
||||||
PaintImage (g, x, y, Forest);
|
PaintImage (g, x, y, Forest);
|
||||||
|
if (locx > 0 && map[locx - 1,locy].IsForest()) {
|
||||||
|
PaintImage(g, x, y, ForestLeft);
|
||||||
|
}
|
||||||
|
if (locx < map.GetLength(0) - 1 && map[locx + 1,locy].IsForest()) {
|
||||||
|
PaintImage (g, x, y, ForestRight);
|
||||||
|
}
|
||||||
|
if (locy > 0 && map[locx, locy - 1].IsForest()) {
|
||||||
|
PaintImage (g, x, y, ForestTop);
|
||||||
|
}
|
||||||
|
if (locy < map.GetLength(1) - 1 && map[locx, locy + 1].IsForest()) {
|
||||||
|
PaintImage (g, x, y, ForestBottom);
|
||||||
|
}
|
||||||
} else if (tile.IsWalkable()) {
|
} else if (tile.IsWalkable()) {
|
||||||
if (FlowerCounter == 4) {
|
if (FlowerCounter == 4) {
|
||||||
PaintImage (g, x, y, Flowers);
|
PaintImage (g, x, y, Flowers);
|
||||||
@@ -137,7 +218,7 @@ namespace WorldOfPeacecraft
|
|||||||
PaintImage (g, x, y, BowAndArrow);
|
PaintImage (g, x, y, BowAndArrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PaintEntities (Graphics g)
|
public void PaintEntities (Graphics g)
|
||||||
{
|
{
|
||||||
IEnumerable<IEntity> dragons = Backend.GetDragons ();
|
IEnumerable<IEntity> dragons = Backend.GetDragons ();
|
||||||
|
|||||||
Reference in New Issue
Block a user