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