feat: add combat and deleveling AI
This commit is contained in:
@@ -41,6 +41,18 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Grid DataContext="{Binding CombatZone}" ClipToBounds="True">
|
||||
<Path StrokeThickness="2" Fill="#1100ff00" Stroke="#3300ff00" >
|
||||
<Path.Data>
|
||||
<EllipseGeometry
|
||||
RadiusX="{Binding Radius,Mode=OneWay}"
|
||||
RadiusY="{Binding Radius,Mode=OneWay}"/>
|
||||
</Path.Data>
|
||||
<Path.RenderTransform>
|
||||
<TranslateTransform X="{Binding Center.X,Mode=OneWay}" Y="{Binding Center.Y,Mode=OneWay}"/>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Grid>
|
||||
<ItemsControl ItemsSource="{Binding Path=Creatures}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -141,9 +153,17 @@
|
||||
</Grid>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding Type,Mode=OneWay}" Value="NPC">
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="DarkGreen" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="DarkGreen" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsHostile,Mode=OneWay}" Value="True">
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="LimeGreen" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="LimeGreen" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsDead,Mode=OneWay}" Value="True">
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="Gray" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="Gray" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Type,Mode=OneWay}" Value="Player">
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="Blue" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="Blue" />
|
||||
@@ -156,6 +176,10 @@
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="Red" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="Red" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsSweepable,Mode=OneWay}" Value="True">
|
||||
<Setter TargetName="CreatureBody" Property="Stroke" Value="Magenta" />
|
||||
<Setter TargetName="CreatureDirection" Property="Stroke" Value="Magenta" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsTarget,Mode=OneWay}" Value="True">
|
||||
<Setter TargetName="CreatureName" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
|
102
Client/Application/Components/MultipleObjectSelector.xaml
Normal file
102
Client/Application/Components/MultipleObjectSelector.xaml
Normal file
@@ -0,0 +1,102 @@
|
||||
<UserControl x:Class="Client.Application.Components.MultipleObjectSelector"
|
||||
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:Client.Application.Components"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
x:Name="root">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="{Binding Header,ElementName=root}" />
|
||||
<StackPanel Grid.Row="1" Grid.Column="0">
|
||||
<TextBox
|
||||
x:Name="sourceSearch"
|
||||
HorizontalAlignment="Stretch">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="KeyUp">
|
||||
<i:InvokeCommandAction
|
||||
Command="{x:Static local:MultipleObjectSelector.SearchSourceCommand}"
|
||||
CommandParameter="{Binding Text,ElementName=sourceSearch}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</TextBox>
|
||||
<ListBox
|
||||
ItemsSource="{Binding Source,ElementName=root}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Height="100"
|
||||
Width="Auto"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
x:Name="source">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}">
|
||||
<TextBlock.InputBindings>
|
||||
<MouseBinding
|
||||
MouseAction="LeftDoubleClick"
|
||||
Command="{x:Static local:MultipleObjectSelector.AddItemCommand}"
|
||||
CommandParameter="{Binding SelectedValue,ElementName=source}"/>
|
||||
</TextBlock.InputBindings>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" Grid.Column="0">
|
||||
<Button
|
||||
Width="20"
|
||||
Command="{x:Static local:MultipleObjectSelector.AddItemCommand}"
|
||||
CommandParameter="{Binding SelectedValue,ElementName=source}"
|
||||
>↓</Button>
|
||||
<Button
|
||||
Width="20"
|
||||
Command="{x:Static local:MultipleObjectSelector.RemoveItemCommand}"
|
||||
CommandParameter="{Binding SelectedValue,ElementName=target}"
|
||||
>↑</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="3" Grid.Column="0">
|
||||
<TextBox
|
||||
x:Name="targetSearch"
|
||||
HorizontalAlignment="Stretch">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="KeyUp">
|
||||
<i:InvokeCommandAction
|
||||
Command="{x:Static local:MultipleObjectSelector.SearchTargetCommand}"
|
||||
CommandParameter="{Binding Text,ElementName=targetSearch}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</TextBox>
|
||||
<ListBox
|
||||
ItemsSource="{Binding Target,ElementName=root}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Height="100"
|
||||
Width="Auto"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
x:Name="target">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}">
|
||||
<TextBlock.InputBindings>
|
||||
<MouseBinding
|
||||
MouseAction="LeftDoubleClick"
|
||||
Command="{x:Static local:MultipleObjectSelector.RemoveItemCommand}"
|
||||
CommandParameter="{Binding SelectedValue,ElementName=target}"/>
|
||||
</TextBlock.InputBindings>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
109
Client/Application/Components/MultipleObjectSelector.xaml.cs
Normal file
109
Client/Application/Components/MultipleObjectSelector.xaml.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using Client.Domain.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Client.Application.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MobSelector.xaml
|
||||
/// </summary>
|
||||
public partial class MultipleObjectSelector : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty SourceProperty =
|
||||
DependencyProperty.Register("Source", typeof(ICollection<ObjectInfo>), typeof(MultipleObjectSelector), new PropertyMetadata(default(ICollection<ObjectInfo>)));
|
||||
public ICollection<ObjectInfo> Source
|
||||
{
|
||||
get { return (ICollection<ObjectInfo>)GetValue(SourceProperty); }
|
||||
set { SetValue(SourceProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TargetProperty =
|
||||
DependencyProperty.Register("Target", typeof(ICollection<ObjectInfo>), typeof(MultipleObjectSelector), new PropertyMetadata(default(ICollection<ObjectInfo>)));
|
||||
public ICollection<ObjectInfo> Target
|
||||
{
|
||||
get { return (ICollection<ObjectInfo>)GetValue(TargetProperty); }
|
||||
set { SetValue(TargetProperty, value); }
|
||||
}
|
||||
public string Header
|
||||
{
|
||||
get { return (string)GetValue(HeaderProperty); }
|
||||
set { SetValue(HeaderProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty HeaderProperty =
|
||||
DependencyProperty.Register("Header", typeof(string), typeof(MultipleObjectSelector), new PropertyMetadata(""));
|
||||
|
||||
public static RoutedUICommand AddItemCommand { get; } = new RoutedUICommand(
|
||||
"Add item",
|
||||
nameof(AddItemCommand),
|
||||
typeof(MultipleObjectSelector)
|
||||
);
|
||||
public static RoutedUICommand RemoveItemCommand { get; } = new RoutedUICommand(
|
||||
"Remove item",
|
||||
nameof(RemoveItemCommand),
|
||||
typeof(MultipleObjectSelector)
|
||||
);
|
||||
public static RoutedUICommand SearchSourceCommand { get; } = new RoutedUICommand(
|
||||
"Search in source",
|
||||
nameof(SearchSourceCommand),
|
||||
typeof(MultipleObjectSelector)
|
||||
);
|
||||
public static RoutedUICommand SearchTargetCommand { get; } = new RoutedUICommand(
|
||||
"Search in target",
|
||||
nameof(SearchTargetCommand),
|
||||
typeof(MultipleObjectSelector)
|
||||
);
|
||||
|
||||
|
||||
public MultipleObjectSelector()
|
||||
{
|
||||
InitializeComponent();
|
||||
CommandBindings.Add(new CommandBinding(AddItemCommand, AddItem));
|
||||
CommandBindings.Add(new CommandBinding(RemoveItemCommand, RemoveItem));
|
||||
CommandBindings.Add(new CommandBinding(SearchSourceCommand, SearchSource));
|
||||
CommandBindings.Add(new CommandBinding(SearchTargetCommand, SearchTarget));
|
||||
}
|
||||
|
||||
private void AddItem(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var item = e.Parameter as ObjectInfo;
|
||||
if (item != null)
|
||||
{
|
||||
Source.Remove(item);
|
||||
Target.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveItem(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var item = e.Parameter as ObjectInfo;
|
||||
if (item != null)
|
||||
{
|
||||
Target.Remove(item);
|
||||
Source.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchSource(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var searchPredicate = (string)e.Parameter ?? null;
|
||||
|
||||
if (searchPredicate != null)
|
||||
{
|
||||
CollectionViewSource.GetDefaultView(Source).Filter = item => (item as ObjectInfo)?.Name.Contains(searchPredicate, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchTarget(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var searchPredicate = (string)e.Parameter ?? null;
|
||||
|
||||
if (searchPredicate != null)
|
||||
{
|
||||
CollectionViewSource.GetDefaultView(Target).Filter = item => (item as ObjectInfo)?.Name.Contains(searchPredicate, StringComparison.OrdinalIgnoreCase) ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
Client/Application/Components/ObjectSelector.xaml
Normal file
30
Client/Application/Components/ObjectSelector.xaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<UserControl x:Class="Client.Application.Components.ObjectSelector"
|
||||
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:Client.Application.Components"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
x:Name="root">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="{Binding Header,ElementName=root}" Grid.Row="0" Grid.Column="0"/>
|
||||
<ComboBox
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
SelectedValuePath="Id"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Source,ElementName=root}"
|
||||
SelectedValue="{Binding SelectedValue,ElementName=root}"
|
||||
>
|
||||
<ComboBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ComboBox.ItemsPanel>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</UserControl>
|
55
Client/Application/Components/ObjectSelector.xaml.cs
Normal file
55
Client/Application/Components/ObjectSelector.xaml.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
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 Client.Application.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SearchableCombobox.xaml
|
||||
/// </summary>
|
||||
public partial class ObjectSelector : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty SourceProperty =
|
||||
DependencyProperty.Register("Source", typeof(ICollection<ObjectInfo>), typeof(ObjectSelector), new PropertyMetadata(default(ICollection<ObjectInfo>)));
|
||||
public ICollection<ObjectInfo> Source
|
||||
{
|
||||
get { return (ICollection<ObjectInfo>)GetValue(SourceProperty); }
|
||||
set { SetValue(SourceProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedValueProperty =
|
||||
DependencyProperty.Register("SelectedValue", typeof(object), typeof(ObjectSelector), new PropertyMetadata(default(object)));
|
||||
public object SelectedValue
|
||||
{
|
||||
get { return GetValue(SelectedValueProperty); }
|
||||
set { SetValue(SelectedValueProperty, value); }
|
||||
}
|
||||
|
||||
public string Header
|
||||
{
|
||||
get { return (string)GetValue(HeaderProperty); }
|
||||
set { SetValue(HeaderProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty HeaderProperty =
|
||||
DependencyProperty.Register("Header", typeof(string), typeof(ObjectSelector), new PropertyMetadata(""));
|
||||
|
||||
public ObjectSelector()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user