联机支持关闭互动功能

This commit is contained in:
ZouJin 2024-03-22 23:13:27 +08:00
parent faf789c139
commit 2d9c4d89d8
8 changed files with 37 additions and 31 deletions

View File

@ -44,7 +44,7 @@ public interface IMPWindows
/// </summary>
/// <param name="friendid">好友id</param>
/// <param name="msg">消息内容(数据包)</param>
void SendMessage(ulong friendid, MPMessage msg);
bool SendMessage(ulong friendid, MPMessage msg);
/// <summary>
/// 给所有人发送消息

View File

@ -190,7 +190,7 @@ public partial class MPFriends : WindowX, IMPFriend
Main.ToolBar.M_TimeUIHandle(Main);
Main.ToolBar.tfun.Visibility = Visibility.Collapsed;
}
if (lb.GetMemberData(friend, "onmod") == "true")
if (lb.GetMemberData(friend, "notouch") == "true")
{
NoTouchTrue();
}
@ -214,14 +214,14 @@ public partial class MPFriends : WindowX, IMPFriend
private void Main_Event_TouchHead()
{
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 3000);
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), 5000);
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 3000);
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
msg.SetContent(Interact.TouchBody);
wmp.SendMessageALL(msg);
@ -371,7 +371,7 @@ public partial class MPFriends : WindowX, IMPFriend
HideForDesign.Children.Remove(MPTalkBox);
Main.ToolBar.MainGrid.Children.Add(MPTalkBox);
if (lb.GetMemberData(friend, "onmod") == "true")
if (lb.GetMemberData(friend, "notouch") == "true")
{
NoTouchTrue();
}
@ -441,6 +441,8 @@ public partial class MPFriends : WindowX, IMPFriend
Loaded = true;
}));
}
public winMPBetterBuy winMPBetterBuy;
public void ShowBetterBuy(Food.FoodType foodType)
@ -478,7 +480,7 @@ public partial class MPFriends : WindowX, IMPFriend
return false;
}
Main.CountNomal = 0;
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 3000);
if (Main.DisplayType.Name == "pinch")
{
if (Main.DisplayType.Animat == AnimatType.A_Start)
@ -501,7 +503,7 @@ public partial class MPFriends : WindowX, IMPFriend
}
private void DisplayPinch_loop()
{
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 3000);
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
msg.SetContent(Interact.TouchPinch);
wmp.SendMessageALL(msg);
@ -607,7 +609,7 @@ public partial class MPFriends : WindowX, IMPFriend
{
case Interact.TouchHead:
case Interact.TouchBody:
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break;
case Interact.TouchPinch:
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name));
@ -619,15 +621,15 @@ public partial class MPFriends : WindowX, IMPFriend
{
case Interact.TouchHead:
DisplayNOCALTouchHead();
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break;
case Interact.TouchBody:
DisplayNOCALTouchBody();
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break;
case Interact.TouchPinch:
DisplayNOCALTouchPinch();
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 5000);
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 3000);
break;
}
}
@ -643,7 +645,7 @@ public partial class MPFriends : WindowX, IMPFriend
Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close));
Task.Run(() =>
{
Thread.Sleep(5000);
Thread.Sleep(3000);
if (Loaded)
Dispatcher.Invoke(Close);
});
@ -811,8 +813,8 @@ public partial class MPFriends : WindowX, IMPFriend
public void ReSetLocal()
{
Main.CleanState();
Main.DisplayToNomal();
Main?.CleanState();
Main?.DisplayToNomal();
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
}

View File

@ -202,9 +202,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), 10000);
mf.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price), 6000);
else
mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 10000);
mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 6000);
var msg = new MPMessage()
{

View File

@ -43,6 +43,7 @@ public partial class winMutiPlayer : Window, IMPWindows
public winMutiPlayer(MainWindow mw, ulong? lobbyid = null)
{
InitializeComponent();
swAllowTouch.IsChecked = !mw.Set.MPNOTouch;
this.mw = mw;
if (lobbyid == null)
CreateLobby();
@ -276,10 +277,10 @@ public partial class winMutiPlayer : Window, IMPWindows
/// <summary>
/// 给指定好友发送消息
/// </summary>
public void SendMessage(ulong friendid, MPMessage msg)
public bool SendMessage(ulong friendid, MPMessage msg)
{
byte[] data = ConverTo(msg);
SteamNetworking.SendP2PPacket(friendid, data);
return SteamNetworking.SendP2PPacket(friendid, data);
}
/// <summary>
/// 给所有人发送消息
@ -309,8 +310,8 @@ public partial class winMutiPlayer : Window, IMPWindows
public event Action<ulong> OnMemberJoined;
private void SteamMatchmaking_OnLobbyMemberJoined(Lobby lobby, Friend friend)
{
if (lobby.Id == lb.Id)
{
if (lobby.Id == lb.Id && MPFriends.Find(x => x.friend.Id == friend.Id) == null)
{ //如果有未处理的退出,不管
Log("好友{0}已加入访客表".Translate(friend.Name));
var mpf = new MPFriends(this, mw, lb, friend);
MPFriends.Add(mpf);
@ -349,21 +350,22 @@ public partial class winMutiPlayer : Window, IMPWindows
var interact = MSG.GetContent<Interact>();
if (MSG.To == SteamClient.SteamId.Value)
{
if (mw.Set.MPNOTouch) return;
bool isok = !IMPFriend.InConvenience(mw.Main);
switch (interact)
{
case Interact.TouchHead:
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000);
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 3000);
if (isok)
DisplayNOCALTouchHead();
break;
case Interact.TouchBody:
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000);
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 3000);
if (isok)
DisplayNOCALTouchBody();
break;
case Interact.TouchPinch:
mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 5000);
mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 3000);
if (isok)
DisplayNOCALTouchPinch();
break;
@ -385,7 +387,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), 10000);
mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price), 6000);
Log("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price));
//对于要修改数据的物品一定要再次检查,避免联机开挂毁存档
if (item.Price >= 10 && item.Price <= 1000 && item.Health >= 0 && item.Exp >= 0 && item.Likability >= 0 && giveprice < 1000
@ -397,7 +399,7 @@ public partial class winMutiPlayer : Window, IMPWindows
}
else
{
mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 10000);
mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 6000);
Log("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName));
}
}
@ -545,13 +547,14 @@ public partial class winMutiPlayer : Window, IMPWindows
private void swAllowTouch_Checked(object sender, RoutedEventArgs e)
{
if (mw == null) return;
lb.SetMemberData("notouch", "true");
lb.SetMemberData("notouch", "false");
mw.Set.MPNOTouch = false;
}
private void swAllowTouch_Unchecked(object sender, RoutedEventArgs e)
{
lb.SetMemberData("notouch", "false");
mw.Set.MPNOTouch = false;
if (mw == null) return;
lb.SetMemberData("notouch", "true");
mw.Set.MPNOTouch = true;
}
}

View File

@ -63,9 +63,13 @@
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<Compile Remove="GameAssets\**" />
<Compile Remove="mod\**" />
<EmbeddedResource Remove="GameAssets\**" />
<EmbeddedResource Remove="mod\**" />
<None Remove="GameAssets\**" />
<None Remove="mod\**" />
<Page Remove="GameAssets\**" />
<Page Remove="mod\**" />
</ItemGroup>
<ItemGroup>

View File

@ -24,7 +24,6 @@
和{0}悄悄说#Whisper to {0}:|
和{0}说#Say it with {0}:|
给更好的{0}买#Buy for Better {0}:|
{0}花费${3}\n给{1}买了{2}#{0} spends ${3}\n to buy {1} for {2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#Failed to join/create Guest List, please check your internet connection or restart the game!:|
{0}的访客表#The Guest List for {0}:|
访客表已被房主{0}关闭#Guest List has been closed by Host {0}:|

View File

@ -24,7 +24,6 @@
和{0}悄悄说#和{0}悄悄说:|
和{0}说#和{0}说:|
给更好的{0}买#给更好的{0}买:|
{0}花费${3}\n给{1}买了{2}#{0}花费${3}\n给{1}买了{2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#加入/创建访客表失败,请检查网络连接或重启游戏:|
{0}的访客表#{0}的访客表:|
访客表已被房主{0}关闭#访客表已被房主{0}关闭:|

View File

@ -24,7 +24,6 @@
和{0}悄悄说#和{0}悄悄說:|
和{0}说#和{0}說:|
给更好的{0}买#給更好的{0}買:|
{0}花费${3}\n给{1}买了{2}#{0}花費${3}\n給{1}買了{2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#加入/建立訪客表失敗,請檢查網路連線或重新啟動遊戲:|
{0}的访客表#{0}的訪客表:|
访客表已被房主{0}关闭#訪客表已被屋主{0}關閉:|