diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs
index d33bf69..07c0782 100644
--- a/VPet-Simulator.Core/Display/MainLogic.cs
+++ b/VPet-Simulator.Core/Display/MainLogic.cs
@@ -156,6 +156,7 @@ namespace VPet_Simulator.Core
labeldisplaytimer.Start();
});
}
+ public Work NowWork;
///
/// 根据消耗计算相关数据
///
@@ -171,6 +172,8 @@ namespace VPet_Simulator.Core
freedrop = Math.Min(Math.Sqrt(freedrop) * TimePass / 2, Core.Save.FeelingMax / 400);
switch (State)
{
+ case WorkingState.Empty:
+ break;
case WorkingState.Sleep:
//睡觉不消耗
Core.Save.StrengthChange(TimePass * 2);
@@ -189,9 +192,10 @@ namespace VPet_Simulator.Core
LastInteractionTime = DateTime.Now;
break;
case WorkingState.Work:
- var nowwork = nowWork;
- var needfood = TimePass * nowwork.StrengthFood;
- var needdrink = TimePass * nowwork.StrengthDrink;
+ if (NowWork == null)
+ break;
+ var needfood = TimePass * NowWork.StrengthFood;
+ var needdrink = TimePass * NowWork.StrengthDrink;
double efficiency = 0;
int addhealth = -2;
if (Core.Save.StrengthFood <= 25)
@@ -232,19 +236,19 @@ namespace VPet_Simulator.Core
}
if (addhealth > 0)
Core.Save.Health += addhealth * TimePass;
- var addmoney = Math.Max(0, nowwork.MoneyBase * (1.500000000 * efficiency - 0.5));
- if (nowwork.Type == Work.WorkType.Work)
+ var addmoney = Math.Max(0, NowWork.MoneyBase * (1.500000000 * efficiency - 0.5));
+ if (NowWork.Type == Work.WorkType.Work)
Core.Save.Money += addmoney;
else
Core.Save.Exp += addmoney;
WorkTimer.GetCount += addmoney;
- if (nowwork.Type == Work.WorkType.Play)
+ if (NowWork.Type == Work.WorkType.Play)
{
LastInteractionTime = DateTime.Now;
- Core.Save.FeelingChange(-nowwork.Feeling * TimePass);
+ Core.Save.FeelingChange(-NowWork.Feeling * TimePass);
}
else
- Core.Save.FeelingChange(-freedrop * nowwork.Feeling);
+ Core.Save.FeelingChange(-freedrop * NowWork.Feeling);
if (Core.Save.Mode == IGameSave.ModeType.Ill)//生病时候停止工作
WorkTimer.Stop();
break;
@@ -479,14 +483,7 @@ namespace VPet_Simulator.Core
/// 当前状态
///
public WorkingState State = WorkingState.Nomal;
- ///
- /// 当前状态辅助ID
- ///
- public int StateID = 0;
- ///
- /// 当前工作
- ///
- public GraphHelper.Work nowWork => Core.Graph.GraphConfig.Works[StateID];
+
///
/// 当前正在的状态
///
@@ -552,7 +549,7 @@ namespace VPet_Simulator.Core
{
if (!Core.Controller.EnableFunction || Core.Save.Mode != IGameSave.ModeType.Ill)
if (!Core.Controller.EnableFunction || Core.Save.Level >= work.LevelLimit)
- if (State == Main.WorkingState.Work && StateID == Core.Graph.GraphConfig.Works.IndexOf(work))
+ if (State == Main.WorkingState.Work && NowWork.Name == work.Name)
WorkTimer.Stop();
else
{
diff --git a/VPet-Simulator.Core/Display/WorkTimer.xaml.cs b/VPet-Simulator.Core/Display/WorkTimer.xaml.cs
index c0fc738..eaf9064 100644
--- a/VPet-Simulator.Core/Display/WorkTimer.xaml.cs
+++ b/VPet-Simulator.Core/Display/WorkTimer.xaml.cs
@@ -82,23 +82,23 @@ namespace VPet_Simulator.Core
if (Visibility == Visibility.Collapsed) return;
TimeSpan ts = DateTime.Now - StartTime;
TimeSpan tleft;
- if (ts.TotalMinutes > nowWork.Time)
+ if (ts.TotalMinutes > m.NowWork.Time)
{
//学完了,停止
//ts = TimeSpan.FromMinutes(MaxTime);
//tleft = TimeSpan.Zero;
//PBLeft.Value = MaxTime;
- FinishWorkInfo fwi = new FinishWorkInfo(nowWork, GetCount);
+ FinishWorkInfo fwi = new FinishWorkInfo(m.NowWork, GetCount);
E_FinishWork?.Invoke(fwi);
- if (nowWork.Type == Work.WorkType.Work)
+ if (m.NowWork.Type == Work.WorkType.Work)
{
- m.Core.Save.Money += GetCount * nowWork.FinishBonus;
+ m.Core.Save.Money += GetCount * m.NowWork.FinishBonus;
Stop(() => m.SayRnd(LocalizeCore.Translate("{2}完成啦, 累计赚了 {0:f2} 金钱\n共计花费了{1}分钟", fwi.count,
fwi.spendtime, fwi.work.NameTrans), true));
}
else
{
- m.Core.Save.Exp += GetCount * nowWork.FinishBonus;
+ m.Core.Save.Exp += GetCount * m.NowWork.FinishBonus;
Stop(() => m.SayRnd(LocalizeCore.Translate("{2}完成啦, 累计获得 {0:f2} 经验\n共计花费了{1}分钟", fwi.count,
fwi.spendtime, fwi.work.NameTrans), true));
}
@@ -106,7 +106,7 @@ namespace VPet_Simulator.Core
}
else
{
- tleft = TimeSpan.FromMinutes(nowWork.Time) - ts;
+ tleft = TimeSpan.FromMinutes(m.NowWork.Time) - ts;
PBLeft.Value = ts.TotalMinutes;
}
switch (DisplayType)
@@ -118,7 +118,7 @@ namespace VPet_Simulator.Core
ShowTimeSpan(tleft); break;
case 2:
tNumber.Text = GetCount.ToString("f0");
- if (nowWork.Type == Work.WorkType.Work)
+ if (m.NowWork.Type == Work.WorkType.Work)
tNumberUnit.Text = LocalizeCore.Translate("钱");
else
tNumberUnit.Text = "EXP";
@@ -154,18 +154,18 @@ namespace VPet_Simulator.Core
else
{
DisplayBorder.Visibility = Visibility.Visible;
- btnStop.Content = LocalizeCore.Translate("停止") + nowWork.NameTrans;
+ btnStop.Content = LocalizeCore.Translate("停止") + m.NowWork.NameTrans;
switch (DisplayType)
{
default:
case 0:
- tNow.Text = LocalizeCore.Translate("当前已{0}", nowWork.NameTrans);
+ tNow.Text = LocalizeCore.Translate("当前已{0}", m.NowWork.NameTrans);
break;
case 1:
- tNow.Text = LocalizeCore.Translate("剩余{0}时间", nowWork.NameTrans);
+ tNow.Text = LocalizeCore.Translate("剩余{0}时间", m.NowWork.NameTrans);
break;
case 2:
- if (nowWork.Type == Work.WorkType.Work)
+ if (m.NowWork.Type == Work.WorkType.Work)
tNow.Text = LocalizeCore.Translate("累计金钱收益");
else
tNow.Text = LocalizeCore.Translate("获得经验值");
@@ -187,7 +187,7 @@ namespace VPet_Simulator.Core
// return;
Visibility = Visibility.Visible;
m.State = Main.WorkingState.Work;
- m.StateID = m.Core.Graph.GraphConfig.Works.IndexOf(work);
+ m.NowWork = work;
StartTime = DateTime.Now;
GetCount = 0;
@@ -195,24 +195,22 @@ namespace VPet_Simulator.Core
work.Display(m);
PBLeft.Maximum = work.Time;
- nowWork = work;
DisplayUI();
}
- private Work nowWork;
///
/// 停止工作
///
///
public void Stop(Action @then = null)
{
- if (m.State == Main.WorkingState.Work && nowWork != null)
+ if (m.State == Main.WorkingState.Work && m.NowWork != null)
{
- FinishWorkInfo fwi = new FinishWorkInfo(nowWork, GetCount);
+ FinishWorkInfo fwi = new FinishWorkInfo(m.NowWork, GetCount);
E_FinishWork?.Invoke(fwi);
}
Visibility = Visibility.Collapsed;
m.State = Main.WorkingState.Nomal;
- m.Display(nowWork.Graph, AnimatType.C_End, then ?? m.DisplayNomal);
+ m.Display(m.NowWork.Graph, AnimatType.C_End, then ?? m.DisplayNomal);
}
private void btnStop_Click(object sender, RoutedEventArgs e)
{
diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs
index a1ea75f..a5b4a4d 100644
--- a/VPet-Simulator.Windows/MainWindow.cs
+++ b/VPet-Simulator.Windows/MainWindow.cs
@@ -763,7 +763,7 @@ namespace VPet_Simulator.Windows
switch (Main.State)
{
case Main.WorkingState.Work:
- if (Main.nowWork.Type == Work.WorkType.Work)
+ if (Main.NowWork.Type == Work.WorkType.Work)
stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval;
else
stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval;
@@ -940,7 +940,7 @@ namespace VPet_Simulator.Windows
switch (obj.State)
{
case Main.WorkingState.Work:
- SteamFriends.SetRichPresence("work", obj.nowWork.Name.Translate());
+ SteamFriends.SetRichPresence("work", obj.NowWork.Name.Translate());
SteamFriends.SetRichPresence("steam_display", "#Status_Work");
break;
case Main.WorkingState.Sleep:
@@ -1345,9 +1345,8 @@ namespace VPet_Simulator.Windows
/// 加载游戏
///
/// MOD地址
- public async void GameLoad(List Path)
+ public async Task GameLoad(List Path)
{
-
Path = Path.Distinct().ToList();
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD"));
//加载mod
@@ -1997,6 +1996,10 @@ namespace VPet_Simulator.Windows
tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100} x{GameSavesData.GameSave.LevelMax}";
}
}
+
+
+
+
#if NewYear
int newyearsay = 0;
private void NewYearHandle(Main main)
diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs
index cd042a5..e7d2291 100644
--- a/VPet-Simulator.Windows/MainWindow.xaml.cs
+++ b/VPet-Simulator.Windows/MainWindow.xaml.cs
@@ -21,6 +21,7 @@ using static VPet_Simulator.Core.GraphInfo;
using System.Globalization;
using LinePutScript.Dictionary;
using Steamworks.Data;
+using VPet_Simulator.Windows.WinDesign;
namespace VPet_Simulator.Windows
{
@@ -100,7 +101,7 @@ namespace VPet_Simulator.Windows
GameInitialization();
- Task.Run(() =>
+ Task.Run(async () =>
{
//加载所有MOD
List Path = new List();
@@ -216,10 +217,27 @@ namespace VPet_Simulator.Windows
else//新玩家,默认设置为
Set["CGPT"][(gstr)"type"] = "LB";
- GameLoad(Path);
+ await GameLoad(Path);
+ if (IsSteamUser)
+ Dispatcher.Invoke(() =>
+ {
+ Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "访客表".Translate(), () =>
+ {
+ if (winMutiPlayer == null)
+ {
+ winMutiPlayer = new winMutiPlayer(this);
+ winMutiPlayer.Show();
+ }
+ else
+ {
+ winMutiPlayer.Focus();
+ }
+ });
+ });
+
});
}
-
+ internal winMutiPlayer winMutiPlayer;
public new void Close()
{
@@ -372,9 +390,9 @@ namespace VPet_Simulator.Windows
try
{
#endif
- if (SavesLoad(new LPS(File.ReadAllText(latestsave))))
- return;
- //MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate());
+ if (SavesLoad(new LPS(File.ReadAllText(latestsave))))
+ return;
+ //MessageBoxX.Show("存档损毁,无法加载该存档\n可能是上次储存出错或Steam云同步导致的\n请在设置中加载备份还原存档", "存档损毁".Translate());
#if !DEBUG
}
catch (Exception ex)
diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
index 0ef0e16..5fbc503 100644
--- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
+++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml
@@ -396,10 +396,7 @@
ToolTip="{ll:Str '重新开始新游戏,重置统计等信息\
对于想要获得脱离超模从而获得成就非常有帮助'}" Click="restart_click" />
-
+ Click="cleancache_click" Content="{ll:Str 清理缓存}" ToolTip="{ll:Str '清理缓存的动画,声音文件'}" />
diff --git a/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml b/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml
new file mode 100644
index 0000000..e0bdda9
--- /dev/null
+++ b/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ :
+
+
+
+
diff --git a/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs b/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs
new file mode 100644
index 0000000..3523d96
--- /dev/null
+++ b/VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs
@@ -0,0 +1,54 @@
+using Steamworks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace VPet_Simulator.Windows.WinDesign;
+///
+/// winMutiPlayer.xaml 的交互逻辑
+///
+public partial class winMutiPlayer : Window
+{
+ Steamworks.Data.Lobby lb;
+ MainWindow mw;
+ public winMutiPlayer(MainWindow mw, ulong? lobbyid = null)
+ {
+ InitializeComponent();
+ this.mw = mw;
+ if (lobbyid == null)
+ CreateLobby();
+ else
+ JoinLobby(lobbyid);
+ }
+ public async void JoinLobby(ulong? lobbyid)
+ {
+ lb = (await SteamMatchmaking.JoinLobbyAsync((SteamId)lobbyid)).Value;
+ }
+ public async void CreateLobby()
+ {
+ lb = (await SteamMatchmaking.CreateLobbyAsync()).Value;
+ lb.SetJoinable(true);
+ lb.SetPublic();
+
+ }
+ public void ShowLobbyInfo()
+ {
+ hostName.Text = lb.Owner.Name;
+ }
+
+ private void Window_Closed(object sender, EventArgs e)
+ {
+ lb.Leave();
+ mw.winMutiPlayer = null;
+ }
+}