支持移动摸头

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

@ -41,7 +41,7 @@ namespace VPet_Simulator.Core
/// 刷新时间时会调用该方法,在所有任务处理完之后 /// 刷新时间时会调用该方法,在所有任务处理完之后
/// </summary> /// </summary>
public event Action<Main> TimeUIHandle; public event Action<Main> TimeUIHandle;
public Main(GameCore core,bool loadtouchevent = true) public Main(GameCore core, bool loadtouchevent = true)
{ {
InitializeComponent(); InitializeComponent();
Core = core; Core = core;
@ -60,7 +60,7 @@ namespace VPet_Simulator.Core
var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, core.Save.Mode); var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, core.Save.Mode);
PetGrid.Child = ig.This; PetGrid.Child = ig.This;
var ig2 = Core.Graph.FindGraph(GraphCore.GraphType.Touch_Head_A_Start, core.Save.Mode); var ig2 = Core.Graph.FindGraph(GraphCore.GraphType.Touch_Head_A_Start, core.Save.Mode);
PetGrid2.Child = ig2.This; //用于缓存 PetGrid2.Child = ig2.This; //用于缓存
PetGrid2.Visibility = Visibility.Collapsed; PetGrid2.Visibility = Visibility.Collapsed;
ig.Run(DisplayNomal); ig.Run(DisplayNomal);
@ -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();
} }
@ -173,7 +174,7 @@ namespace VPet_Simulator.Core
public void Dispose() public void Dispose()
{ {
EventTimer.Stop(); EventTimer.Stop();
MoveTimer.Enabled = false;; MoveTimer.Enabled = false; ;
EventTimer.Dispose(); EventTimer.Dispose();
MoveTimer.Dispose(); MoveTimer.Dispose();
MsgBar.Dispose(); MsgBar.Dispose();
@ -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)
{
Core.Save.StrengthChange(-1);
Core.Save.FeelingChange(1);
}
if (DisplayType == GraphType.Touch_Head_A_Start)
return; return;
Core.Save.StrengthChange(-1);
Core.Save.FeelingChange(1);
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)
@ -1035,7 +1040,7 @@ namespace VPet_Simulator.Core
/// <param name="EndAction">结束操作</param> /// <param name="EndAction">结束操作</param>
public void Display(IGraph graph, Action EndAction = null) public void Display(IGraph graph, Action EndAction = null)
{ {
if(graph == null) if (graph == null)
{ {
EndAction?.Invoke(); EndAction?.Invoke();
return; return;

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" />
@ -101,18 +101,18 @@
<UniformGrid Columns="5" /> <UniformGrid Columns="5" />
</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,9 +583,7 @@ 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)