支持喂食和数据计算

This commit is contained in:
ZouJin 2023-06-08 21:44:41 +10:00
parent e18417618e
commit c451f83eb0
12 changed files with 177 additions and 80 deletions

View File

@ -100,6 +100,7 @@ namespace VPet_Simulator.Core
else else
lowStrengthFood(); lowStrengthFood();
Core.Save.StrengthChangeFood(-TimePass); Core.Save.StrengthChangeFood(-TimePass);
Core.Save.StrengthChangeDrink(-TimePass);
break; break;
case WorkingState.WorkONE: case WorkingState.WorkONE:
//工作 //工作
@ -114,20 +115,21 @@ namespace VPet_Simulator.Core
Core.Save.Health -= TimePass; Core.Save.Health -= TimePass;
} }
lowStrengthFood(); lowStrengthFood();
var addmoney = TimePass * 10; var addmoney = TimePass * 5;
Core.Save.Money += addmoney; Core.Save.Money += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
else else
{ {
Core.Save.StrengthChange(TimePass); Core.Save.StrengthChangeFood(TimePass);
if (Core.Save.StrengthFood >= 75) if (Core.Save.StrengthFood >= 75)
Core.Save.Health += TimePass; Core.Save.Health += TimePass;
var addmoney = TimePass * 20; var addmoney = TimePass * (10 + Core.Save.Level / 2);
Core.Save.Money += addmoney; Core.Save.Money += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
Core.Save.StrengthChangeFood(-TimePass * 3); Core.Save.StrengthChangeFood(-TimePass * 3);
Core.Save.StrengthChangeDrink(-TimePass);
break; break;
case WorkingState.WorkTWO: case WorkingState.WorkTWO:
//工作2 更加消耗体力 //工作2 更加消耗体力
@ -142,7 +144,7 @@ namespace VPet_Simulator.Core
Core.Save.Health -= TimePass; Core.Save.Health -= TimePass;
} }
lowStrengthFood(); lowStrengthFood();
var addmoney = TimePass * 20; var addmoney = TimePass * 10;
Core.Save.Money += addmoney; Core.Save.Money += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
@ -150,11 +152,12 @@ namespace VPet_Simulator.Core
{ {
if (Core.Save.StrengthFood >= 75) if (Core.Save.StrengthFood >= 75)
Core.Save.Health += TimePass; Core.Save.Health += TimePass;
var addmoney = TimePass * 50; var addmoney = TimePass * (20 + Core.Save.Level);
Core.Save.Money += addmoney; Core.Save.Money += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
Core.Save.StrengthChangeFood(-TimePass * 5); Core.Save.StrengthChangeFood(-TimePass * 4);
Core.Save.StrengthChangeDrink(-TimePass * 6);
break; break;
case WorkingState.Study: case WorkingState.Study:
//学习 //学习
@ -169,7 +172,7 @@ namespace VPet_Simulator.Core
Core.Save.Health -= TimePass; Core.Save.Health -= TimePass;
} }
lowStrengthFood(); lowStrengthFood();
var addmoney = TimePass * 12; var addmoney = TimePass * 6;
Core.Save.Exp += addmoney; Core.Save.Exp += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
@ -178,12 +181,13 @@ namespace VPet_Simulator.Core
Core.Save.StrengthChange(TimePass); Core.Save.StrengthChange(TimePass);
if (Core.Save.StrengthFood >= 75) if (Core.Save.StrengthFood >= 75)
Core.Save.Health += TimePass; Core.Save.Health += TimePass;
var addmoney = TimePass * 25; var addmoney = TimePass * (15 + Core.Save.Level);
Core.Save.Exp += addmoney; Core.Save.Exp += addmoney;
WorkTimer.GetCount += addmoney; WorkTimer.GetCount += addmoney;
} }
Core.Save.StrengthChangeFood(-TimePass * 3); Core.Save.StrengthChangeFood(-TimePass * 3);
break; Core.Save.StrengthChangeDrink(-TimePass * 2);
goto default;
default://默认 default://默认
//饮食等乱七八糟的消耗 //饮食等乱七八糟的消耗
if (Core.Save.StrengthFood >= 50) if (Core.Save.StrengthFood >= 50)
@ -197,10 +201,10 @@ namespace VPet_Simulator.Core
Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass; Core.Save.Health -= Function.Rnd.Next(0, 1) * TimePass;
} }
Core.Save.StrengthChangeFood(-TimePass * 2); Core.Save.StrengthChangeFood(-TimePass * 2);
Core.Save.StrengthChangeDrink(-TimePass);
break; break;
} }
//if (Core.GameSave.Strength <= 40) //if (Core.GameSave.Strength <= 40)
//{ //{
// Core.GameSave.Health -= Function.Rnd.Next(0, 1); // Core.GameSave.Health -= Function.Rnd.Next(0, 1);
@ -247,7 +251,7 @@ namespace VPet_Simulator.Core
if (Core.Controller.EnableFunction) if (Core.Controller.EnableFunction)
{ {
FunctionSpend(0.1); FunctionSpend(0.05);
} }
else else
{ {

View File

@ -7,6 +7,7 @@ using System.Timers;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System.Windows.Threading; using System.Windows.Threading;
using LinePutScript;
namespace VPet_Simulator.Core namespace VPet_Simulator.Core
{ {
@ -266,28 +267,38 @@ namespace VPet_Simulator.Core
private void Study_Click(object sender, RoutedEventArgs e) private void Study_Click(object sender, RoutedEventArgs e)
{ {
this.Visibility = Visibility.Collapsed; this.Visibility = Visibility.Collapsed;
if (m.Core.Save.Mode != GameSave.ModeType.Ill) if (!m.Core.Controller.EnableFunction || m.Core.Save.Mode != GameSave.ModeType.Ill)
if (m.State == Main.WorkingState.Study) if (m.State == Main.WorkingState.Study)
m.WorkTimer.Stop(); m.WorkTimer.Stop();
else m.WorkTimer.Start(Main.WorkingState.Study); else m.WorkTimer.Start(Main.WorkingState.Study);
else
MessageBoxX.Show($"您的桌宠 {m.Core.Save.Name} 生病啦,没法进行学习", "工作取消");
} }
private void Work1_Click(object sender, RoutedEventArgs e) private void Work1_Click(object sender, RoutedEventArgs e)
{ {
this.Visibility = Visibility.Collapsed; this.Visibility = Visibility.Collapsed;
if (m.Core.Save.Mode != GameSave.ModeType.Ill) if (!m.Core.Controller.EnableFunction || m.Core.Save.Mode != GameSave.ModeType.Ill)
if (m.State == Main.WorkingState.WorkONE) if (m.State == Main.WorkingState.WorkONE)
m.WorkTimer.Stop(); m.WorkTimer.Stop();
else m.WorkTimer.Start(Main.WorkingState.WorkONE); else m.WorkTimer.Start(Main.WorkingState.WorkONE);
else
MessageBoxX.Show($"您的桌宠 {m.Core.Save.Name} 生病啦,没法进行工作{m.Core.Graph.GraphConfig.Str[(gstr)"work1"]}", "工作取消");
} }
private void Work2_Click(object sender, RoutedEventArgs e) private void Work2_Click(object sender, RoutedEventArgs e)
{ {
this.Visibility = Visibility.Collapsed; this.Visibility = Visibility.Collapsed;
if (m.Core.Save.Mode != GameSave.ModeType.Ill)
if (!m.Core.Controller.EnableFunction || m.Core.Save.Mode != GameSave.ModeType.Ill)
if (!m.Core.Controller.EnableFunction || m.Core.Save.Level >= 10)
if (m.State == Main.WorkingState.WorkTWO) if (m.State == Main.WorkingState.WorkTWO)
m.WorkTimer.Stop(); m.WorkTimer.Stop();
else m.WorkTimer.Start(Main.WorkingState.WorkTWO); else m.WorkTimer.Start(Main.WorkingState.WorkTWO);
else
MessageBoxX.Show($"您的桌宠等级不足{m.Core.Save.Level}/10\n无法进行工作{m.Core.Graph.GraphConfig.Str[(gstr)"work2"]}", "工作取消");
else
MessageBoxX.Show($"您的桌宠 {m.Core.Save.Name} 生病啦,没法进行工作{m.Core.Graph.GraphConfig.Str[(gstr)"work2"]}", "工作取消");
} }
} }
} }

View File

@ -50,11 +50,29 @@ namespace VPet_Simulator.Core
if (Visibility == Visibility.Hidden) return; if (Visibility == Visibility.Hidden) return;
TimeSpan ts = DateTime.Now - StartTime; TimeSpan ts = DateTime.Now - StartTime;
TimeSpan tleft; TimeSpan tleft;
if (ts.TotalMinutes > MaxTime)//基本上不可能,加个这个作为容错 if (ts.TotalMinutes > MaxTime)
{ {
ts = TimeSpan.FromMinutes(MaxTime); //学完了,停止
tleft = TimeSpan.Zero; //ts = TimeSpan.FromMinutes(MaxTime);
PBLeft.Value = MaxTime; //tleft = TimeSpan.Zero;
//PBLeft.Value = MaxTime;
switch (m.State)
{
case Main.WorkingState.Study:
m.Core.Save.Money += GetCount * 0.2;
Stop(() => m.Say($"学习完成啦, 累计学会了 {(GetCount * 1.2):f2} EXP\n共计花费了{MaxTime}分钟"));
break;
case Main.WorkingState.WorkONE:
m.Core.Save.Money += GetCount * 0.15;
Stop(() => m.Say($"{m.Core.Graph.GraphConfig.Str[(gstr)"work1"]}完成啦, 累计赚了 {GetCount * 1.15:f2} 金钱\n共计花费了{MaxTime}分钟"));
break;
case Main.WorkingState.WorkTWO:
m.Core.Save.Money += GetCount * 0.25;
Stop(() => m.Say($"{m.Core.Graph.GraphConfig.Str[(gstr)"work2"]}完成啦, 累计赚了 {GetCount * 1.25:f2} 金钱\n共计花费了{MaxTime}分钟"));
break;
}
return;
} }
else else
{ {
@ -163,7 +181,6 @@ namespace VPet_Simulator.Core
m.State = state; m.State = state;
StartTime = DateTime.Now; StartTime = DateTime.Now;
GetCount = 0; GetCount = 0;
new UIStyleConfig().SetStyle(this);
switch (state) switch (state)
{ {
case Main.WorkingState.Study: case Main.WorkingState.Study:

View File

@ -1,6 +1,7 @@
using LinePutScript; using LinePutScript;
using LinePutScript.Converter; using LinePutScript.Converter;
using System; using System;
using System.Windows.Forms;
namespace VPet_Simulator.Core namespace VPet_Simulator.Core
{ {
@ -26,13 +27,13 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 等级 /// 等级
/// </summary> /// </summary>
public int Level => (int)(Math.Sqrt(Exp) / 5) + 1; public int Level => (int)(Math.Sqrt(Exp) / 10) + 1;
/// <summary> /// <summary>
/// 升级所需经验值 /// 升级所需经验值
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public int LevelUpNeed() => (int)(Math.Pow((Level) * 5, 2)); public int LevelUpNeed() => (int)(Math.Pow((Level) * 10, 2));
/// <summary> /// <summary>
/// 体力 0-100 /// 体力 0-100
/// </summary> /// </summary>
@ -56,7 +57,20 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 饱腹度 /// 饱腹度
/// </summary> /// </summary>
public double StrengthFood { get => strengthFood; set => strengthFood = Math.Min(100, Math.Max(0, value)); } public double StrengthFood
{
get => strengthFood; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthFood = 0;
}
else
strengthFood = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)] [Line(Type = LPSConvert.ConvertType.ToFloat)]
private double strengthFood; private double strengthFood;
/// <summary> /// <summary>
@ -76,7 +90,20 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 口渴度 /// 口渴度
/// </summary> /// </summary>
public double StrengthDrink { get => strengthDrink; set => strengthDrink = Math.Min(100, Math.Max(0, value)); } public double StrengthDrink
{
get => strengthDrink; set
{
value = Math.Min(100, value);
if (value <= 0)
{
Health += value;
strengthDrink = 0;
}
else
strengthDrink = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)] [Line(Type = LPSConvert.ConvertType.ToFloat)]
private double strengthDrink; private double strengthDrink;
@ -125,54 +152,68 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 好感度(隐藏)(累加值) /// 好感度(隐藏)(累加值)
/// </summary> /// </summary>
public double Likability { get => likability; set => likability = Math.Min(90 + Level * 10, Math.Max(0, value)); } public double Likability
{
get => likability; set
{
int max = 90 + Level * 10;
value = Math.Max(0, value);
if (value > max)
{
likability = max;
Health += value - max;
}
else
likability = value;
}
}
[Line(Type = LPSConvert.ConvertType.ToFloat)] [Line(Type = LPSConvert.ConvertType.ToFloat)]
private double likability; private double likability;
private int cleantick = 10;
/// <summary> /// <summary>
/// 清除变化 /// 清除变化
/// </summary> /// </summary>
public void CleanChange(bool force = false) public void CleanChange()
{
if (--cleantick <= 0 || force)
{ {
ChangeStrength /= 2; ChangeStrength /= 2;
ChangeFeeling /= 2; ChangeFeeling /= 2;
ChangeStrengthDrink /= 2; ChangeStrengthDrink /= 2;
ChangeStrengthFood /= 2; ChangeStrengthFood /= 2;
cleantick = 10;
}
} }
/// <summary> /// <summary>
/// 取回被储存的体力 /// 取回被储存的体力
/// </summary> /// </summary>
public void StoreTake() public void StoreTake()
{ {
StoreFeeling /= 2; const int t = 10;
var s = StoreFeeling / t;
StoreFeeling -= s;
if (Math.Abs(StoreFeeling) < 1) if (Math.Abs(StoreFeeling) < 1)
StoreFeeling = 0; StoreFeeling = 0;
else else
FeelingChange(StoreFeeling); FeelingChange(s);
StoreStrength /= 2; s = StoreStrength / t;
StoreStrength -= s;
if (Math.Abs(StoreStrength) < 1) if (Math.Abs(StoreStrength) < 1)
StoreStrength = 0; StoreStrength = 0;
else else
StrengthChange(StoreStrength); StrengthChange(s);
StoreStrengthDrink /= 2; s = StoreStrengthDrink / t;
StoreStrengthDrink -= s;
if (Math.Abs(StoreStrengthDrink) < 1) if (Math.Abs(StoreStrengthDrink) < 1)
StoreStrengthDrink = 0; StoreStrengthDrink = 0;
else else
StrengthChange(StoreStrengthDrink); StrengthChangeDrink(s);
StoreStrengthFood /= 2; s = StoreStrengthFood / t;
StoreStrengthFood -= s;
if (Math.Abs(StoreStrengthFood) < 1) if (Math.Abs(StoreStrengthFood) < 1)
StoreStrengthFood = 0; StoreStrengthFood = 0;
else else
StrengthChange(StoreStrengthFood); StrengthChangeFood(s);
} }
/// <summary> /// <summary>
/// 吃食物 /// 吃食物

View File

@ -58,7 +58,7 @@ namespace VPet_Simulator.Windows
public int PressLength => mw.Set.PressLength; public int PressLength => mw.Set.PressLength;
public bool EnableFunction => false;// mw.Set.EnableFunction; public bool EnableFunction => mw.Set.EnableFunction;
public int InteractionCycle => mw.Set.InteractionCycle; public int InteractionCycle => mw.Set.InteractionCycle;

View File

@ -33,7 +33,7 @@ namespace VPet_Simulator.Windows
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>
public int verison { get; } = 20; public int verison { get; } = 21;
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>
@ -56,7 +56,12 @@ namespace VPet_Simulator.Windows
if (Set != null) if (Set != null)
{ {
if (Main != null) if (Main != null)
{
Set.VoiceVolume = Main.PlayVoiceVolume; Set.VoiceVolume = Main.PlayVoiceVolume;
List<string> list = new List<string>();
Foods.FindAll(x => x.Star).ForEach(x => list.Add(x.Name));
Set["betterbuy"]["star"].info = string.Join(",", list);
}
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", Set.ToString()); File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", Set.ToString());
} }
if (Core != null && Core.Save != null) if (Core != null && Core.Save != null)

View File

@ -275,14 +275,14 @@ namespace VPet_Simulator.Windows
//this.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Res/TopLogo2019.PNG"))); //this.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Res/TopLogo2019.PNG")));
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "喂食测试", () => //Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "喂食测试", () =>
{ // {
Main.ToolBar.Visibility = Visibility.Collapsed; // Main.ToolBar.Visibility = Visibility.Collapsed;
IRunImage eat = (IRunImage)Core.Graph.FindGraph(GraphType.Eat, GameSave.ModeType.Nomal); // IRunImage eat = (IRunImage)Core.Graph.FindGraph(GraphType.Eat, GameSave.ModeType.Nomal);
var b = Main.FindDisplayBorder(eat); // var b = Main.FindDisplayBorder(eat);
eat.Run(b, new BitmapImage(new Uri("pack://application:,,,/Res/汉堡.png")), Main.DisplayToNomal); // eat.Run(b, new BitmapImage(new Uri("pack://application:,,,/Res/汉堡.png")), Main.DisplayToNomal);
} // }
); //);
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "吃饭", () => Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "吃饭", () =>
{ {
winBetterBuy.Show(Food.FoodType.Meal); winBetterBuy.Show(Food.FoodType.Meal);
@ -357,14 +357,14 @@ namespace VPet_Simulator.Windows
Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining); Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining);
}); });
} }
else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 5, 26)) else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 6, 8))
{ {
if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4)) // if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4))
notifyIcon.ShowBalloonTip(10, "更新通知 05/26", // notifyIcon.ShowBalloonTip(10, "更新通知 05/26",
"支持外置消息窗/时钟等窗口\n新增语音插件,请在设置中MOD管理开启", ToolTipIcon.Info); //"支持外置消息窗/时钟等窗口\n新增语音插件,请在设置中MOD管理开启", ToolTipIcon.Info);
else // else
notifyIcon.ShowBalloonTip(10, "更新通知 06/01", notifyIcon.ShowBalloonTip(10, "更新通知 06/08",
"支持外置消息窗/时钟等窗口", ToolTipIcon.Info); "现已支持数据计算,桌宠现在需要进行吃饭喝水等\n前往设置调整速率和关闭数据计算\n若有游戏数据设计上的反馈,欢迎加群虚拟主播模拟器430081239或使用反馈功能反馈", ToolTipIcon.Info);
Set["SingleTips"].SetDateTime("update", DateTime.Now); Set["SingleTips"].SetDateTime("update", DateTime.Now);
} }
Save(); Save();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -251,8 +251,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource> </Resource>
<Resource Include="Res\TopLogo2019.PNG" /> <Resource Include="Res\TopLogo2019.PNG" />
<Resource Include="Res\tony.bmp" />
<Resource Include="Res\汉堡.png" />
<Content Include="steam_api.dll"> <Content Include="steam_api.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

View File

@ -6,7 +6,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:local="clr-namespace:VPet_Simulator.Windows" xmlns:pu="https://opensource.panuon.com/wpf-ui" xmlns:local="clr-namespace:VPet_Simulator.Windows"
mc:Ignorable="d" Title="更好买" Height="450" Width="800" FontSize="14" WindowStartupLocation="CenterScreen" mc:Ignorable="d" Title="更好买" Height="450" Width="800" FontSize="14" WindowStartupLocation="CenterScreen"
Background="#E0F6FF" pu:WindowXCaption.Height="45" pu:WindowXCaption.Background="{DynamicResource DARKPrimary}" Background="#E0F6FF" pu:WindowXCaption.Height="45" pu:WindowXCaption.Background="{DynamicResource DARKPrimary}"
pu:WindowXCaption.Foreground="#FFFFFF" pu:WindowXCaption.Buttons="Close" Topmost="True" pu:WindowXCaption.Foreground="#FFFFFF" pu:WindowXCaption.Buttons="Close"
pu:WindowXCaption.ShadowColor="{DynamicResource ShadowColor}" Closing="WindowX_Closing"> pu:WindowXCaption.ShadowColor="{DynamicResource ShadowColor}" Closing="WindowX_Closing">
<pu:WindowXCaption.CloseButtonStyle> <pu:WindowXCaption.CloseButtonStyle>
<Style TargetType="Button" BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}"> <Style TargetType="Button" BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}">
@ -26,8 +26,9 @@
<Grid Margin="10,0"> <Grid Margin="10,0">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Button Style="{DynamicResource TextButtonStyle}" Foreground="{DynamicResource DARKPrimaryText}" <Button Style="{DynamicResource TextButtonStyle}" Foreground="{DynamicResource DARKPrimaryText}"
Content="更好买" VerticalAlignment="Center" FontSize="20" Click="BtnTitle_Click" /> Content="更好买" VerticalAlignment="Center" FontSize="20" Click="BtnTitle_Click"
<Grid Grid.Column="1" Margin="15,0,0,0" Width="200"> pu:WindowX.IsDragMoveArea="False" Margin="15,0,0,0"/>
<Grid Grid.Column="1" Margin="15,0,0,0" Width="200" pu:WindowX.IsDragMoveArea="False">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -179,7 +180,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="2*" /> <RowDefinition Height="2*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="商品分类" FontSize="18" Margin="10" Foreground="{DynamicResource DARKPrimary}" /> <TextBlock Text="商品分类" FontSize="18" Margin="5" Foreground="{DynamicResource DARKPrimary}" />
<ListBox x:Name="LsbCategory" Grid.Row="1" Margin="-12,10,-12,0" Background="Transparent" <ListBox x:Name="LsbCategory" Grid.Row="1" Margin="-12,10,-12,0" Background="Transparent"
BorderThickness="0" SelectedIndex="0" pu:ListBoxHelper.ItemsPadding="15,8" BorderThickness="0" SelectedIndex="0" pu:ListBoxHelper.ItemsPadding="15,8"
pu:ListBoxHelper.ItemsSelectedBackground="{DynamicResource DARKPrimary}" pu:ListBoxHelper.ItemsSelectedBackground="{DynamicResource DARKPrimary}"
@ -193,7 +194,7 @@
<ListBoxItem Content="功能性" /> <ListBoxItem Content="功能性" />
<ListBoxItem Content="药品" /> <ListBoxItem Content="药品" />
</ListBox> </ListBox>
<TextBlock Grid.Row="2" Text="排序方式" Margin="10" FontSize="18" Foreground="{DynamicResource DARKPrimary}" /> <TextBlock Grid.Row="2" Text="排序方式" Margin="5" FontSize="18" Foreground="{DynamicResource DARKPrimary}" />
<Border Grid.Row="3" Margin="0,10,0,0" MinHeight="100" CornerRadius="5"> <Border Grid.Row="3" Margin="0,10,0,0" MinHeight="100" CornerRadius="5">
<Grid VerticalAlignment="Top"> <Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>

View File

@ -1,4 +1,5 @@
using Panuon.WPF; using IWshRuntimeLibrary;
using Panuon.WPF;
using Panuon.WPF.UI; using Panuon.WPF.UI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -40,15 +41,16 @@ namespace VPet_Simulator.Windows
} }
public void Show(Food.FoodType type) public void Show(Food.FoodType type)
{ {
mw.Topmost = false;
LsbCategory.SelectedIndex = (int)type; LsbCategory.SelectedIndex = (int)type;
//OrderItemSource(type, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex); //OrderItemSource(type, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex);
Show(); Show();
} }
public void OrderItemSource(Food.FoodType type, int sortrule, bool sortasc) public void OrderItemSource(Food.FoodType type, int sortrule, bool sortasc, string searchtext = null)
{ {
Task.Run(() => Task.Run(() =>
{ {
IList<Food> foods; List<Food> foods;
switch (type) switch (type)
{ {
case Food.FoodType.Food: case Food.FoodType.Food:
@ -70,6 +72,10 @@ namespace VPet_Simulator.Windows
foods = mw.Foods.FindAll(x => x.Type == type); foods = mw.Foods.FindAll(x => x.Type == type);
break; break;
} }
if (!string.IsNullOrEmpty(searchtext))
{
foods = foods.FindAll(x => x.Name.Contains(searchtext));
}
IOrderedEnumerable<Food> ordered; IOrderedEnumerable<Food> ordered;
switch (sortrule) switch (sortrule)
{ {
@ -139,12 +145,28 @@ namespace VPet_Simulator.Windows
private void BtnBuy_Click(object sender, RoutedEventArgs e) private void BtnBuy_Click(object sender, RoutedEventArgs e)
{ {
this.Hide();
var Button = sender as Button; var Button = sender as Button;
var item = Button.DataContext as Food; var item = Button.DataContext as Food;
//看是什么模式
if (mw.Set.EnableFunction)
{
if (item.Price >= mw.Core.Save.Money)
{//买不起
MessageBoxX.Show($"您没有足够金钱来购买 {item.Name}\n您需要 {item.Price:f2} 金钱来购买\n您当前 {mw.Core.Save.Money:f2} 拥有金钱"
, "金钱不足");
return;
}
//开始加点
mw.Core.Save.EatFood(item);
mw.Core.Save.Money -= item.Price;
}
this.Hide();
IRunImage eat = (IRunImage)mw.Core.Graph.FindGraph(GraphType.Eat, GameSave.ModeType.Nomal); IRunImage eat = (IRunImage)mw.Core.Graph.FindGraph(GraphType.Eat, GameSave.ModeType.Nomal);
var b = mw.Main.FindDisplayBorder(eat); var b = mw.Main.FindDisplayBorder(eat);
eat.Run(b, item.ImageSource, mw.Main.DisplayToNomal); eat.Run(b, item.ImageSource, mw.Main.DisplayToNomal);
} }
private void BtnSearch_Click(object sender, RoutedEventArgs e) private void BtnSearch_Click(object sender, RoutedEventArgs e)
@ -160,11 +182,7 @@ namespace VPet_Simulator.Windows
private void Search() private void Search()
{ {
var searchText = _searchTextBox.Text; OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex == 0, _searchTextBox.Text);
var category = LsbCategory.SelectedIndex;
var sortRule = LsbSortRule.SelectedIndex;
var sortAsc = LsbSortAsc.SelectedIndex == 0;
//搜索商品
} }
private void TbTitleSearch_Loaded(object sender, RoutedEventArgs e) private void TbTitleSearch_Loaded(object sender, RoutedEventArgs e)
@ -180,12 +198,14 @@ namespace VPet_Simulator.Windows
bool asc = LsbSortAsc.SelectedIndex == 0; bool asc = LsbSortAsc.SelectedIndex == 0;
mw.Set["betterbuy"].SetInt("lastorder", order); mw.Set["betterbuy"].SetInt("lastorder", order);
mw.Set["betterbuy"].SetBool("lastasc", asc); mw.Set["betterbuy"].SetBool("lastasc", asc);
OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, order, asc); OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, order, asc, _searchTextBox?.Text);
} }
private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
mw.Topmost = mw.Set.TopMost;
e.Cancel = true; e.Cancel = true;
IcCommodity.ItemsSource = null;
Hide(); Hide();
} }
} }