mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
联机功能预备 + 修复工作问题
This commit is contained in:
parent
8a797fd4e4
commit
78b84adf32
@ -156,6 +156,7 @@ namespace VPet_Simulator.Core
|
||||
labeldisplaytimer.Start();
|
||||
});
|
||||
}
|
||||
public Work NowWork;
|
||||
/// <summary>
|
||||
/// 根据消耗计算相关数据
|
||||
/// </summary>
|
||||
@ -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
|
||||
/// 当前状态
|
||||
/// </summary>
|
||||
public WorkingState State = WorkingState.Nomal;
|
||||
/// <summary>
|
||||
/// 当前状态辅助ID
|
||||
/// </summary>
|
||||
public int StateID = 0;
|
||||
/// <summary>
|
||||
/// 当前工作
|
||||
/// </summary>
|
||||
public GraphHelper.Work nowWork => Core.Graph.GraphConfig.Works[StateID];
|
||||
|
||||
/// <summary>
|
||||
/// 当前正在的状态
|
||||
/// </summary>
|
||||
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
/// <summary>
|
||||
/// 停止工作
|
||||
/// </summary>
|
||||
/// <param name="then"></param>
|
||||
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)
|
||||
{
|
||||
|
@ -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
|
||||
/// 加载游戏
|
||||
/// </summary>
|
||||
/// <param name="Path">MOD地址</param>
|
||||
public async void GameLoad(List<DirectoryInfo> Path)
|
||||
public async Task GameLoad(List<DirectoryInfo> 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)
|
||||
|
@ -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<DirectoryInfo> Path = new List<DirectoryInfo>();
|
||||
@ -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()
|
||||
{
|
||||
|
@ -397,9 +397,6 @@
|
||||
<Button x:Name="btn_cleancache" Grid.Row="1" Grid.Column="2" Margin="4" Padding="1"
|
||||
pu:ButtonHelper.CornerRadius="4" Background="{DynamicResource SecondaryLight}"
|
||||
Click="cleancache_click" Content="{ll:Str 清理缓存}" ToolTip="{ll:Str '清理缓存的动画,声音文件'}" />
|
||||
<Button Grid.Row="1" Grid.Column="2" Margin="4" Padding="1" pu:ButtonHelper.CornerRadius="4"
|
||||
Background="{DynamicResource SecondaryLight}" Click="cleancache_click"
|
||||
Content="{ll:Str 清理缓存}" ToolTip="{ll:Str '清理缓存的动画,声音文件'}" />
|
||||
<TextBlock Margin="0,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Background="{x:Null}" TextWrapping="Wrap">
|
||||
<Run FontSize="18" FontWeight="Bold" Text="{ll:Str 桌宠多开}" /> <LineBreak />
|
||||
|
21
VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml
Normal file
21
VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml
Normal file
@ -0,0 +1,21 @@
|
||||
<Window x:Class="VPet_Simulator.Windows.WinDesign.winMutiPlayer"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:VPet_Simulator.Windows.WinDesign" mc:Ignorable="d"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF" Title="xxx的访客表"
|
||||
Height="600" Width="400" Closed="Window_Closed" FontSize="16">
|
||||
<Grid>
|
||||
<Image Margin="20" Width="80" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Source="/Res/TopLogo2019.PNG" />
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="120,20,0,0"
|
||||
Foreground="{DynamicResource DARKPrimaryDarker}">
|
||||
<Run Text="萝莉斯" FontSize="24" FontWeight="Bold" /> <Run Text="{ll:Str 的访客表}" />
|
||||
<LineBreak />
|
||||
<Run Text="{ll:Str 主持人}" />: <Run x:Name="hostName" Text="XXX" />
|
||||
</TextBlock>
|
||||
<StackPanel />
|
||||
</Grid>
|
||||
</Window>
|
54
VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs
Normal file
54
VPet-Simulator.Windows/WinDesign/winMutiPlayer.xaml.cs
Normal file
@ -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;
|
||||
/// <summary>
|
||||
/// winMutiPlayer.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user