diff --git a/inf3.csproj b/inf3.csproj
index a690624..f67c585 100644
--- a/inf3.csproj
+++ b/inf3.csproj
@@ -9,29 +9,28 @@
Exe
inf3
inf3
- v4.0
- True
+ true
full
- False
+ false
bin\Debug
DEBUG;
prompt
4
x86
- False
+ false
/unsafe
true
none
- True
+ true
bin\Release
prompt
4
x86
- False
+ false
true
@@ -78,9 +77,10 @@
-
+
+
diff --git a/src/Gui/Dummytile.cs b/src/Gui/Dummytile.cs
new file mode 100644
index 0000000..d518cf6
--- /dev/null
+++ b/src/Gui/Dummytile.cs
@@ -0,0 +1,52 @@
+namespace WorldOfPeacecraft
+{
+ // A ITile always returning it is a wall and 0,0 as position
+ public class Dummytile : ITile
+ {
+ private static Dummytile Instance = new Dummytile();
+
+ public Dummytile ()
+ {
+ }
+
+ public static Dummytile GetInstance()
+ {
+ return Instance;
+ }
+
+ public bool IsWall()
+ {
+ return true;
+ }
+
+ public bool IsWalkable()
+ {
+ return false;
+ }
+
+ public bool IsWater()
+ {
+ return false;
+ }
+
+ public bool IsForest()
+ {
+ return false;
+ }
+
+ public bool IsHuntable()
+ {
+ return false;
+ }
+
+ public int GetX()
+ {
+ return 0;
+ }
+
+ public int GetY ()
+ {
+ return 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Gui/MapPanel.cs b/src/Gui/MapPanel.cs
index cf976ec..5df6957 100644
--- a/src/Gui/MapPanel.cs
+++ b/src/Gui/MapPanel.cs
@@ -24,8 +24,20 @@ namespace WorldOfPeacecraft
private Image Knight;
private Image Walkable;
private Image Water;
- private Image Wall;
private Image Flowers;
+ private Image WallBase;
+ private Image WallEdgeTopLeft;
+ private Image WallEdgeTopRight;
+ private Image WallEdgeBotRight;
+ private Image WallEdgeBotLeft;
+ private Image WallCornerTopLeft;
+ private Image WallCornerTopRight;
+ private Image WallCornerBotRight;
+ private Image WallCornerBotLeft;
+ private Image WallInnerTopLeft;
+ private Image WallInnerTopRight;
+ private Image WallInnerBotRight;
+ private Image WallInnerBotLeft;
private Image BeachTop;
private Image BeachBottom;
private Image BeachLeft;
@@ -53,7 +65,6 @@ namespace WorldOfPeacecraft
Knight = Image.FromFile (ImagesFolder + "knight.png");
Walkable = Image.FromFile (ImagesFolder + "walkable.jpg");
Water = Image.FromFile (ImagesFolder + "water.jpg");
- Wall = Image.FromFile(ImagesFolder + "wall.jpg");
Flowers = Image.FromFile(ImagesFolder + "flowers.png");
BeachBottom = Image.FromFile (ImagesFolder + "beach.png");
BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone);
@@ -63,6 +74,19 @@ namespace WorldOfPeacecraft
BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone);
BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone);
BeachTopRight = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate270FlipNone);
+ WallBase = Image.FromFile(ImagesFolder + "wall_base.png");
+ WallEdgeBotLeft = Image.FromFile (ImagesFolder + "wall_edge_botleft.png");
+ WallEdgeBotRight = Image.FromFile (ImagesFolder + "wall_edge_botright.png");
+ WallEdgeTopLeft = Image.FromFile (ImagesFolder + "wall_edge_topleft.png");
+ WallEdgeTopRight = Image.FromFile (ImagesFolder + "wall_edge_topright.png");
+ WallCornerBotLeft = Image.FromFile (ImagesFolder + "wall_corner_botleft.png");
+ WallCornerBotRight = Image.FromFile (ImagesFolder + "wall_corner_botright.png");
+ WallCornerTopLeft = Image.FromFile (ImagesFolder + "wall_corner_topleft.png");
+ WallCornerTopRight = Image.FromFile (ImagesFolder + "wall_corner_topright.png");
+ WallInnerBotLeft = Image.FromFile (ImagesFolder + "wall_inner_botleft.png");
+ WallInnerBotRight = Image.FromFile (ImagesFolder + "wall_inner_botright.png");
+ WallInnerTopLeft = Image.FromFile (ImagesFolder + "wall_inner_topleft.png");
+ WallInnerTopRight = Image.FromFile (ImagesFolder + "wall_inner_topright.png");
}
private Image RotateFlipImage(Image image, RotateFlipType type)
@@ -140,27 +164,42 @@ namespace WorldOfPeacecraft
ITile tile = map [locx, locy];
int x = locx * TileSize;
int y = locy * TileSize;
- Image image = null;
- if (tile.IsWater ()) {
+ if (tile.IsWall ()) {
+ PaintImage(g, x, y, WallBase);
+ ITile top = GetTile(locx, locy - 1, map);
+ ITile topright = GetTile(locx + 1, locy - 1, map);
+ ITile right = GetTile(locx + 1, locy, map);
+ ITile botright = GetTile(locx + 1, locy + 1, map);
+ ITile bot = GetTile(locx, locy + 1, map);
+ ITile botleft = GetTile(locx - 1, locy + 1, map);
+ ITile left = GetTile(locx - 1, locy, map);
+ ITile topleft = GetTile(locx - 1, locy - 1, map);
+ int offset = TileSize - 12;
+ DrawWallEdge(g, CountWater (left, topleft, top), x, y, 0, 0, WallEdgeTopLeft, WallCornerTopLeft);
+ DrawWallEdge(g, CountWater (top, topright, right), x, y, offset, 0, WallEdgeTopRight, WallCornerTopRight);
+ DrawWallEdge(g, CountWater (right, botright, bot), x, y, offset, offset, WallEdgeBotRight, WallCornerBotRight);
+ DrawWallEdge(g, CountWater (bot, botleft, left), x, y, 0, offset, WallEdgeBotLeft, WallCornerBotLeft);
+ } else if (tile.IsWater ()) {
PaintImage(g, x, y, Water);
- } else if (tile.IsWall ()) {
- PaintImage (g, x, y, Wall);
- } else {
+ PaintWallInnerEdge(g, locx, locy, x, y, map);
+ }
+ else {
PaintImage (g, x, y, Walkable);
+ PaintWallInnerEdge(g, locx, locy, x, y, map);
bool beachPlaced = false;
- if (locx > 0 && map[locx - 1,locy].IsWater()) {
+ if (NullsafeIsWater(locx - 1, locy, map)) {
PaintImage(g, x, y, BeachLeft);
beachPlaced = true;
}
- if (locx < map.GetLength(0) - 1 && map[locx + 1,locy].IsWater()) {
+ if (NullsafeIsWater(locx + 1, locy, map)) {
PaintImage (g, x, y, BeachRight);
beachPlaced = true;
}
- if (locy > 0 && map[locx, locy - 1].IsWater()) {
+ if (NullsafeIsWater(locx, locy - 1, map)) {
PaintImage (g, x, y, BeachTop);
beachPlaced = true;
}
- if (locy < map.GetLength(1) - 1 && map[locx, locy + 1].IsWater()) {
+ if (NullsafeIsWater(locx, locy + 1, map)) {
PaintImage (g, x, y, BeachBottom);
beachPlaced = true;
}
@@ -193,16 +232,16 @@ namespace WorldOfPeacecraft
}
if (tile.IsForest ()) {
PaintImage (g, x, y, Forest);
- if (locx > 0 && map[locx - 1,locy].IsForest()) {
+ if (NullsafeIsForrest(locx - 1, locy, map)) {
PaintImage(g, x, y, ForestLeft);
}
- if (locx < map.GetLength(0) - 1 && map[locx + 1,locy].IsForest()) {
+ if (NullsafeIsForrest(locx + 1, locy, map)) {
PaintImage (g, x, y, ForestRight);
}
- if (locy > 0 && map[locx, locy - 1].IsForest()) {
+ if (NullsafeIsForrest(locx, locy - 1, map)) {
PaintImage (g, x, y, ForestTop);
}
- if (locy < map.GetLength(1) - 1 && map[locx, locy + 1].IsForest()) {
+ if (NullsafeIsForrest(locx, locy + 1, map)) {
PaintImage (g, x, y, ForestBottom);
}
} else if (tile.IsWalkable()) {
@@ -219,6 +258,90 @@ namespace WorldOfPeacecraft
}
}
+ private void PaintWallInnerEdge (Graphics g, int locx, int locy, int x, int y, ITile[,] map)
+ {
+ bool topWall = NullsafeIsWall (locx, locy - 1, map);
+ bool rightWall = NullsafeIsWall (locx + 1, locy, map);
+ bool botWall = NullsafeIsWall (locx, locy + 1, map);
+ bool leftWall = NullsafeIsWall (locx - 1, locy, map);
+ if (leftWall) {
+ if (topWall)
+ PaintImage (g, x, y, WallInnerTopLeft);
+ if (botWall)
+ PaintImage (g, x, y, WallInnerBotLeft);
+ }
+ if (rightWall) {
+ if (topWall)
+ PaintImage (g, x, y, WallInnerTopRight);
+ if (botWall)
+ PaintImage (g, x, y, WallInnerBotRight);
+ }
+ }
+
+ private void DrawWallEdge (Graphics g, int water, int x, int y, int offsetx, int offsety, Image edgeImage, Image cornerImage)
+ {
+ if (water == -1)
+ PaintImage (g, x, y, edgeImage);
+ else {
+ Rectangle src = new Rectangle(0 + offsetx, 0 + offsety, 12, 12);
+ Rectangle dst = new Rectangle(x + offsetx, y + offsety, 12, 12);
+ if (water == 3) {
+ g.DrawImage(Water, dst, src, GraphicsUnit.Pixel);
+ PaintImage(g, x, y, cornerImage);
+ }
+ else if (water == 0) {
+ g.DrawImage(Walkable, dst, src, GraphicsUnit.Pixel);
+ PaintImage(g, x, y, cornerImage);
+ }
+ else
+ PaintImage (g, x, y, edgeImage);
+ }
+ }
+
+ private static int CountWater (params ITile[] tiles)
+ {
+ int water = 0;
+ foreach (ITile tile in tiles) {
+ if (tile.IsWall())
+ return -1;
+ if (tile.IsWater())
+ water++;
+ }
+ return water;
+ }
+
+ private bool NullsafeIsWater (int x, int y, ITile[,] map)
+ {
+ ITile tile = GetTile (x, y, map);
+ if (tile == null)
+ return false;
+ return tile.IsWater();
+ }
+
+ private bool NullsafeIsWall (int x, int y, ITile[,] map)
+ {
+ ITile tile = GetTile (x, y, map);
+ if (tile == null)
+ return true;
+ return tile.IsWall();
+ }
+
+ private bool NullsafeIsForrest (int x, int y, ITile[,] map)
+ {
+ ITile tile = GetTile (x, y, map);
+ if (tile == null)
+ return false;
+ return tile.IsForest();
+ }
+
+ private static ITile GetTile (int x, int y, ITile[,] map)
+ {
+ if (x >= 0 && x < map.GetLength (0) && y >= 0 && y < map.GetLength (1)) {
+ return map[x,y];
+ }
+ return Dummytile.GetInstance();
+ }
+
public void PaintEntities (Graphics g)
{
IEnumerable dragons = Backend.GetDragons ();
diff --git a/textures/wall.jpg b/textures/wall.jpg
deleted file mode 100644
index c33c1c0..0000000
Binary files a/textures/wall.jpg and /dev/null differ
diff --git a/textures/wall.xcf b/textures/wall.xcf
new file mode 100644
index 0000000..fbda3a9
Binary files /dev/null and b/textures/wall.xcf differ
diff --git a/textures/wall_base.png b/textures/wall_base.png
new file mode 100644
index 0000000..5087413
Binary files /dev/null and b/textures/wall_base.png differ
diff --git a/textures/wall_corner_botleft.png b/textures/wall_corner_botleft.png
new file mode 100644
index 0000000..50c2e7d
Binary files /dev/null and b/textures/wall_corner_botleft.png differ
diff --git a/textures/wall_corner_botright.png b/textures/wall_corner_botright.png
new file mode 100644
index 0000000..b6203c5
Binary files /dev/null and b/textures/wall_corner_botright.png differ
diff --git a/textures/wall_corner_topleft.png b/textures/wall_corner_topleft.png
new file mode 100644
index 0000000..3f8d750
Binary files /dev/null and b/textures/wall_corner_topleft.png differ
diff --git a/textures/wall_corner_topright.png b/textures/wall_corner_topright.png
new file mode 100644
index 0000000..d52dd56
Binary files /dev/null and b/textures/wall_corner_topright.png differ
diff --git a/textures/wall_edge_botleft.png b/textures/wall_edge_botleft.png
new file mode 100644
index 0000000..17ac62e
Binary files /dev/null and b/textures/wall_edge_botleft.png differ
diff --git a/textures/wall_edge_botright.png b/textures/wall_edge_botright.png
new file mode 100644
index 0000000..e9e1713
Binary files /dev/null and b/textures/wall_edge_botright.png differ
diff --git a/textures/wall_edge_topleft.png b/textures/wall_edge_topleft.png
new file mode 100644
index 0000000..a0344d5
Binary files /dev/null and b/textures/wall_edge_topleft.png differ
diff --git a/textures/wall_edge_topright.png b/textures/wall_edge_topright.png
new file mode 100644
index 0000000..0343039
Binary files /dev/null and b/textures/wall_edge_topright.png differ
diff --git a/textures/wall_inner_botleft.png b/textures/wall_inner_botleft.png
new file mode 100644
index 0000000..b2d0fba
Binary files /dev/null and b/textures/wall_inner_botleft.png differ
diff --git a/textures/wall_inner_botright.png b/textures/wall_inner_botright.png
new file mode 100644
index 0000000..b590fbc
Binary files /dev/null and b/textures/wall_inner_botright.png differ
diff --git a/textures/wall_inner_topleft.png b/textures/wall_inner_topleft.png
new file mode 100644
index 0000000..7fbfdf8
Binary files /dev/null and b/textures/wall_inner_topleft.png differ
diff --git a/textures/wall_inner_topright.png b/textures/wall_inner_topright.png
new file mode 100644
index 0000000..4cf22ab
Binary files /dev/null and b/textures/wall_inner_topright.png differ