支持移动摸头

This commit is contained in:
ZouJin 2023-02-20 19:47:44 +11:00
parent 8db05e1b9a
commit c6a73e589e
8 changed files with 91 additions and 22 deletions

BIN
README.assets/ss0.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

View File

@ -22,7 +22,7 @@
##### 摸头 ##### 摸头
![ss2](README.assets/ss2.gif) ![ss0](README.assets/ss0.gif)
##### 提起 ##### 提起

View File

@ -5,7 +5,7 @@
mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="250"> mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="250">
<Viewbox> <Viewbox>
<Grid x:Name="MainGrid" Width="500" Height="500" MouseLeftButtonDown="MainGrid_MouseLeftButtonDown" <Grid x:Name="MainGrid" Width="500" Height="500" MouseLeftButtonDown="MainGrid_MouseLeftButtonDown"
MouseLeftButtonUp="MainGrid_MouseLeftButtonUp" MouseRightButtonDown="MainGrid_MouseRightButtonDown"> MouseLeftButtonUp="MainGrid_MouseLeftButtonUp" MouseRightButtonDown="MainGrid_MouseRightButtonDown" MouseMove="MainGrid_MouseWave">
<Border x:Name="PetGrid" VerticalAlignment="Bottom" /> <Border x:Name="PetGrid" VerticalAlignment="Bottom" />
<Border x:Name="PetGrid2" VerticalAlignment="Bottom" /> <Border x:Name="PetGrid2" VerticalAlignment="Bottom" />
<Grid x:Name="UIGrid"> <Grid x:Name="UIGrid">

View File

@ -137,6 +137,7 @@ namespace VPet_Simulator.Core
if (DisplayType.ToString().StartsWith("Raised")) if (DisplayType.ToString().StartsWith("Raised"))
{ {
MainGrid.MouseMove -= MainGrid_MouseMove; MainGrid.MouseMove -= MainGrid_MouseMove;
MainGrid.MouseMove += MainGrid_MouseWave;
rasetype = -1; rasetype = -1;
DisplayRaising(); DisplayRaising();
} }
@ -190,6 +191,73 @@ namespace VPet_Simulator.Core
{ {
MoveTimer.Enabled = false; MoveTimer.Enabled = false;
MainGrid.MouseMove -= MainGrid_MouseMove; MainGrid.MouseMove -= MainGrid_MouseMove;
MainGrid.MouseMove += MainGrid_MouseWave;
}
private int wavetimes = 0;
private int switchcount = 0;
private bool? waveleft = null;
private bool? wavetop = null;
private DateTime wavespan;
private void MainGrid_MouseWave(object sender, MouseEventArgs e)
{
if ((DateTime.Now - wavespan).TotalSeconds > 5)
{
wavetimes = 0;
switchcount = 0;
waveleft = null;
wavetop = null;
}
wavespan = DateTime.Now;
bool active = false;
var p = e.GetPosition(MainGrid);
if (p.Y < 200)
{
if (wavetop != false)
wavetop = true;
else
{
if (switchcount++ > 150)
wavespan = DateTime.MinValue;
return;
}
}
else
{
if (waveleft != true)
wavetop = false;
else
{
if (switchcount++ > 150)
wavespan = DateTime.MinValue;
return;
}
}
if (p.X < 200 && waveleft != true)
{
waveleft = true;
active = true;
}
if (p.X > 300 && waveleft != false)
{
active = true;
waveleft = false;
}
if (active)
{
if (wavetimes++ > 3)
if (wavetop == true)
{
DisplayTouchHead();
Console.WriteLine(wavetimes);
}
else
{
}
}
} }
} }
} }

View File

@ -90,10 +90,13 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
public void DisplayTouchHead() public void DisplayTouchHead()
{ {
if (Core.Save.Strength <= DistanceMin) if (Core.Controller.EnableFunction && Core.Save.Strength <= DistanceMin)
return; {
Core.Save.StrengthChange(-1); Core.Save.StrengthChange(-1);
Core.Save.FeelingChange(1); Core.Save.FeelingChange(1);
}
if (DisplayType == GraphType.Touch_Head_A_Start)
return;
if (DisplayType == GraphType.Touch_Head_B_Loop) if (DisplayType == GraphType.Touch_Head_B_Loop)
if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop) if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop)
{ {
@ -105,6 +108,7 @@ namespace VPet_Simulator.Core
ig2.IsContinue = true; ig2.IsContinue = true;
return; return;
} }
Display(GraphCore.GraphType.Touch_Head_A_Start, () => Display(GraphCore.GraphType.Touch_Head_A_Start, () =>
Display(GraphCore.GraphType.Touch_Head_B_Loop, () => Display(GraphCore.GraphType.Touch_Head_B_Loop, () =>
Display(GraphCore.GraphType.Touch_Head_C_End, DisplayNomal Display(GraphCore.GraphType.Touch_Head_C_End, DisplayNomal
@ -236,6 +240,7 @@ namespace VPet_Simulator.Core
{ {
//位置迁移: 254-128 //位置迁移: 254-128
MainGrid.MouseMove += MainGrid_MouseMove; MainGrid.MouseMove += MainGrid_MouseMove;
MainGrid.MouseMove -= MainGrid_MouseWave;
rasetype = 0; rasetype = 0;
DisplayRaising(); DisplayRaising();
//if (((IGraph)PetGrid.Child).GraphType == GraphCore.GraphType.Touch_Head_B_Loop) //if (((IGraph)PetGrid.Child).GraphType == GraphCore.GraphType.Touch_Head_B_Loop)

View File

@ -38,7 +38,7 @@
<TextBlock x:Name="Tlv" Text="Lv 14" VerticalAlignment="Center" <TextBlock x:Name="Tlv" Text="Lv 14" VerticalAlignment="Center"
Foreground="{DynamicResource DARKPrimary}" Grid.ColumnSpan="3" /> Foreground="{DynamicResource DARKPrimary}" Grid.ColumnSpan="3" />
<Button Grid.Column="4" VerticalAlignment="Center" Background="Transparent" <Button Grid.Column="4" VerticalAlignment="Center" Background="Transparent"
Foreground="{DynamicResource DARKPrimary}" Content="详细" Cursor="Hand" Click="MenuPanel_Click"> Foreground="{DynamicResource DARKPrimary}" Content="详细" Cursor="Hand" Click="MenuPanel_Click" IsEnabled="False">
<Button.ContentTemplate> <Button.ContentTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding}" TextDecorations="Underline" /> <TextBlock Text="{Binding}" TextDecorations="Underline" />
@ -102,17 +102,17 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</Menu.ItemsPanel> </Menu.ItemsPanel>
<MenuItem x:Name="MenuFeed" Header="投喂" HorizontalContentAlignment="Center" > <MenuItem x:Name="MenuFeed" Header="投喂" HorizontalContentAlignment="Center" >
<MenuItem Header="食物" HorizontalContentAlignment="Center" /> <MenuItem Header="食物" HorizontalContentAlignment="Center" IsEnabled="False" />
<MenuItem Header="饮料" HorizontalContentAlignment="Center" /> <MenuItem Header="饮料" HorizontalContentAlignment="Center" IsEnabled="False" />
<MenuItem Header="药品" HorizontalContentAlignment="Center" /> <MenuItem Header="药品" HorizontalContentAlignment="Center" IsEnabled="False"/>
</MenuItem> </MenuItem>
<MenuItem x:Name="MenuPanel" Header="面板" MouseEnter="MenuPanel_MouseEnter" MouseLeave="MenuPanel_MouseLeave" <MenuItem x:Name="MenuPanel" Header="面板" MouseEnter="MenuPanel_MouseEnter" MouseLeave="MenuPanel_MouseLeave"
HorizontalContentAlignment="Center" /> HorizontalContentAlignment="Center" />
<MenuItem x:Name="MenuInteract" Header="互动" HorizontalContentAlignment="Center"> <MenuItem x:Name="MenuInteract" Header="互动" HorizontalContentAlignment="Center">
<MenuItem Header="睡觉" HorizontalContentAlignment="Center" Click="Sleep_Click" /> <MenuItem Header="睡觉" HorizontalContentAlignment="Center" Click="Sleep_Click" />
<MenuItem Header="玩耍" HorizontalContentAlignment="Center" /> <MenuItem Header="玩耍" HorizontalContentAlignment="Center" IsEnabled="False"/>
<MenuItem Header="说话" HorizontalContentAlignment="Center" /> <MenuItem Header="说话" HorizontalContentAlignment="Center" IsEnabled="False"/>
<MenuItem Header="学习" HorizontalContentAlignment="Center" /> <MenuItem Header="学习" HorizontalContentAlignment="Center" IsEnabled="False" />
</MenuItem> </MenuItem>
<MenuItem x:Name="MenuDIY" Header="自定" HorizontalContentAlignment="Center" Click="MenuDIY_Click" <MenuItem x:Name="MenuDIY" Header="自定" HorizontalContentAlignment="Center" Click="MenuDIY_Click"
x:FieldModifier="public" /> x:FieldModifier="public" />

View File

@ -561,9 +561,7 @@ namespace VPet_Simulator.Windows
if (mw.Set.StartUPBoot) if (mw.Set.StartUPBoot)
{ {
if (File.Exists(path)) if (File.Exists(path))
{ File.Delete(path);
return;
}
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
string shortcutAddress; string shortcutAddress;
if (mw.Set.StartUPBootSteam) if (mw.Set.StartUPBootSteam)
@ -585,11 +583,9 @@ namespace VPet_Simulator.Windows
else else
{ {
if (File.Exists(path)) if (File.Exists(path))
{
File.Delete(path); File.Delete(path);
} }
} }
}
private void StartUpBox_Checked(object sender, RoutedEventArgs e) private void StartUpBox_Checked(object sender, RoutedEventArgs e)
{ {
if (!AllowChange) if (!AllowChange)