Skip to content

Commit

Permalink
Build 0.12: All moves have no simple animation. Users can create acco…
Browse files Browse the repository at this point in the history
…unts if server was set up correctly.
  • Loading branch information
michi84o committed Oct 28, 2018
1 parent 1c693a0 commit 48883e1
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 25 deletions.
4 changes: 2 additions & 2 deletions AccessBattle/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0.0")]
[assembly: AssemblyFileVersion("0.12.0")]
4 changes: 2 additions & 2 deletions AccessBattleAI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0")]
[assembly: AssemblyFileVersion("0.12.0")]
4 changes: 2 additions & 2 deletions AccessBattleConsole/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0")]
[assembly: AssemblyFileVersion("0.12.0")]
4 changes: 2 additions & 2 deletions AccessBattleMySql/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0")]
[assembly: AssemblyFileVersion("0.12.0")]
4 changes: 2 additions & 2 deletions AccessBattleServer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0")]
[assembly: AssemblyFileVersion("0.12.0")]
14 changes: 14 additions & 0 deletions AccessBattleWpf/AccessBattleWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<Compile Include="View\DeploymentView.xaml.cs">
<DependentUpon>DeploymentView.xaml</DependentUpon>
</Compile>
<Compile Include="View\Error404Field.xaml.cs">
<DependentUpon>Error404Field.xaml</DependentUpon>
</Compile>
<Compile Include="View\ErrorNotification.xaml.cs">
<DependentUpon>ErrorNotification.xaml</DependentUpon>
</Compile>
Expand All @@ -104,6 +107,9 @@
<Compile Include="View\SwitchCards404Menu.xaml.cs">
<DependentUpon>SwitchCards404Menu.xaml</DependentUpon>
</Compile>
<Compile Include="View\VirusCheckField.xaml.cs">
<DependentUpon>VirusCheckField.xaml</DependentUpon>
</Compile>
<Compile Include="View\WaitForAcceptMenu.xaml.cs">
<DependentUpon>WaitForAcceptMenu.xaml</DependentUpon>
</Compile>
Expand All @@ -129,6 +135,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\Error404Field.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\ErrorNotification.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -183,6 +193,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\VirusCheckField.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\WaitForAcceptMenu.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
4 changes: 2 additions & 2 deletions AccessBattleWpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.0")]
[assembly: AssemblyFileVersion("0.11.0")]
[assembly: AssemblyVersion("0.12.0")]
[assembly: AssemblyFileVersion("0.12.0")]
38 changes: 38 additions & 0 deletions AccessBattleWpf/View/Error404Field.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<UserControl x:Class="AccessBattle.Wpf.View.Error404Field"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AccessBattle.Wpf.View"
Width="48" Height="48" FontFamily="../ExternalResources/#Silkscreen">
<Border CornerRadius="2" BorderBrush="Yellow" BorderThickness="2" Background="White">
<Grid Margin="1">
<Grid.RowDefinitions>
<RowDefinition Height=".8*"/>
<RowDefinition Height=".1*"/>
<RowDefinition Height=".3*"/>
</Grid.RowDefinitions>
<Viewbox Margin="2" Grid.Row="0" Grid.RowSpan="2" >
<Path
Margin="1"
Fill="Black"
Stroke="Black" StrokeThickness="1"
Data="{StaticResource NotFound404Path}"/>
</Viewbox>
<Viewbox Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Top">
<TextBlock Margin="0"
FontSize="10" Foreground="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text=" 404 " TextAlignment="Center" />
</Viewbox>
<Viewbox Grid.Row="2" VerticalAlignment="Bottom">
<TextBlock Margin="1,0,1,0"
FontSize="10" Foreground="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Not Found" TextAlignment="Center" />
</Viewbox>
</Grid>
</Border>
</UserControl>
28 changes: 28 additions & 0 deletions AccessBattleWpf/View/Error404Field.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 AccessBattle.Wpf.View
{
/// <summary>
/// Interaction logic for Error404Field.xaml
/// </summary>
public partial class Error404Field : UserControl
{
public Error404Field()
{
InitializeComponent();
}
}
}
85 changes: 83 additions & 2 deletions AccessBattleWpf/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private void Game_PropertyChanged(object sender, System.ComponentModel.PropertyC
var split = move.Split(new[] { ',' });
if (split.Length != 3) return;

Game.ReplaceLettersWithNumbers(ref split);

uint x1, y1, enabled;
if (!uint.TryParse(split[0], out x1) ||
!uint.TryParse(split[1], out y1) ||
Expand All @@ -167,19 +169,98 @@ private void Game_PropertyChanged(object sender, System.ComponentModel.PropertyC
(int)x1, (int)y1, enabled == 1,
boost ? BoardFieldVisualState.LineBoost : BoardFieldVisualState.Firewall);
}
else if (move.StartsWith("vc", StringComparison.InvariantCultureIgnoreCase))
{
move = move.Substring(3).Trim();
var split = move.Split(new[] { ',' });
if (split.Length != 2) return;

Game.ReplaceLettersWithNumbers(ref split);

uint x1, y1;
if (!uint.TryParse(split[0], out x1) ||
!uint.TryParse(split[1], out y1))
return;

// Convert to zero based index:
--x1; --y1;

if (x1 > 7 || y1 > 7)
return;

// Invert Y
if (ViewModel.IsPlayerHost)
{
y1 = 7 - y1;
}
else // Invert X
{
x1 = 7 - x1;
}

AnimatePlacement((int)x1, (int)y1, true, BoardFieldVisualState.VirusCheck);

}
else if (move.StartsWith("er", StringComparison.InvariantCultureIgnoreCase))
{
move = move.Substring(3).Trim();
var split = move.Split(new[] { ',' });
if (split.Length != 5) return; // Last field is '?'
Game.ReplaceLettersWithNumbers(ref split);
int x1, x2, y1, y2;
if (!int.TryParse(split[0], out x1) ||
!int.TryParse(split[1], out y1) ||
!int.TryParse(split[2], out x2) ||
!int.TryParse(split[3], out y2))
return;
// Convert to zero based index:
--x1; --x2; --y1; --y2;

// Invert Y
if (ViewModel.IsPlayerHost)
{
y1 = 7 - y1;

if (y2 == 10)
y2 = 8;
else
y2 = 7 - y2;
}
else // Invert X
{
x1 = 7 - x1;
x2 = 7 - x2;

if (y2 == 10) y2 = 8;
}

AnimateMovement(x1, y1, x2, y2);
AnimateMovement(x2, y2, x1, y1);
AnimatePlacement(x1, y1, false, BoardFieldVisualState.Error404);
AnimatePlacement(x2, y2, false, BoardFieldVisualState.Error404);

}

}

void AnimatePlacement(int x, int y, bool direction, BoardFieldVisualState card)
{
if (card != BoardFieldVisualState.LineBoost && card != BoardFieldVisualState.Firewall) return;
if (card != BoardFieldVisualState.LineBoost &&
card != BoardFieldVisualState.Firewall &&
card != BoardFieldVisualState.VirusCheck &&
card != BoardFieldVisualState.Error404) return;

Application.Current.Dispatcher.BeginInvoke((Action)(async () =>
{
UserControl view;
if (card == BoardFieldVisualState.Firewall)
view = new FirewallField();
else view = new BoostField();
else if (card == BoardFieldVisualState.LineBoost)
view = new BoostField();
else if (card == BoardFieldVisualState.Error404)
view = new Error404Field();
else
view = new VirusCheckField();
Grid.SetColumnSpan(view, 12);
Expand Down
35 changes: 24 additions & 11 deletions AccessBattleWpf/View/NetworkGameMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AccessBattle.Wpf.ViewModel;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand All @@ -14,27 +15,39 @@ public NetworkGameMenu()
{
InitializeComponent();

DataContextChanged += NetworkGameMenu_DataContextChanged;

NetworkGameMenu_DataContextChanged(null, new DependencyPropertyChangedEventArgs());
}

private void NetworkGameMenu_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var ctx = DataContext as NetworkGameMenuViewModel;
if (ctx == null) return;
ctx.PropertyChanged += Ctx_PropertyChanged;

Ctx_PropertyChanged(null, new System.ComponentModel.PropertyChangedEventArgs(nameof(NetworkGameMenuViewModel.AllowsRegistration)));
}

private void Ctx_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(NetworkGameMenuViewModel.AllowsRegistration))
Application.Current.Dispatcher.BeginInvoke((Action)(() =>
{
var ctx = sender as NetworkGameMenuViewModel;
if (ctx?.AllowsRegistration != true)
{
CreateAccountButton.Visibility = Visibility.Collapsed;
Grid.SetRowSpan(LoginButton, 2);
}
else
if (e.PropertyName == nameof(NetworkGameMenuViewModel.AllowsRegistration))
{
CreateAccountButton.Visibility = Visibility.Visible;
Grid.SetRowSpan(LoginButton, 1);
var ctx = sender as NetworkGameMenuViewModel;
if (ctx?.AllowsRegistration != true)
{
CreateAccountButton.Visibility = Visibility.Collapsed;
Grid.SetRowSpan(LoginButton, 2);
}
else
{
CreateAccountButton.Visibility = Visibility.Visible;
Grid.SetRowSpan(LoginButton, 1);
}
}
}
}));
}

void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
Expand Down
39 changes: 39 additions & 0 deletions AccessBattleWpf/View/VirusCheckField.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<UserControl x:Class="AccessBattle.Wpf.View.VirusCheckField"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AccessBattle.Wpf.View"
Width="48" Height="48" FontFamily="../ExternalResources/#Silkscreen">
<Border CornerRadius="2" BorderBrush="Yellow" BorderThickness="2" Background="White">
<Grid Margin="1">
<Grid.RowDefinitions>
<RowDefinition Height=".8*"/>
<RowDefinition Height=".1*"/>
<RowDefinition Height=".3*"/>
</Grid.RowDefinitions>
<Viewbox Margin="2" Grid.Row="0" Grid.RowSpan="2">
<Path
Margin="1"
Fill="Black"
Stroke="Black" StrokeThickness="1"
Data="{StaticResource VirusCheckPath}"/>
</Viewbox>
<Viewbox Grid.Row="1" VerticalAlignment="Top" Grid.RowSpan="2">
<TextBlock Margin="0"
FontSize="10" Foreground="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text=" Virus " />
</Viewbox>
<Viewbox Grid.Row="2" VerticalAlignment="Bottom">
<TextBlock Margin="0"
FontSize="10" Foreground="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text=" Check " />
</Viewbox>
</Grid>

</Border>
</UserControl>
28 changes: 28 additions & 0 deletions AccessBattleWpf/View/VirusCheckField.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 AccessBattle.Wpf.View
{
/// <summary>
/// Interaction logic for VirusCheckField.xaml
/// </summary>
public partial class VirusCheckField : UserControl
{
public VirusCheckField()
{
InitializeComponent();
}
}
}

0 comments on commit 48883e1

Please sign in to comment.