Refactored and added base projects & code
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# IDE0011: Add braces
|
||||
csharp_prefer_braces = when_multiline
|
||||
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="Pokemon_Drinking_Game.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Pokemon_Drinking_Game"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<BitmapImage x:Key="GameBoardImage" UriSource="../pokemon_v3.png" />
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Pokemon_Drinking_Game
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
@@ -0,0 +1,147 @@
|
||||
<Window x:Class="Pokemon_Drinking_Game.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Pokemon_Drinking_Game"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800" Background="Black">
|
||||
<Grid>
|
||||
<Grid x:Name="GameGrid" Background="Black" Visibility="Visible">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image x:Name="gameBoard" Source="/pokemon_v3.png" />
|
||||
<Grid x:Name="boardLayout" Margin="1,1,1,1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- First moves -->
|
||||
<Button x:Name="palletTownButton" Content="" Grid.Row="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="rattataButton" Content="" Grid.Row="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="pidgeyButton" Content="" Grid.Row="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="caterpieButton" Content="" Grid.Row="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="pikachuButton" Content="" Grid.Row="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="beedrilButton" Content="" Grid.Row="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="pewterButton" Content="" Grid.Row="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="nidoranButton" Content="" Grid.Row="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="zubatButton" Content="" Grid.Row="0" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- Second Moves -->
|
||||
<Button x:Name="clefairyButton" Content="" Grid.Row="0" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="jigglypuffButton" Content="" Grid.Row="0" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="abraButton" Content="" Grid.Row="0" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="garyButton" Content="" Grid.Row="0" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="ceruleanButton" Content="" Grid.Row="0" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="slowpokeButton" Content="" Grid.Row="0" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="bellsproutButton" Content="" Grid.Row="0" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="meowthButton" Content="" Grid.Row="0" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- Third Moves -->
|
||||
<Button x:Name="diglettButton" Content="" Grid.Row="1" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="ssanneButton" Content="" Grid.Row="2" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="vermillionButton" Content="" Grid.Row="3" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="bicycleButton" Content="" Grid.Row="4" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="magikarpButton" Content="" Grid.Row="5" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="sandshrewButton" Content="" Grid.Row="6" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="pokemontowerButton" Content="" Grid.Row="7" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="channelerButton" Content="" Grid.Row="8" Grid.Column="8" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- fourth Moves -->
|
||||
<Button x:Name="haunterButton" Content="" Grid.Row="8" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="cuboneButton" Content="" Grid.Row="8" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="ghostButton" Content="" Grid.Row="8" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="abra2Button" Content="" Grid.Row="8" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="snorlaxButton" Content="" Grid.Row="8" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="gary2Button" Content="" Grid.Row="8" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="eeveeButton" Content="" Grid.Row="8" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- fifth Moves -->
|
||||
<Button x:Name="celadonButton" Content="" Grid.Row="7" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="psyduckButton" Content="" Grid.Row="6" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="evolutionButton" Content="" Grid.Row="5" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="porygonButton" Content="" Grid.Row="4" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="silphButton" Content="" Grid.Row="3" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="scientistButton" Content="" Grid.Row="2" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="laprasButton" Content="" Grid.Row="1" Grid.Column="1" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- sixth Moves -->
|
||||
<Button x:Name="rocketButton" Content="" Grid.Row="1" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="giovanniButton" Content="" Grid.Row="1" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="rarecandyButton" Content="" Grid.Row="1" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="gary3Button" Content="" Grid.Row="1" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="saffronButton" Content="" Grid.Row="1" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="hitmonsButton" Content="" Grid.Row="1" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- seventh Moves -->
|
||||
<Button x:Name="krabbyButton" Content="" Grid.Row="2" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="dittoButton" Content="" Grid.Row="3" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="doduoButton" Content="" Grid.Row="4" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="safariButton" Content="" Grid.Row="5" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="dratiniButton" Content="" Grid.Row="6" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="taurosButton" Content="" Grid.Row="7" Grid.Column="7" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- eigth Moves -->
|
||||
<Button x:Name="chanseyButton" Content="" Grid.Row="7" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="fuchsiaButton" Content="" Grid.Row="7" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="electrodeButton" Content="" Grid.Row="7" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="electabuzzButton" Content="" Grid.Row="7" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="poliwagButton" Content="" Grid.Row="7" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- ninth Moves -->
|
||||
<Button x:Name="seakingButton" Content="" Grid.Row="6" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="missingnoButton" Content="" Grid.Row="5" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="cinnabarButton" Content="" Grid.Row="4" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="koffingButton" Content="" Grid.Row="3" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="fossilButton" Content="" Grid.Row="2" Grid.Column="2" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- tenth Moves -->
|
||||
<Button x:Name="pokeballButton" Content="" Grid.Row="2" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="persianButton" Content="" Grid.Row="2" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="viridianButton" Content="" Grid.Row="2" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="fearowButton" Content="" Grid.Row="2" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- tenth Moves -->
|
||||
<Button x:Name="gravellerButton" Content="" Grid.Row="3" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="gyradosButton" Content="" Grid.Row="4" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="dragoniteButton" Content="" Grid.Row="5" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="legendbirdButton" Content="" Grid.Row="6" Grid.Column="6" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<!-- 11th Moves -->
|
||||
<Button x:Name="elitefourButton" Content="" Grid.Row="6" Grid.Column="5" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="championButton" Content="" Grid.Row="6" Grid.Column="4" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Button x:Name="masterButton" Content="" Grid.Row="6" Grid.Column="3" Background="#01000000" MouseEnter="buttons_MouseEnter" MouseLeave="buttons_MouseLeave" BorderBrush="{x:Null}"/>
|
||||
<Image x:Name="zoomPieceImage" Grid.ColumnSpan="3" Grid.Column="3" Grid.RowSpan="3" Grid.Row="3" Source="/pokemon_v3.png" />
|
||||
|
||||
<!-- Holders -->
|
||||
<StackPanel Grid.Row="8"/>
|
||||
|
||||
|
||||
</Grid>
|
||||
<StackPanel x:Name="PlayerList" Grid.Column="1"/>
|
||||
|
||||
</Grid>
|
||||
<Grid x:Name="ConnectionGrid" Background="Black" Visibility="Visible" d:IsHidden="True">
|
||||
<StackPanel Margin="0,20,0,10" HorizontalAlignment="Center">
|
||||
<TextBlock Text="Connection:" TextWrapping="Wrap" Foreground="White" HorizontalAlignment="Center" Margin="0,0,0,10" FontSize="22"/>
|
||||
<TextBlock Text="Server Address:" TextWrapping="Wrap" Foreground="White" HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="AddressTextBox" Text="pdgserver.kauripeak.co.nz" TextWrapping="Wrap" MinWidth="250" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="Server Port:" TextWrapping="Wrap" Foreground="White" HorizontalAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="PortTextBox" Text="13000" TextWrapping="Wrap" MinWidth="50" HorizontalAlignment="Center" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="Player Name:" TextWrapping="Wrap" Foreground="White" HorizontalAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBox x:Name="PlayerNameTextBox" Text="Player" TextWrapping="Wrap" MinWidth="250" HorizontalAlignment="Center" Margin="0,5,0,0"/>
|
||||
<Button x:Name="ConnectButton" Content="Connect" HorizontalAlignment="Center" Margin="0,20,0,0" Click="ConnectButton_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Pokemon_Drinking_Game
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
BitmapImage subImage;
|
||||
List<Player> players;
|
||||
int ourPlayerIndex;
|
||||
int currentTurn;
|
||||
Timer updateTimer;
|
||||
TcpClient client;
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Load the sub image just once
|
||||
loadImage();
|
||||
players = new List<Player>();
|
||||
//TcpClient client = new TcpClient("pdgserver.kauripeak.co.nz", 13000);
|
||||
|
||||
}
|
||||
|
||||
void loadImage()
|
||||
{
|
||||
subImage = new(new Uri("pack://application:,,,/pokemon_v3.png"));
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
private void buttons_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Replace center image
|
||||
|
||||
zoomPieceImage.Source = retrieveSubImage(subImage, (Button)sender);
|
||||
zoomPieceImage.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void buttons_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Hide center image
|
||||
//zoomPieceImage.Source = new BitmapImage();
|
||||
zoomPieceImage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
CroppedBitmap retrieveSubImage(BitmapImage source, Button button)
|
||||
{
|
||||
// Get various element heights & widths
|
||||
int imageWidth = source.PixelWidth;
|
||||
int imageHight = source.PixelHeight;
|
||||
|
||||
int pixPerTile = imageWidth / 9 -1;
|
||||
|
||||
double parentHeight = ((Grid)button.Parent).ActualHeight;
|
||||
double parentWidth = ((Grid)button.Parent).ActualWidth;
|
||||
|
||||
|
||||
int row = -1;
|
||||
int col = -1;
|
||||
|
||||
// Hard coding cause its a bitch
|
||||
|
||||
if (button == palletTownButton)
|
||||
{
|
||||
col = 0;
|
||||
row = 8;
|
||||
}
|
||||
else if (button == rattataButton) { col = 0; row = 7; }
|
||||
else if (button == pidgeyButton) { col = 0; row = 6; }
|
||||
else if (button == caterpieButton) { col = 0; row = 5; }
|
||||
else if (button == pikachuButton) { col = 0; row = 4; }
|
||||
else if (button == beedrilButton) { col = 0; row = 3; }
|
||||
else if (button == pewterButton) { col = 0; row = 2; }
|
||||
else if (button == nidoranButton) { col = 0; row = 1; }
|
||||
else if (button == zubatButton) { col = 0; row = 0; }
|
||||
//
|
||||
else if (button == clefairyButton) { col = 1; row = 0; }
|
||||
else if (button == jigglypuffButton) { col = 2; row = 0; }
|
||||
else if (button == abraButton) { col = 3; row = 0; }
|
||||
else if (button == garyButton) { col = 4; row = 0; }
|
||||
else if (button == ceruleanButton) { col = 5; row = 0; }
|
||||
else if (button == slowpokeButton) { col = 6; row = 0; }
|
||||
else if (button == bellsproutButton) { col = 7; row = 0; }
|
||||
else if (button == meowthButton) { col = 8; row = 0; }
|
||||
//
|
||||
else if (button == diglettButton) { col = 8; row = 1; }
|
||||
else if (button == ssanneButton) { col = 8; row = 2; }
|
||||
else if (button == vermillionButton) { col = 8; row = 3; }
|
||||
else if (button == bicycleButton) { col = 8; row = 4; }
|
||||
else if (button == magikarpButton) { col = 8; row = 5; }
|
||||
else if (button == sandshrewButton) { col = 8; row = 6; }
|
||||
else if (button == pokemontowerButton) { col = 8; row = 7; }
|
||||
else if (button == channelerButton) { col = 8; row = 8; }
|
||||
//
|
||||
else if (button == haunterButton) { col = 7; row = 8; }
|
||||
else if (button == cuboneButton) { col = 6; row = 8; }
|
||||
else if (button == ghostButton) { col = 5; row = 8; }
|
||||
else if (button == abra2Button) { col = 4; row = 8; }
|
||||
else if (button == snorlaxButton) { col = 3; row = 8; }
|
||||
else if (button == gary2Button) { col = 2; row = 8; }
|
||||
else if (button == eeveeButton) { col = 1; row = 8; }
|
||||
//
|
||||
else if (button == celadonButton) { col = 1; row = 7; }
|
||||
else if (button == psyduckButton) { col = 1; row = 6; }
|
||||
else if (button == evolutionButton) { col = 1; row = 5; }
|
||||
else if (button == porygonButton) { col = 1; row = 4; }
|
||||
else if (button == silphButton) { col = 1; row = 3; }
|
||||
else if (button == scientistButton) { col = 1; row = 2; }
|
||||
else if (button == laprasButton) { col = 1; row = 1; }
|
||||
//
|
||||
else if (button == rocketButton) { col = 2; row = 1; }
|
||||
else if (button == giovanniButton) { col = 3; row = 1; }
|
||||
else if (button == rarecandyButton) { col = 4; row = 1; }
|
||||
else if (button == gary3Button) { col = 5; row = 1; }
|
||||
else if (button == saffronButton) { col = 6; row = 1; }
|
||||
else if (button == hitmonsButton) { col = 7; row = 1; }
|
||||
//
|
||||
else if (button == krabbyButton) { col = 7; row = 2; }
|
||||
else if (button == dittoButton) { col = 7; row = 3; }
|
||||
else if (button == doduoButton) { col = 7; row = 4; }
|
||||
else if (button == safariButton) { col = 7; row = 5; }
|
||||
else if (button == dratiniButton) { col = 7; row = 6; }
|
||||
else if (button == taurosButton) { col = 7; row = 7; }
|
||||
//
|
||||
else if (button == chanseyButton) { col = 6; row = 7; }
|
||||
else if (button == fuchsiaButton) { col = 5; row = 7; }
|
||||
else if (button == electrodeButton) { col = 4; row = 7; }
|
||||
else if (button == electabuzzButton) { col = 3; row = 7; }
|
||||
else if (button == poliwagButton) { col = 2; row = 7; }
|
||||
//
|
||||
else if (button == seakingButton) { col = 2; row = 6; }
|
||||
else if (button == missingnoButton) { col = 2; row = 5; }
|
||||
else if (button == cinnabarButton) { col = 2; row = 4; }
|
||||
else if (button == koffingButton) { col = 2; row = 3; }
|
||||
else if (button == fossilButton) { col = 2; row = 2; }
|
||||
//
|
||||
else if (button == pokeballButton) { col = 3; row = 2; }
|
||||
else if (button == persianButton) { col = 4; row = 2; }
|
||||
else if (button == viridianButton) { col = 5; row = 2; }
|
||||
else if (button == fearowButton) { col = 6; row = 2; }
|
||||
//
|
||||
else if (button == gravellerButton) { col = 6; row = 3; }
|
||||
else if (button == gyradosButton) { col = 6; row = 4; }
|
||||
else if (button == dragoniteButton) { col = 6; row = 5; }
|
||||
else if (button == legendbirdButton) { col = 6; row = 6; }
|
||||
//
|
||||
else if (button == elitefourButton) { col = 5; row = 6; }
|
||||
else if (button == championButton) { col = 4; row = 6; }
|
||||
else if (button == masterButton) { col = 3; row = 6; }
|
||||
|
||||
|
||||
|
||||
Int32Rect pixelRect = new Int32Rect(pixPerTile * col, pixPerTile * row , pixPerTile, pixPerTile);
|
||||
CroppedBitmap cb = new CroppedBitmap(source, pixelRect);
|
||||
return cb;
|
||||
}
|
||||
|
||||
|
||||
byte[] overflowBuffer;
|
||||
/// <summary>
|
||||
/// Server logic
|
||||
/// Called periodically (e.g. 1/10 of a second), retrieves new data from the buffer, and
|
||||
/// sends out any updates that have occured.
|
||||
///
|
||||
/// Data packets are 0xFF terminated (new command is the proceeding byte)
|
||||
/// Data terminations are 0xFE (next data type is the proceeding byte; does not apply to deterministic primative sizes)
|
||||
/// strings are expected to be sent in UTF-8 format
|
||||
///
|
||||
/// As this is all in TCP, data is guaranteed to be in the correct order
|
||||
/// </summary>
|
||||
void ClientUpdate()
|
||||
{
|
||||
// ***************************
|
||||
// **** Ensure connected ***
|
||||
// ***************************
|
||||
if (!client.Connected)
|
||||
{
|
||||
|
||||
}
|
||||
// ***************************
|
||||
// ****** Recieve Data *****
|
||||
// ***************************
|
||||
if (client.Available > 0)
|
||||
{
|
||||
int available = client.Available;
|
||||
// Internal byte array to store all awaiting bytes
|
||||
byte[] buffer = new byte[available];
|
||||
// Get the underlying networkstream, to read and write
|
||||
NetworkStream connectionStream = client.GetStream();
|
||||
connectionStream.Read(buffer, 0, available);
|
||||
|
||||
int pos = 0;
|
||||
|
||||
while (pos < available)
|
||||
{
|
||||
int command = buffer[pos] >> 4; // Get the four command bits
|
||||
ourPlayerIndex = buffer[pos++] & 0xF; // Ensure we are the correct indexed player
|
||||
|
||||
switch (command) // post-increment past the command byte
|
||||
{
|
||||
case 0: // Server queries a heartbeat response
|
||||
connectionStream.Write(new byte[] { (byte)ourPlayerIndex, 1, 0xFF });
|
||||
break;
|
||||
case 1: // Server has a board (game) update
|
||||
while (buffer[pos] != 0xFF)
|
||||
{
|
||||
// First four bits, after the command is the number of players
|
||||
int playerCount = buffer[pos] >> 4;
|
||||
// Next four are the number of players
|
||||
currentTurn = buffer[pos++] | 0xF;
|
||||
// Next
|
||||
|
||||
|
||||
// If there is a different number of players, create a new list of players
|
||||
if (players.Count != playerCount)
|
||||
{
|
||||
players = new List<Player>(playerCount);
|
||||
}
|
||||
// Next bit is a flag, denoting if the current player is a
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
UpdateUI();
|
||||
}
|
||||
// ***************************
|
||||
// ******* Send Data *******
|
||||
// ***************************
|
||||
|
||||
}
|
||||
|
||||
void UpdateUI()
|
||||
{
|
||||
Brush labelBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
|
||||
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
{
|
||||
PlayerList.Children.Clear();
|
||||
// do UI updates here
|
||||
foreach (var item in players)
|
||||
{
|
||||
Label playerLabel = new Label()
|
||||
{
|
||||
Content = item.name,
|
||||
Foreground = labelBrush
|
||||
};
|
||||
PlayerList.Children.Add(playerLabel);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void ConnectButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Do connection using props
|
||||
if (client != null)
|
||||
{
|
||||
client.Close();
|
||||
}
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
client = new TcpClient(AddressTextBox.Text, Convert.ToInt32(PortTextBox.Text));
|
||||
success = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
ConnectionGrid.Visibility = Visibility.Collapsed;
|
||||
GameGrid.Visibility = Visibility.Visible;
|
||||
|
||||
ourPlayerIndex = 0;
|
||||
currentTurn = 0;
|
||||
|
||||
List<byte> sendBytes = new();
|
||||
sendBytes.Add(1 << 4);
|
||||
sendBytes.AddRange(Encoding.UTF8.GetBytes(PlayerNameTextBox.Text));
|
||||
sendBytes.Add(0xFF);
|
||||
// Send through the player name
|
||||
client.GetStream().Write(sendBytes.ToArray());
|
||||
// Add listener for data
|
||||
updateTimer = new Timer((t) =>
|
||||
{
|
||||
ClientUpdate();
|
||||
});
|
||||
updateTimer.Change(100, 33);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct Player
|
||||
{
|
||||
public string name;
|
||||
public int row;
|
||||
public int column;
|
||||
public long lastTime;
|
||||
|
||||
public Player(string name, int row, int column)
|
||||
{
|
||||
this.name = name;
|
||||
this.row = row;
|
||||
this.column = column;
|
||||
this.lastTime = DateTime.Now.Ticks;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return name + " (" + column + ", " + row + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<RootNamespace>Pokemon_Drinking_Game</RootNamespace>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="pokemon_v3.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="pokemon_v3.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31515.178
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pokemon Drinking Game", "Pokemon Drinking Game.csproj", "{3BF04BFD-307C-4878-B420-47DFFAD97BE0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDGServer", "..\PDGServer\PDGServer.csproj", "{FD6A1623-2695-4353-8B4E-7115BDCB34FD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDGServer_WPF", "..\PDGServer_WPF\PDGServer_WPF.csproj", "{78CE20FA-E26B-4C12-9498-6EFB058586E5}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F4C5002D-A70D-4B97-8BDD-F02008F4B79B}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3BF04BFD-307C-4878-B420-47DFFAD97BE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BF04BFD-307C-4878-B420-47DFFAD97BE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BF04BFD-307C-4878-B420-47DFFAD97BE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BF04BFD-307C-4878-B420-47DFFAD97BE0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FD6A1623-2695-4353-8B4E-7115BDCB34FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FD6A1623-2695-4353-8B4E-7115BDCB34FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FD6A1623-2695-4353-8B4E-7115BDCB34FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FD6A1623-2695-4353-8B4E-7115BDCB34FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{78CE20FA-E26B-4C12-9498-6EFB058586E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{78CE20FA-E26B-4C12-9498-6EFB058586E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{78CE20FA-E26B-4C12-9498-6EFB058586E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{78CE20FA-E26B-4C12-9498-6EFB058586E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {35DA9C3E-6A70-4E39-85A6-1843C79A07D4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user