Skip to content

Commit

Permalink
支持移动摸头
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisYounger committed Feb 20, 2023
1 parent 8db05e1 commit c6a73e5
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 22 deletions.
Binary file added README.assets/ss0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed README.assets/ss2.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

##### 摸头

![ss2](README.assets/ss2.gif)
![ss0](README.assets/ss0.gif)

##### 提起

Expand Down
2 changes: 1 addition & 1 deletion VPet-Simulator.Core/Display/Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mc:Ignorable="d" d:DesignHeight="250" d:DesignWidth="250">
<Viewbox>
<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="PetGrid2" VerticalAlignment="Bottom" />
<Grid x:Name="UIGrid">
Expand Down
74 changes: 71 additions & 3 deletions VPet-Simulator.Core/Display/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public partial class Main : UserControl, IDisposable
/// 刷新时间时会调用该方法,在所有任务处理完之后
/// </summary>
public event Action<Main> TimeUIHandle;
public Main(GameCore core,bool loadtouchevent = true)
public Main(GameCore core, bool loadtouchevent = true)
{
InitializeComponent();
Core = core;
Expand All @@ -60,7 +60,7 @@ public Main(GameCore core,bool loadtouchevent = true)

var ig = Core.Graph.FindGraph(GraphCore.GraphType.Default, core.Save.Mode);
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.Visibility = Visibility.Collapsed;
ig.Run(DisplayNomal);
Expand Down Expand Up @@ -137,6 +137,7 @@ private void MainGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
if (DisplayType.ToString().StartsWith("Raised"))
{
MainGrid.MouseMove -= MainGrid_MouseMove;
MainGrid.MouseMove += MainGrid_MouseWave;
rasetype = -1;
DisplayRaising();
}
Expand Down Expand Up @@ -173,7 +174,7 @@ private void MainGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e
public void Dispose()
{
EventTimer.Stop();
MoveTimer.Enabled = false;;
MoveTimer.Enabled = false; ;
EventTimer.Dispose();
MoveTimer.Dispose();
MsgBar.Dispose();
Expand All @@ -190,6 +191,73 @@ public void CleanState()
{
MoveTimer.Enabled = false;
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
{

}
}
}
}
}
13 changes: 9 additions & 4 deletions VPet-Simulator.Core/Display/MainDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ public bool DisplayStopMove(Action EndAction)
/// </summary>
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;
Core.Save.StrengthChange(-1);
Core.Save.FeelingChange(1);
if (DisplayType == GraphType.Touch_Head_B_Loop)
if (PetGrid.Child is IGraph ig && ig.GraphType == GraphCore.GraphType.Touch_Head_B_Loop)
{
Expand All @@ -105,6 +108,7 @@ public void DisplayTouchHead()
ig2.IsContinue = true;
return;
}

Display(GraphCore.GraphType.Touch_Head_A_Start, () =>
Display(GraphCore.GraphType.Touch_Head_B_Loop, () =>
Display(GraphCore.GraphType.Touch_Head_C_End, DisplayNomal
Expand Down Expand Up @@ -236,6 +240,7 @@ public void DisplayRaised()
{
//位置迁移: 254-128
MainGrid.MouseMove += MainGrid_MouseMove;
MainGrid.MouseMove -= MainGrid_MouseWave;
rasetype = 0;
DisplayRaising();
//if (((IGraph)PetGrid.Child).GraphType == GraphCore.GraphType.Touch_Head_B_Loop)
Expand Down Expand Up @@ -1035,7 +1040,7 @@ public void Display(GraphType Type, Action EndAction = null, bool storernd = fal
/// <param name="EndAction">结束操作</param>
public void Display(IGraph graph, Action EndAction = null)
{
if(graph == null)
if (graph == null)
{
EndAction?.Invoke();
return;
Expand Down
16 changes: 8 additions & 8 deletions VPet-Simulator.Core/Display/ToolBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<TextBlock x:Name="Tlv" Text="Lv 14" VerticalAlignment="Center"
Foreground="{DynamicResource DARKPrimary}" Grid.ColumnSpan="3" />
<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>
<DataTemplate>
<TextBlock Text="{Binding}" TextDecorations="Underline" />
Expand Down Expand Up @@ -101,18 +101,18 @@
<UniformGrid Columns="5" />
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem x:Name="MenuFeed" Header="投喂" HorizontalContentAlignment="Center">
<MenuItem Header="食物" HorizontalContentAlignment="Center" />
<MenuItem Header="饮料" HorizontalContentAlignment="Center" />
<MenuItem Header="药品" HorizontalContentAlignment="Center" />
<MenuItem x:Name="MenuFeed" Header="投喂" HorizontalContentAlignment="Center" >
<MenuItem Header="食物" HorizontalContentAlignment="Center" IsEnabled="False" />
<MenuItem Header="饮料" HorizontalContentAlignment="Center" IsEnabled="False" />
<MenuItem Header="药品" HorizontalContentAlignment="Center" IsEnabled="False"/>
</MenuItem>
<MenuItem x:Name="MenuPanel" Header="面板" MouseEnter="MenuPanel_MouseEnter" MouseLeave="MenuPanel_MouseLeave"
HorizontalContentAlignment="Center" />
<MenuItem x:Name="MenuInteract" Header="互动" HorizontalContentAlignment="Center">
<MenuItem Header="睡觉" HorizontalContentAlignment="Center" Click="Sleep_Click" />
<MenuItem Header="玩耍" HorizontalContentAlignment="Center" />
<MenuItem Header="说话" HorizontalContentAlignment="Center" />
<MenuItem Header="学习" HorizontalContentAlignment="Center" />
<MenuItem Header="玩耍" HorizontalContentAlignment="Center" IsEnabled="False"/>
<MenuItem Header="说话" HorizontalContentAlignment="Center" IsEnabled="False"/>
<MenuItem Header="学习" HorizontalContentAlignment="Center" IsEnabled="False" />
</MenuItem>
<MenuItem x:Name="MenuDIY" Header="自定" HorizontalContentAlignment="Center" Click="MenuDIY_Click"
x:FieldModifier="public" />
Expand Down
6 changes: 1 addition & 5 deletions VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,7 @@ private void GenStartUP()
if (mw.Set.StartUPBoot)
{
if (File.Exists(path))
{
return;
}
File.Delete(path);
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
string shortcutAddress;
if (mw.Set.StartUPBootSteam)
Expand All @@ -585,9 +583,7 @@ private void GenStartUP()
else
{
if (File.Exists(path))
{
File.Delete(path);
}
}
}
private void StartUpBox_Checked(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit c6a73e5

Please sign in to comment.