-
Notifications
You must be signed in to change notification settings - Fork 7
/
MainWindow.xaml
86 lines (80 loc) · 4.08 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<Window xmlns="https://github.com/avaloniaui"
xmlns:local="clr-namespace:Avalonia.BattleCity;assembly=Avalonia.BattleCity"
xmlns:model="clr-namespace:Avalonia.BattleCity.Model;assembly=Avalonia.BattleCity"
xmlns:tran="clr-namespace:Avalonia.Animation;assembly=Avalonia.Animation"
xmlns:infrastructure="clr-namespace:Avalonia.BattleCity.Infrastructure;assembly=Avalonia.BattleCity"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Avalonia.BattleCity" Width="640" Height="480" Design.DataContext="{x:Static model:GameField.DesignInstance}" >
<Window.Styles >
<Style Selector="ItemsControl > ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding Location.X}"/>
<Setter Property="Canvas.Top" Value="{Binding Location.Y}"/>
<Setter Property="ZIndex" Value="{Binding Converter={x:Static infrastructure:ZIndexConverter.Instance }}" />
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0:0.5"/>
</Transitions>
</Setter>
</Style>
<Style Selector="ItemsControl > ContentPresenter.test:pointerover">
<Setter Property="Opacity" Value="0.5"/>
</Style>
</Window.Styles>
<ItemsControl
Items="{Binding GameObjects}"
Width="{Binding Width, Converter={x:Static infrastructure:CellToScreenConverter.Instance}, Mode=OneWay}"
Height="{Binding Height, Converter={x:Static infrastructure:CellToScreenConverter.Instance}, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.DataTemplates>
<DataTemplate DataType="{x:Type model:TerrainTile}">
<Image Width="32" Height="32"
Source="{Binding Type, Converter={x:Static infrastructure:TerrainTileConverter.Instance}}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type model:Player}">
<Border ClipToBounds="False">
<Border.Styles>
<Style Selector="Border">
<Style.Animations>
<Animation Duration="0:0:1"
RepeatCount="Loop"
PlaybackDirection="Alternate"
Easing="SineEaseInOut"
FillMode="None">
<KeyFrame Cue="70%">
<Setter Property="ScaleTransform.ScaleX" Value="2"/>
<Setter Property="ScaleTransform.ScaleY" Value="2"/>
</KeyFrame>
<KeyFrame Cue="90%">
<Setter Property="ScaleTransform.ScaleX" Value="2.5"/>
<Setter Property="ScaleTransform.ScaleY" Value="2.5"/>
</KeyFrame>
</Animation>
<Animation Duration="0:0:2"
RepeatCount="Loop"
PlaybackDirection="Alternate"
FillMode="None">
<KeyFrame Cue="30%">
<Setter Property="RotateTransform.Angle" Value="-45"/>
</KeyFrame>
<KeyFrame Cue="90%">
<Setter Property="RotateTransform.Angle" Value="45"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</Border.Styles>
<Image Width="32" Height="32"
Source="resm:Avalonia.BattleCity.Resources.Player.png"
RenderTransform="{Binding Facing, Converter={x:Static infrastructure:DirectionToMatrixConverter.Instance}}"/>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type model:Tank}">
<Image Width="32" Height="32" Source="resm:Avalonia.BattleCity.Resources.Tank.png" RenderTransform="{Binding Facing, Converter={x:Static infrastructure:DirectionToMatrixConverter.Instance}}"/>
</DataTemplate>
</ItemsControl.DataTemplates>
</ItemsControl>
</Window>