Click here to Skip to main content
15,885,366 members
Articles / Desktop Programming / WPF

Game Attack Combos : WPF Hybrid Smart Client for Combo Calculations

Rate me:
Please Sign up or sign in to vote.
4.96/5 (35 votes)
23 May 2009CPOL37 min read 84.2K   3.2K   50  
A WPF hybrid smart client for calculating attack combos in the Prince of Persia game.
<ResourceDictionary 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	
	<LinearGradientBrush x:Key="ButtonShineBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientStop Color="#80FFFFFF" Offset="0"/>
		<GradientStop Color="Transparent" Offset="1"/>
	</LinearGradientBrush>
	<SolidColorBrush x:Key="CloseButtonBorderBrush" Color="#B90000" />
	<SolidColorBrush x:Key="CloseButtonBackgroundBrush" Color="#B90000" />
	<SolidColorBrush x:Key="CloseButtonOverBackgroundBrush" Color="#FF0F0F" />
	
	<LinearGradientBrush x:Key="TitlebarBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientStop Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}" Offset="0.5" />
		<GradientStop Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" Offset="1" />
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="TitlebarShadowBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientStop Color="{DynamicResource {x:Static SystemColors.ControlColorKey}}" Offset="0" />
		<GradientStop Color="{DynamicResource {x:Static SystemColors.ControlDarkDarkColorKey}}" Offset="1" />
	</LinearGradientBrush>
	
	
	<!-- Window styles -->
	<Style x:Key="TitlebarMinimizeButton" TargetType="{x:Type Button}">
		<Setter Property="Width" Value="16" />
		<Setter Property="Height" Value="16" />
		<Setter Property="Focusable" Value="False" />
		<Setter Property="IsTabStop" Value="False" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Grid>
						<Rectangle Name="RectBackground" 
								   RadiusX="3" RadiusY="3" 
								   Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
								   Stroke="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 
								   StrokeThickness="1" />
						<Rectangle x:Name="RectShine" 
								   RadiusX="1" RadiusY="1" 
								   Fill="{StaticResource ButtonShineBrush}"
								   Stroke="Transparent"
								   Margin="1,1,1,0"
								   RenderTransformOrigin="0.5,0.5" />
						<Line Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
							  X1="4" Y1="11" X2="12" Y2="11" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter TargetName="RectBackground" Property="Fill" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="True">
							<Setter TargetName="RectBackground" Property="Fill" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
							<Setter TargetName="RectShine" Property="RenderTransform">
								<Setter.Value>
									<RotateTransform Angle="180" CenterX="0" CenterY="0" />
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="TitlebarCloseButton" TargetType="{x:Type Button}">
		<Setter Property="Width" Value="16" />
		<Setter Property="Height" Value="16" />
		<Setter Property="Margin" Value="3,0,0,0" />
		<Setter Property="Focusable" Value="False" />
		<Setter Property="IsTabStop" Value="False" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Grid>
						<Rectangle Name="RectBackground" 
								   RadiusX="3" RadiusY="3" 
								   Fill="{StaticResource CloseButtonBackgroundBrush}"
								   Stroke="{StaticResource CloseButtonBorderBrush}" 
								   StrokeThickness="1" />
						<Rectangle x:Name="RectShine" 
								   RadiusX="1" RadiusY="1" 
								   Fill="{StaticResource ButtonShineBrush}"
								   Stroke="Transparent"
								   Margin="1,1,1,0"
								   RenderTransformOrigin="0.5,0.5" />
						<Line Stroke="#FFFFFF" StrokeThickness="2" X1="4" Y1="4" X2="12" Y2="12" />
						<Line Stroke="#FFFFFF" StrokeThickness="2" X1="4" Y1="12" X2="12" Y2="4" />
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter TargetName="RectBackground" Property="Fill" Value="{StaticResource CloseButtonOverBackgroundBrush}"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="True">
							<Setter TargetName="RectBackground" Property="Fill" Value="{StaticResource CloseButtonBackgroundBrush}"/>
							<Setter TargetName="RectShine" Property="RenderTransform">
								<Setter.Value>
									<RotateTransform Angle="180" CenterX="0" CenterY="0" />
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="Window" TargetType="{x:Type Window}">
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
		<Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
		<Setter Property="BorderThickness" Value="2" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Window}">
					<Border Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}">
						<DockPanel>
							<Border Name="PART_Titlebar" 
									DockPanel.Dock="Top" 
									Height="Auto" 
									Background="{StaticResource TitlebarBackgroundBrush}">
								<Grid Margin="2,1">
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="Auto" />
										<ColumnDefinition Width="*" />
										<ColumnDefinition Width="Auto" />
									</Grid.ColumnDefinitions>
									<Image Grid.Column="0" 
										   Height="16" Margin="0,0,7,0" 
										   VerticalAlignment="Center"
										   Source="{TemplateBinding Icon}" />
									<TextBlock Grid.Column="1" 
											   Text="{TemplateBinding Title}" 
											   Foreground="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" 
											   VerticalAlignment="Center" 
											   FontWeight="Bold" />
									<StackPanel Grid.Column="2" 
												Orientation="Horizontal" 
												HorizontalAlignment="Right" 
												VerticalAlignment="Center">
										<Button Name="PART_MinimizeButton" Style="{StaticResource TitlebarMinimizeButton}" />
										<Button Name="PART_CloseButton" Style="{StaticResource TitlebarCloseButton}" />
									</StackPanel>
								</Grid>
							</Border>
							<Rectangle DockPanel.Dock="Top" 
									   Height="3" Width="Auto"
									   Fill="{StaticResource TitlebarShadowBrush}" />
							<AdornerDecorator>
								<ContentPresenter Margin="{TemplateBinding Margin}" />
							</AdornerDecorator>
						</DockPanel>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="ResizeMode" Value="NoResize">
							<Setter TargetName="PART_MinimizeButton" Property="Visibility" Value="Hidden" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style x:Key="GameBackground" TargetType="{x:Type Panel}">
	</Style>

	<Style x:Key="ComboList" TargetType="{x:Type ListBox}">
	</Style>
	
	<Style TargetType="{x:Type Menu}">
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrush}}" />
	</Style>
	
</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.

The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).

Comments and Discussions