mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
智能化重新归位
This commit is contained in:
parent
69c64b83ae
commit
a8107a6ea8
@ -28,7 +28,6 @@ namespace VPet_Simulator.Core
|
||||
/// </summary>
|
||||
public void DisplayToNomal()
|
||||
{
|
||||
this.Core.Controller.ResetPosition();
|
||||
switch (State)
|
||||
{
|
||||
default:
|
||||
@ -378,6 +377,7 @@ namespace VPet_Simulator.Core
|
||||
break;
|
||||
case -1:
|
||||
rasetype = int.MinValue;
|
||||
Core.Controller.RePostionActive = !Core.Controller.CheckPosition();
|
||||
if (string.IsNullOrEmpty(name))
|
||||
Display(GraphType.Raised_Static, AnimatType.C_End, DisplayToNomal);
|
||||
else
|
||||
|
@ -485,8 +485,7 @@ namespace VPet_Simulator.Core
|
||||
return;
|
||||
}
|
||||
}
|
||||
m.MoveTimer.Enabled = false;
|
||||
m.Display(Graph, AnimatType.C_End, m.DisplayToNomal);
|
||||
StopMoving(m);
|
||||
return;
|
||||
}
|
||||
//不是:继续右边走or停下
|
||||
@ -504,6 +503,14 @@ namespace VPet_Simulator.Core
|
||||
return;
|
||||
}
|
||||
}
|
||||
StopMoving(m);
|
||||
}
|
||||
|
||||
private void StopMoving(Main m)
|
||||
{
|
||||
if (m.Core.Controller.RePostionActive)
|
||||
m.Core.Controller.ResetPosition();
|
||||
m.Core.Controller.RePostionActive = !m.Core.Controller.CheckPosition();
|
||||
m.MoveTimer.Enabled = false;
|
||||
m.Display(Graph, AnimatType.C_End, m.DisplayToNomal);
|
||||
}
|
||||
|
@ -54,6 +54,10 @@
|
||||
/// 在边缘时重新靠边,防止被阻挡
|
||||
/// </summary>
|
||||
void ResetPosition();
|
||||
/// <summary>
|
||||
/// 判断桌宠是否靠边
|
||||
/// </summary>
|
||||
bool CheckPosition();
|
||||
|
||||
/// <summary>
|
||||
/// 启用计算等数据功能
|
||||
@ -62,6 +66,11 @@
|
||||
/// <summary>
|
||||
/// 互动周期
|
||||
/// </summary>
|
||||
int InteractionCycle { get; }
|
||||
int InteractionCycle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用边缘重新定位
|
||||
/// </summary>
|
||||
bool RePostionActive { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -111,30 +111,32 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
mw.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (RePostionActive)
|
||||
if (GetWindowsDistanceUp() < -0.25 * mw.Height && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight)
|
||||
{
|
||||
if (mw.Core.Controller.GetWindowsDistanceUp() < -0.25 * mw.Height && mw.Core.Controller.GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight)
|
||||
{
|
||||
mw.Core.Controller.MoveWindows(0, -mw.Core.Controller.GetWindowsDistanceUp() / mw.Core.Controller.ZoomRatio);
|
||||
}
|
||||
else if (mw.Core.Controller.GetWindowsDistanceDown() < -0.25 * mw.Height && mw.Core.Controller.GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight)
|
||||
{
|
||||
mw.Core.Controller.MoveWindows(0, mw.Core.Controller.GetWindowsDistanceDown() / mw.Core.Controller.ZoomRatio);
|
||||
}
|
||||
if (mw.Core.Controller.GetWindowsDistanceLeft() < -0.25 * mw.Width && mw.Core.Controller.GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth)
|
||||
{
|
||||
mw.Core.Controller.MoveWindows(-mw.Core.Controller.GetWindowsDistanceLeft() / mw.Core.Controller.ZoomRatio, 0);
|
||||
}
|
||||
else if (mw.Core.Controller.GetWindowsDistanceRight() < -0.25 * mw.Width && mw.Core.Controller.GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth)
|
||||
{
|
||||
mw.Core.Controller.MoveWindows(mw.Core.Controller.GetWindowsDistanceRight() / mw.Core.Controller.ZoomRatio, 0);
|
||||
}
|
||||
MoveWindows(0, -GetWindowsDistanceUp() / ZoomRatio);
|
||||
}
|
||||
else if (GetWindowsDistanceDown() < -0.25 * mw.Height && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight)
|
||||
{
|
||||
MoveWindows(0, GetWindowsDistanceDown() / ZoomRatio);
|
||||
}
|
||||
if (GetWindowsDistanceLeft() < -0.25 * mw.Width && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth)
|
||||
{
|
||||
MoveWindows(-GetWindowsDistanceLeft() / ZoomRatio, 0);
|
||||
}
|
||||
else if (GetWindowsDistanceRight() < -0.25 * mw.Width && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth)
|
||||
{
|
||||
MoveWindows(GetWindowsDistanceRight() / ZoomRatio, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
public bool CheckPosition() => mw.Dispatcher.Invoke(() =>
|
||||
GetWindowsDistanceUp() < -0.25 * mw.Height && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight
|
||||
|| GetWindowsDistanceDown() < -0.25 * mw.Height && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight
|
||||
|| GetWindowsDistanceLeft() < -0.25 * mw.Width && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth
|
||||
|| GetWindowsDistanceRight() < -0.25 * mw.Width && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth
|
||||
);
|
||||
|
||||
|
||||
public bool RePostionActive = true;
|
||||
public bool RePostionActive { get; set; } = true;
|
||||
|
||||
public double ZoomRatio => mw.Set.ZoomLevel;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user