mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
同步游戏数据
This commit is contained in:
parent
7fa99f1e70
commit
969d52c2f7
@ -49,9 +49,9 @@
|
||||
</Button.ContentTemplate>
|
||||
</Button>
|
||||
<TextBlock x:Name="till" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#FF4C4C"
|
||||
Text="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" TextWrapping="Wrap" />
|
||||
Text="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" TextWrapping="Wrap" x:FieldModifier="public" />
|
||||
<TextBlock x:Name="tfun" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#4caf50"
|
||||
Text="{ll:Str 已关闭数据计算\, 可放心挂机}" TextWrapping="Wrap" />
|
||||
Text="{ll:Str 已关闭数据计算\, 可放心挂机}" TextWrapping="Wrap" x:FieldModifier="public" />
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" Text="{ll:Str 金钱}" />
|
||||
<TextBlock x:Name="tMoney" Grid.Row="2" Grid.Column="2" Foreground="{DynamicResource DARKPrimary}"
|
||||
Text="$100,000" />
|
||||
|
@ -63,7 +63,9 @@ namespace VPet_Simulator.Core
|
||||
if (m.StartWork(w))
|
||||
Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载默认工作
|
||||
/// </summary>
|
||||
public void LoadWork()
|
||||
{
|
||||
LoadClean();
|
||||
@ -156,8 +158,10 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
StartWork(wplay);
|
||||
}
|
||||
|
||||
private void M_TimeUIHandle(Main m)
|
||||
/// <summary>
|
||||
/// 刷新显示UI
|
||||
/// </summary>
|
||||
public void M_TimeUIHandle(Main m)
|
||||
{
|
||||
if (BdrPanel.Visibility == Visibility.Visible)
|
||||
{
|
||||
|
@ -867,6 +867,10 @@ namespace VPet_Simulator.Windows
|
||||
SteamFriends.SetRichPresence("steam_player_group", winMutiPlayer.LobbyID.ToString("x"));
|
||||
SteamFriends.SetRichPresence("steam_player_group_size", winMutiPlayer.lb.MemberCount.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
SteamFriends.SetRichPresence("steam_player_group_size", "0");
|
||||
}
|
||||
if (App.MainWindows.Count > 1)
|
||||
{
|
||||
if (App.MainWindows.FirstOrDefault() != this)
|
||||
|
@ -167,20 +167,35 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
|
||||
Main.Event_TouchHead += Main_Event_TouchHead;
|
||||
Main.Event_TouchBody += Main_Event_TouchBody;
|
||||
SteamMatchmaking.OnLobbyMemberDataChanged += SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void SteamMatchmaking_OnLobbyMemberDataChanged(Lobby lobby, Friend friend)
|
||||
{
|
||||
if (lobby.Id == lb.Id && friend.Id == this.friend.Id)
|
||||
{
|
||||
string tmp = lb.GetMemberData(friend, "save");
|
||||
if (!string.IsNullOrEmpty(tmp))
|
||||
{
|
||||
Core.Save = GameSave_VPet.Load(new Line(tmp));
|
||||
Main.ToolBar.M_TimeUIHandle(Main);
|
||||
Main.ToolBar.tfun.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Main_Event_TouchHead()
|
||||
{
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000);
|
||||
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
|
||||
msg.SetContent(Interact.TouchHead);
|
||||
wmp.SendMessageALL(msg);
|
||||
}
|
||||
private void Main_Event_TouchBody()
|
||||
{
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000);
|
||||
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
|
||||
msg.SetContent(Interact.TouchBody);
|
||||
wmp.SendMessageALL(msg);
|
||||
@ -253,15 +268,15 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
petloader ??= Pets[0];
|
||||
|
||||
|
||||
////加载数据合理化:食物
|
||||
//foreach (Food f in Foods)
|
||||
//{
|
||||
// if (f.IsOverLoad())
|
||||
// {
|
||||
// f.Price = Math.Max((int)f.RealPrice, 1);
|
||||
// f.isoverload = false;
|
||||
// }
|
||||
//}
|
||||
//加载数据合理化:食物
|
||||
foreach (Food f in Foods)
|
||||
{
|
||||
if (f.IsOverLoad())
|
||||
{
|
||||
f.Price = Math.Max((int)f.RealPrice, 1);
|
||||
f.isoverload = false;
|
||||
}
|
||||
}
|
||||
await Dispatcher.InvokeAsync(new Action(() =>
|
||||
{
|
||||
LoadingText.Content = "尝试加载动画和生成缓存\n该步骤可能会耗时比较长\n请耐心等待".Translate();
|
||||
@ -277,6 +292,14 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
Main.Load_2_TouchEvent();
|
||||
Task.Run(Main.Load_24_WaitAndStart);
|
||||
|
||||
Main.ToolBar.MenuInteract.Items.Clear();
|
||||
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "摸头".Translate(), Main.DisplayTouchHead);
|
||||
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "摸身体".Translate(), Main.DisplayTouchBody);
|
||||
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "捏脸".Translate(), () => DisplayPinch());
|
||||
|
||||
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "退出访客表".Translate(), wmp.Close);
|
||||
Main.ToolBar.tfun.Visibility = Visibility.Collapsed;
|
||||
|
||||
Main.EventTimer.AutoReset = false;
|
||||
Main.EventTimer.Enabled = false;
|
||||
|
||||
@ -373,7 +396,7 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
return false;
|
||||
}
|
||||
Main.CountNomal = 0;
|
||||
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000);
|
||||
if (Main.DisplayType.Name == "pinch")
|
||||
{
|
||||
if (Main.DisplayType.Animat == AnimatType.A_Start)
|
||||
@ -396,19 +419,12 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
}
|
||||
private void DisplayPinch_loop()
|
||||
{
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000);
|
||||
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
|
||||
msg.SetContent(Interact.TouchPinch);
|
||||
wmp.SendMessageALL(msg);
|
||||
if (Main.isPress && Main.DisplayType.Name == "pinch" && Main.DisplayType.Animat == AnimatType.B_Loop)
|
||||
{
|
||||
if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < 100)
|
||||
{
|
||||
Core.Save.StrengthChange(-2);
|
||||
Core.Save.FeelingChange(1);
|
||||
Core.Save.Mode = Core.Save.CalMode();
|
||||
Main.LabelDisplayShowChangeNumber(LocalizeCore.Translate("体力-{0:f0} 心情+{1:f0}"), 2, 1);
|
||||
}
|
||||
{
|
||||
Main.Display("pinch", AnimatType.B_Loop, DisplayPinch_loop);
|
||||
}
|
||||
else
|
||||
@ -509,7 +525,7 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
{
|
||||
case Interact.TouchHead:
|
||||
case Interact.TouchBody:
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
|
||||
break;
|
||||
case Interact.TouchPinch:
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name));
|
||||
@ -521,15 +537,15 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
{
|
||||
case Interact.TouchHead:
|
||||
DisplayNOCALTouchHead();
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
|
||||
break;
|
||||
case Interact.TouchBody:
|
||||
DisplayNOCALTouchBody();
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
|
||||
break;
|
||||
case Interact.TouchPinch:
|
||||
DisplayNOCALTouchPinch();
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name));
|
||||
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 5000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -631,6 +647,7 @@ public partial class MPFriends : WindowX, IMPFriend
|
||||
}
|
||||
}
|
||||
}
|
||||
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||
winMPBetterBuy?.Close();
|
||||
Main?.Dispose();
|
||||
mw.Windows.Remove(this);
|
||||
|
@ -7,10 +7,10 @@
|
||||
mc:Ignorable="d" Margin="5" Width="340" Height="100" Background="{DynamicResource SecondaryLight}"
|
||||
BorderBrush="{DynamicResource Secondary}">
|
||||
<Grid>
|
||||
<pu:ContentControlX HorizontalAlignment="Left" Margin="4" CornerRadius="43">
|
||||
<pu:ContentControlX HorizontalAlignment="Left" Margin="12" CornerRadius="35">
|
||||
<Image x:Name="uimg" Source="/Res/TopLogo2019.PNG" />
|
||||
</pu:ContentControlX>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="100,0,0,0"
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="90,0,0,0"
|
||||
Foreground="{DynamicResource DARKPrimaryDarker}" FontSize="16">
|
||||
<Run Text="{ll:Str 访客}" />: <Run x:Name="rPetName" Text="{ll:Str 萝莉斯}" FontSize="20" FontWeight="Bold" />
|
||||
<LineBreak />
|
||||
|
@ -201,9 +201,9 @@ namespace VPet_Simulator.Windows
|
||||
mf.DisplayFoodAnimation(item.GetGraph(), item.ImageSource);
|
||||
|
||||
if (EnableFunction)
|
||||
mf.Main.LabelDisplayShow("{0}花费${3}\n给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price));
|
||||
mf.Main.LabelDisplayShow("{0}花费${3}\n给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price), 10000);
|
||||
else
|
||||
mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName));
|
||||
mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 10000);
|
||||
|
||||
var msg = new MPMessage()
|
||||
{
|
||||
|
@ -136,6 +136,7 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined;
|
||||
SteamMatchmaking.OnLobbyMemberLeave += SteamMatchmaking_OnLobbyMemberLeave;
|
||||
SteamMatchmaking.OnLobbyDataChanged += SteamMatchmaking_OnLobbyDataChanged;
|
||||
|
||||
Steamworks.Data.Image? img = await lb.Owner.GetMediumAvatarAsync();
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
@ -154,6 +155,7 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
|
||||
//给自己动画添加绑定
|
||||
mw.Main.GraphDisplayHandler += Main_GraphDisplayHandler;
|
||||
mw.Main.TimeHandle += Main_TimeHandle;
|
||||
if (IsHost)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
@ -196,6 +198,11 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
});
|
||||
}
|
||||
|
||||
private void Main_TimeHandle(Main obj)
|
||||
{
|
||||
lb.SetMemberData("save", mw.GameSavesData.GameSave.ToLine().ToString());
|
||||
}
|
||||
|
||||
private void SteamMatchmaking_OnLobbyDataChanged(Lobby lobby)
|
||||
{
|
||||
if (lb.Id == lobby.Id)
|
||||
@ -341,17 +348,17 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
switch (interact)
|
||||
{
|
||||
case Interact.TouchHead:
|
||||
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name));
|
||||
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000);
|
||||
if (isok)
|
||||
DisplayNOCALTouchHead();
|
||||
break;
|
||||
case Interact.TouchBody:
|
||||
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name));
|
||||
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000);
|
||||
if (isok)
|
||||
DisplayNOCALTouchBody();
|
||||
break;
|
||||
case Interact.TouchPinch:
|
||||
mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name));
|
||||
mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 5000);
|
||||
if (isok)
|
||||
DisplayNOCALTouchPinch();
|
||||
break;
|
||||
@ -373,7 +380,7 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
mw.DisplayFoodAnimation(feed.Item.GetGraph(), feed.Item.ImageSource);
|
||||
if (feed.EnableFunction)
|
||||
{
|
||||
mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price));
|
||||
mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price), 10000);
|
||||
//对于要修改数据的物品一定要再次检查,避免联机开挂毁存档
|
||||
if (item.Price >= 10 && item.Price <= 1000 && item.Health >= 0 && item.Exp >= 0 && item.Likability >= 0 && giveprice < 1000)
|
||||
{//单次联机收礼物上限1000
|
||||
@ -382,7 +389,7 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
}
|
||||
}
|
||||
else
|
||||
mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName));
|
||||
mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -406,8 +413,11 @@ public partial class winMutiPlayer : Window, IMPWindows
|
||||
public event Action<ulong, MPMessage> ReceivedMessage;
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
mw.Main.TimeHandle -= Main_TimeHandle;
|
||||
mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler;
|
||||
SteamMatchmaking.OnLobbyMemberJoined -= SteamMatchmaking_OnLobbyMemberJoined;
|
||||
SteamMatchmaking.OnLobbyMemberLeave -= SteamMatchmaking_OnLobbyMemberLeave;
|
||||
SteamMatchmaking.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged;
|
||||
lb.Leave();
|
||||
for (int i = 0; i < MPFriends.Count; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user