有没有将项目集成到自己的WPF程序中的demo呢 #382
Answered
by
LorisYounger
ChangSheng3407
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
LorisYounger
May 20, 2024
Replies: 1 comment 1 reply
-
没有, 不过这里提供部分虚拟主播模拟器写的加载桌宠的代码 读取配置 case "pet":
//宠物模型
Content += "宠物形象\n";
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName));
if (lps.First().Name.ToLower() == "pet")
{
var name = lps.First().Info;
var p = core.CorePets.FirstOrDefault(x => x.Name == name);
if (p == null)
core.CorePets.Add(new PetLoader(lps, di));
else
{
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
p.Config.Set(lps);
}
}
}
break; 加载桌宠 //加载桌宠
PetCore = new VPet_Simulator.Core.GameCore();
PetCore.Controller = new MWController(this);
PetCore.Graph = Core.CorePets[0].Graph(500);//TODO:写进设置
PetCore.Save = Save.VPet;
VPet = new VPet_Simulator.Core.Main(PetCore);
VPet.LoadALL();
if (Save.Statistics.GetInt("tutorial") <= 100 && Set.EnableTutorial)
{//<=100,教程没放完,继续放教程
VPet.DefaultClickAction = () => Tutorial.ClickEvent(this);
VPet.MsgBar.EndAction += () => Tutorial.SayEndEvent(this);
Task.Run(() =>
{
Thread.Sleep(3000);
Tutorial.ClickEvent(this);
});
}
else
{
//TODO教程放完了,让宠物自由互动
VPet.MsgBar.EndAction -= () => Tutorial.SayEndEvent(this);
} 让桌宠能在窗体控件里移动的控制器 public class MWController : IController
{
readonly MainWindow mw;
public MWController(MainWindow mw)
{
this.mw = mw;
}
public double ZoomRatio => .4;
public int PressLength => 500;
public bool EnableFunction => false;
public int InteractionCycle => 2000;
public bool RePostionActive { get; set; } = true;
public bool CheckPosition() => mw.Dispatcher.Invoke(() =>
GetWindowsDistanceUp() < -0.25 * mw.ActualHeight && GetWindowsDistanceDown() < 720
|| GetWindowsDistanceDown() < -0.25 * mw.ActualHeight && GetWindowsDistanceUp() < 720
|| GetWindowsDistanceLeft() < -0.25 * mw.ActualWidth && GetWindowsDistanceRight() < 1280
|| GetWindowsDistanceRight() < -0.25 * mw.ActualWidth && GetWindowsDistanceLeft() < 1280
);
public double GetWindowsDistanceDown()
{
return mw.Dispatcher.Invoke(() => 1280 - mw.BorderPet.Margin.Top - mw.BorderPet.Height);
}
public double GetWindowsDistanceLeft()
{
return mw.Dispatcher.Invoke(() => mw.BorderPet.Margin.Left);
}
public double GetWindowsDistanceRight()
{
return mw.Dispatcher.Invoke(() => 720 - mw.BorderPet.Margin.Left - mw.BorderPet.Width);
}
public double GetWindowsDistanceUp()
{
return mw.Dispatcher.Invoke(() => mw.BorderPet.Margin.Top);
}
public void MoveWindows(double X, double Y)
{
mw.Dispatcher.Invoke(() =>
{
var m = mw.BorderPet.Margin;
mw.BorderPet.Margin = new System.Windows.Thickness(m.Left + X * ZoomRatio, m.Top + Y * ZoomRatio, 0, 0);
});
}
public void ResetPosition()
{
throw new NotImplementedException();
}
public void ShowPanel()
{
//TODO
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
LorisYounger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
没有, 不过这里提供部分虚拟主播模拟器写的加载桌宠的代码
读取配置
加载桌宠