Wände werden nun mit runden ecken gezeichnet
14
inf3.csproj
@@ -9,29 +9,28 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>inf3</RootNamespace>
|
<RootNamespace>inf3</RootNamespace>
|
||||||
<AssemblyName>inf3</AssemblyName>
|
<AssemblyName>inf3</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<DebugSymbols>True</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug</OutputPath>
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
<DefineConstants>DEBUG;</DefineConstants>
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<ConsolePause>False</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
<additionalargs>/unsafe</additionalargs>
|
<additionalargs>/unsafe</additionalargs>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release</OutputPath>
|
<OutputPath>bin\Release</OutputPath>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<ConsolePause>False</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
@@ -78,9 +77,10 @@
|
|||||||
<Compile Include="src\Gui\MapPanel.cs" />
|
<Compile Include="src\Gui\MapPanel.cs" />
|
||||||
<Compile Include="src\Pathfinder.cs" />
|
<Compile Include="src\Pathfinder.cs" />
|
||||||
<Compile Include="src\Gui\IEntity.cs" />
|
<Compile Include="src\Gui\IEntity.cs" />
|
||||||
<Compile Include="src\Gui\SplashScreen.cs" />
|
|
||||||
<Compile Include="src\Gui\OnlinePlayerList.cs" />
|
<Compile Include="src\Gui\OnlinePlayerList.cs" />
|
||||||
<Compile Include="src\Gui\IPlayer.cs" />
|
<Compile Include="src\Gui\IPlayer.cs" />
|
||||||
|
<Compile Include="src\Gui\Splashscreen.cs" />
|
||||||
|
<Compile Include="src\Gui\Dummytile.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
52
src/Gui/Dummytile.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,8 +24,20 @@ namespace WorldOfPeacecraft
|
|||||||
private Image Knight;
|
private Image Knight;
|
||||||
private Image Walkable;
|
private Image Walkable;
|
||||||
private Image Water;
|
private Image Water;
|
||||||
private Image Wall;
|
|
||||||
private Image Flowers;
|
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 BeachTop;
|
||||||
private Image BeachBottom;
|
private Image BeachBottom;
|
||||||
private Image BeachLeft;
|
private Image BeachLeft;
|
||||||
@@ -53,7 +65,6 @@ namespace WorldOfPeacecraft
|
|||||||
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");
|
|
||||||
Flowers = Image.FromFile(ImagesFolder + "flowers.png");
|
Flowers = Image.FromFile(ImagesFolder + "flowers.png");
|
||||||
BeachBottom = Image.FromFile (ImagesFolder + "beach.png");
|
BeachBottom = Image.FromFile (ImagesFolder + "beach.png");
|
||||||
BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone);
|
BeachLeft = RotateFlipImage (BeachBottom, RotateFlipType.Rotate90FlipNone);
|
||||||
@@ -63,6 +74,19 @@ namespace WorldOfPeacecraft
|
|||||||
BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone);
|
BeachBottomLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate90FlipNone);
|
||||||
BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone);
|
BeachTopLeft = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate180FlipNone);
|
||||||
BeachTopRight = RotateFlipImage (BeachBottomRight, RotateFlipType.Rotate270FlipNone);
|
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)
|
private Image RotateFlipImage(Image image, RotateFlipType type)
|
||||||
@@ -140,27 +164,42 @@ namespace WorldOfPeacecraft
|
|||||||
ITile tile = map [locx, locy];
|
ITile tile = map [locx, locy];
|
||||||
int x = locx * TileSize;
|
int x = locx * TileSize;
|
||||||
int y = locy * TileSize;
|
int y = locy * TileSize;
|
||||||
Image image = null;
|
if (tile.IsWall ()) {
|
||||||
if (tile.IsWater ()) {
|
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);
|
PaintImage(g, x, y, Water);
|
||||||
} else if (tile.IsWall ()) {
|
PaintWallInnerEdge(g, locx, locy, x, y, map);
|
||||||
PaintImage (g, x, y, Wall);
|
}
|
||||||
} else {
|
else {
|
||||||
PaintImage (g, x, y, Walkable);
|
PaintImage (g, x, y, Walkable);
|
||||||
|
PaintWallInnerEdge(g, locx, locy, x, y, map);
|
||||||
bool beachPlaced = false;
|
bool beachPlaced = false;
|
||||||
if (locx > 0 && map[locx - 1,locy].IsWater()) {
|
if (NullsafeIsWater(locx - 1, locy, map)) {
|
||||||
PaintImage(g, x, y, BeachLeft);
|
PaintImage(g, x, y, BeachLeft);
|
||||||
beachPlaced = true;
|
beachPlaced = true;
|
||||||
}
|
}
|
||||||
if (locx < map.GetLength(0) - 1 && map[locx + 1,locy].IsWater()) {
|
if (NullsafeIsWater(locx + 1, locy, map)) {
|
||||||
PaintImage (g, x, y, BeachRight);
|
PaintImage (g, x, y, BeachRight);
|
||||||
beachPlaced = true;
|
beachPlaced = true;
|
||||||
}
|
}
|
||||||
if (locy > 0 && map[locx, locy - 1].IsWater()) {
|
if (NullsafeIsWater(locx, locy - 1, map)) {
|
||||||
PaintImage (g, x, y, BeachTop);
|
PaintImage (g, x, y, BeachTop);
|
||||||
beachPlaced = true;
|
beachPlaced = true;
|
||||||
}
|
}
|
||||||
if (locy < map.GetLength(1) - 1 && map[locx, locy + 1].IsWater()) {
|
if (NullsafeIsWater(locx, locy + 1, map)) {
|
||||||
PaintImage (g, x, y, BeachBottom);
|
PaintImage (g, x, y, BeachBottom);
|
||||||
beachPlaced = true;
|
beachPlaced = true;
|
||||||
}
|
}
|
||||||
@@ -193,16 +232,16 @@ namespace WorldOfPeacecraft
|
|||||||
}
|
}
|
||||||
if (tile.IsForest ()) {
|
if (tile.IsForest ()) {
|
||||||
PaintImage (g, x, y, Forest);
|
PaintImage (g, x, y, Forest);
|
||||||
if (locx > 0 && map[locx - 1,locy].IsForest()) {
|
if (NullsafeIsForrest(locx - 1, locy, map)) {
|
||||||
PaintImage(g, x, y, ForestLeft);
|
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);
|
PaintImage (g, x, y, ForestRight);
|
||||||
}
|
}
|
||||||
if (locy > 0 && map[locx, locy - 1].IsForest()) {
|
if (NullsafeIsForrest(locx, locy - 1, map)) {
|
||||||
PaintImage (g, x, y, ForestTop);
|
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);
|
PaintImage (g, x, y, ForestBottom);
|
||||||
}
|
}
|
||||||
} else if (tile.IsWalkable()) {
|
} 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)
|
public void PaintEntities (Graphics g)
|
||||||
{
|
{
|
||||||
IEnumerable<IEntity> dragons = Backend.GetDragons ();
|
IEnumerable<IEntity> dragons = Backend.GetDragons ();
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.6 KiB |
BIN
textures/wall.xcf
Normal file
BIN
textures/wall_base.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/wall_corner_botleft.png
Normal file
|
After Width: | Height: | Size: 608 B |
BIN
textures/wall_corner_botright.png
Normal file
|
After Width: | Height: | Size: 592 B |
BIN
textures/wall_corner_topleft.png
Normal file
|
After Width: | Height: | Size: 577 B |
BIN
textures/wall_corner_topright.png
Normal file
|
After Width: | Height: | Size: 589 B |
BIN
textures/wall_edge_botleft.png
Normal file
|
After Width: | Height: | Size: 635 B |
BIN
textures/wall_edge_botright.png
Normal file
|
After Width: | Height: | Size: 614 B |
BIN
textures/wall_edge_topleft.png
Normal file
|
After Width: | Height: | Size: 621 B |
BIN
textures/wall_edge_topright.png
Normal file
|
After Width: | Height: | Size: 618 B |
BIN
textures/wall_inner_botleft.png
Normal file
|
After Width: | Height: | Size: 338 B |
BIN
textures/wall_inner_botright.png
Normal file
|
After Width: | Height: | Size: 333 B |
BIN
textures/wall_inner_topleft.png
Normal file
|
After Width: | Height: | Size: 370 B |
BIN
textures/wall_inner_topright.png
Normal file
|
After Width: | Height: | Size: 345 B |