Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Thewest123 committed Jul 4, 2019
1 parent 3eddd45 commit c9d45d3
Show file tree
Hide file tree
Showing 174 changed files with 13,801 additions and 2 deletions.
Binary file added BattleshipsClient.exe
Binary file not shown.
Binary file added BattleshipsLibrary.dll
Binary file not shown.
Binary file added BattleshipsServer.exe
Binary file not shown.
Binary file added NetworkCommsDotNetComplete.dll
Binary file not shown.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# battleships-csharp
WinForm application with server/client
# Battleships C#
Final project for my C# programing class in WinForm applications

## Components
- Server (Console)
- Client (Windows Forms)
- Library

## Usage
1. The Console Server application
- Displaying the IPs on which the server listens
- Showing logs
- Changable name by setting more args when running from console


2. The Client Application
- Loggin Form
- Lobby Form
- Game Form
Binary file added source/.vs/BattleshipsGame/v15/.suo
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions source/BattleshipsClient/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
150 changes: 150 additions & 0 deletions source/BattleshipsClient/BattleshipsClient.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{15B79A33-1392-489D-87E0-3272D64D292B}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BattleshipsClient</RootNamespace>
<AssemblyName>BattleshipsClient</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NetworkCommsDotNetComplete">
<HintPath>F:\PLOCHA\NetworkCommsDotNetComplete.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Drawing.cs" />
<Compile Include="GameForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GameForm.Designer.cs">
<DependentUpon>GameForm.cs</DependentUpon>
</Compile>
<Compile Include="GridTile.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="LobbyForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LobbyForm.Designer.cs">
<DependentUpon>LobbyForm.cs</DependentUpon>
</Compile>
<Compile Include="LoginForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
<EmbeddedResource Include="GameForm.resx">
<DependentUpon>GameForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LobbyForm.resx">
<DependentUpon>LobbyForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BattleshipsLibrary\BattleshipsLibrary.csproj">
<Project>{9e01c4c2-44e3-4953-a2f7-277f639e8d5d}</Project>
<Name>BattleshipsLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Cover.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ShipCenter.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ShipEnd.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ShipSolo.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Water.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Pb1.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Pb2.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Pb3.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Pb4.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Pb5.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Fire.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeEditing/Localization/MoveToResource/LastResourceFile/@EntryValue">15B79A33-1392-489D-87E0-3272D64D292B/d:Resources/f:Messages.resx</s:String></wpf:ResourceDictionary>
58 changes: 58 additions & 0 deletions source/BattleshipsClient/Drawing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BattleshipsClient.Properties;
using BattleshipsLibrary;

namespace BattleshipsClient
{
//Třída pro kreslení na GridTile, zakresluje označení, zásah a minutí cíle
static class Drawing
{
private static Pen _pen = new Pen(Color.Red, 4);
private static int _offset = 5;

//Označení - "šipka"
public static void DrawSelected(GridTile gridTile, Graphics graphics)
{
Point[] points =
{
new Point(gridTile.Width / 2, _offset),
new Point(_offset, gridTile.Height - _offset),
new Point(gridTile.Width - _offset, gridTile.Height - _offset)
};

graphics.DrawClosedCurve(_pen, points, 0.3f, FillMode.Winding);
}

//Zásah - křížek
public static void DrawHit(GridTile gridTile, Graphics graphics)
{
Point upperLeft = new Point(0 + _offset, 0 + _offset);
Point upperRight = new Point(gridTile.Width - _offset, 0 + _offset);
Point lowerLeft = new Point(0 + _offset, gridTile.Height - _offset);
Point lowerRight = new Point(gridTile.Width - _offset, gridTile.Height - _offset);

graphics.DrawLine(_pen, upperLeft, lowerRight);
graphics.DrawLine(_pen, upperRight, lowerLeft);
}

//Minutí - kolečko
public static void DrawMiss(GridTile gridTile, Graphics graphics)
{
Rectangle r = new Rectangle(0 + _offset, 0 + _offset, gridTile.Width - _offset*2, gridTile.Height - _offset*2);

graphics.DrawEllipse(_pen, r);
}

//Oheň
public static void DrawFire(GridTile gridTile, Graphics graphics)
{
graphics.DrawImage(Resources.Fire, new Point(0,0));
}
}
}
Loading

0 comments on commit c9d45d3

Please sign in to comment.