mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
支持宠物自己吃东西
This commit is contained in:
parent
ba568da81a
commit
25832f1862
@ -9,6 +9,7 @@ using LinePutScript.Localization.WPF;
|
||||
using static VPet_Simulator.Core.GraphInfo;
|
||||
using System.Xml.Linq;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace VPet_Simulator.Core
|
||||
{
|
||||
@ -641,5 +642,21 @@ namespace VPet_Simulator.Core
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示夹层动画
|
||||
/// </summary>
|
||||
/// <param name="Type">动画类型</param>
|
||||
/// <param name="img">夹层内容</param>
|
||||
/// <param name="EndAction">动画结束后操作</param>
|
||||
public void Display(GraphType Type, ImageSource img, Action EndAction)
|
||||
{
|
||||
var name = Core.Graph.FindName(Type);
|
||||
var ig = Core.Graph.FindGraph(name, AnimatType.Single, Core.Save.Mode);
|
||||
if (ig != null)
|
||||
{
|
||||
var b = FindDisplayBorder(ig);
|
||||
ig.Run(b, img, EndAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// 礼品 (没做)
|
||||
/// </summary>
|
||||
Gift,
|
||||
/// <summary>
|
||||
/// 不超模的好食物
|
||||
/// </summary>
|
||||
NoOverLoad,
|
||||
}
|
||||
/// <summary>
|
||||
/// 食物类型
|
||||
@ -128,7 +132,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
sb.Append("好感度".Translate() + ":\t").Append(Likability > 0 ? "+" : "").Append(Likability.ToString("f2"));
|
||||
desc = sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
return desc + '\n' + descs + '\n' + Desc.Translate();
|
||||
}
|
||||
}
|
||||
@ -145,8 +149,19 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// </summary>
|
||||
[Line(ignoreCase: true)]
|
||||
public string Image;
|
||||
|
||||
|
||||
private bool? isoverload = null;
|
||||
/// <summary>
|
||||
/// 该食物是否超模
|
||||
/// </summary>
|
||||
public bool IsOverLoad()
|
||||
{
|
||||
if (isoverload == null)
|
||||
{
|
||||
double realp = ((Exp / 4 + Strength / 5 + StrengthDrink / 3 + StrengthFood / 2 + Feeling / 6) / 3 + Health + Likability * 5);
|
||||
isoverload = Price > realp * 1.3 || Price < realp * 0.7;//30%容错
|
||||
}
|
||||
return isoverload.Value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载物品图片
|
||||
/// </summary>
|
||||
|
@ -415,5 +415,19 @@ namespace VPet_Simulator.Windows.Interface
|
||||
get => this["gameconfig"].GetInt("resolution", 500);
|
||||
set => this["gameconfig"].SetInt("resolution", value);
|
||||
}
|
||||
|
||||
bool autobuy;
|
||||
/// <summary>
|
||||
/// 允许桌宠自动购买食品
|
||||
/// </summary>
|
||||
public bool AutoBuy
|
||||
{
|
||||
get => autobuy;
|
||||
set
|
||||
{
|
||||
autobuy = value;
|
||||
this["gameconfig"].SetBool("allowmove", !value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using CSCore.CoreAudioAPI;
|
||||
using LinePutScript;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using Panuon.WPF.UI;
|
||||
using Steamworks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -236,7 +237,42 @@ namespace VPet_Simulator.Windows
|
||||
int lowstrengthAskCountDrink = 20;
|
||||
private void lowStrength()
|
||||
{
|
||||
if (Core.Save.Mode == GameSave.ModeType.Happy || Core.Save.Mode == GameSave.ModeType.Nomal)
|
||||
if (Set.AutoBuy && Core.Save.Money >= 100)
|
||||
{
|
||||
var havemoney = Core.Save.Money * 1.2;
|
||||
List<Food> food = Foods.FindAll(x => x.Price >= 2 && x.Health >= 0 && x.Exp >= 0 && x.Likability >= 0 && x.Price < havemoney //桌宠不吃负面的食物
|
||||
&& x.IsOverLoad() // 不吃超模食物
|
||||
);
|
||||
|
||||
if (Core.Save.StrengthFood < 75)
|
||||
{
|
||||
if (Core.Save.StrengthFood < 50)
|
||||
{//太饿了,找正餐
|
||||
food = food.FindAll(x => x.Type == Food.FoodType.Meal && x.StrengthFood > 20);
|
||||
}
|
||||
else
|
||||
{//找零食
|
||||
food = food.FindAll(x => x.Type == Food.FoodType.Snack && x.StrengthFood > 10);
|
||||
}
|
||||
if (food.Count == 0)
|
||||
return;
|
||||
var item = food[Function.Rnd.Next(food.Count)];
|
||||
Core.Save.Money -= item.Price * 1.2;
|
||||
TakeItem(item);
|
||||
Main.Display(GraphType.Eat, item.ImageSource, Main.DisplayToNomal);
|
||||
}
|
||||
else if (Core.Save.StrengthDrink < 75)
|
||||
{
|
||||
food = food.FindAll(x => x.Type == Food.FoodType.Drink && x.StrengthDrink > 10);
|
||||
if (food.Count == 0)
|
||||
return;
|
||||
var item = food[Function.Rnd.Next(food.Count)];
|
||||
Core.Save.Money -= item.Price * 1.2;
|
||||
TakeItem(item);
|
||||
Main.Display(GraphType.Drink, item.ImageSource, Main.DisplayToNomal);
|
||||
}
|
||||
}
|
||||
else if (Core.Save.Mode == GameSave.ModeType.Happy || Core.Save.Mode == GameSave.ModeType.Nomal)
|
||||
{
|
||||
if (Core.Save.StrengthFood < 75 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0)
|
||||
{
|
||||
@ -339,6 +375,59 @@ namespace VPet_Simulator.Windows
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 使用/食用物品 (不包括显示动画)
|
||||
/// </summary>
|
||||
/// <param name="item">物品</param>
|
||||
public void TakeItem(Food item)
|
||||
{
|
||||
//获取吃腻时间
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime eattime = Set.PetData.GetDateTime("buytime_" + item.Name, now);
|
||||
double eattimes = 0;
|
||||
if (eattime > now)
|
||||
{
|
||||
eattimes = (eattime - now).TotalHours;
|
||||
}
|
||||
//开始加点
|
||||
Core.Save.EatFood(item, Math.Max(0.5, 1 - Math.Pow(eattimes, 2) * 0.01));
|
||||
//吃腻了
|
||||
eattimes += 2;
|
||||
Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes));
|
||||
//通知
|
||||
item.LoadEatTimeSource(this);
|
||||
item.NotifyOfPropertyChange("Eattime");
|
||||
|
||||
Core.Save.Money -= item.Price;
|
||||
//统计
|
||||
Set.Statistics[(gint)("buy_" + item.Name)]++;
|
||||
Set.Statistics[(gdbe)"stat_betterbuy"] += item.Price;
|
||||
switch (item.Type)
|
||||
{
|
||||
case Food.FoodType.Food:
|
||||
Set.Statistics[(gdbe)"stat_bb_food"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Drink:
|
||||
Set.Statistics[(gdbe)"stat_bb_drink"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Drug:
|
||||
Set.Statistics[(gdbe)"stat_bb_drug"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Snack:
|
||||
Set.Statistics[(gdbe)"stat_bb_snack"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Functional:
|
||||
Set.Statistics[(gdbe)"stat_bb_functional"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Meal:
|
||||
Set.Statistics[(gdbe)"stat_bb_meal"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Gift:
|
||||
Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RunAction(string action)
|
||||
{
|
||||
|
@ -174,9 +174,6 @@
|
||||
<Compile Include="WinDesign\winReport.xaml.cs">
|
||||
<DependentUpon>winReport.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WinDesign\winTrusteeShip.xaml.cs">
|
||||
<DependentUpon>winTrusteeShip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="PetHelper.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -234,10 +231,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WinDesign\winTrusteeShip.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Platform)' == 'x86'">
|
||||
<Reference Include="Facepunch.Steamworks.Win32, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
@ -49,16 +49,31 @@
|
||||
Click="BtnSearch_Click" />
|
||||
</Grid>
|
||||
<TextBlock VerticalAlignment="Center" Margin="20,0,0,0" FontSize="16" FontWeight="Bold">
|
||||
<Run Text="{ll:Str 金钱}" />: $ <Run x:Name="rMoney" Loaded="rMoney_Loaded" Text=""/>
|
||||
<Run Text="{ll:Str 金钱}" />: $ <Run x:Name="rMoney" Loaded="rMoney_Loaded" Text="" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<pu:Switch Content="{ll:Str 购买后不自动关闭窗口}" Grid.Column="2" FontSize="14" Margin="10,0,5,0" Height="20"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" BoxHeight="14" ToggleSize="18"
|
||||
CheckedBackground="{DynamicResource Primary}" CheckedBorderBrush="{DynamicResource Primary}"
|
||||
Background="Transparent" ToggleShadowColor="{x:Null}" IsChecked="{Binding StateOpen}"
|
||||
CheckedToggleBrush="{DynamicResource DARKPrimaryText}"
|
||||
ToggleBrush="{DynamicResource PrimaryDark}" pu:WindowX.IsDragMoveArea="False" BoxWidth="30"
|
||||
Loaded="Switch_Loaded" />
|
||||
<Grid HorizontalAlignment="Right">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<pu:Switch Content="{ll:Str 购买后不自动关闭窗口}" Grid.Column="2" FontSize="14" Margin="10,0,5,0" Height="20"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left" BoxHeight="14" ToggleSize="18"
|
||||
CheckedBackground="{DynamicResource Primary}" CheckedBorderBrush="{DynamicResource Primary}"
|
||||
Background="Transparent" ToggleShadowColor="{x:Null}" IsChecked="{Binding StateOpen}"
|
||||
CheckedToggleBrush="{DynamicResource DARKPrimaryText}"
|
||||
ToggleBrush="{DynamicResource PrimaryDark}" pu:WindowX.IsDragMoveArea="False" BoxWidth="30"
|
||||
Loaded="Switch_Loaded" />
|
||||
<pu:Switch Content="{ll:Str 让宠物自己买东西吃}" Grid.Column="2" FontSize="14" Margin="10,0,5,0" Height="20"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left" BoxHeight="14" ToggleSize="18"
|
||||
CheckedBackground="{DynamicResource Primary}" CheckedBorderBrush="{DynamicResource Primary}"
|
||||
Background="Transparent" ToggleShadowColor="{x:Null}" IsChecked="{Binding StateOpen}"
|
||||
CheckedToggleBrush="{DynamicResource DARKPrimaryText}" Grid.Row="1"
|
||||
ToggleBrush="{DynamicResource PrimaryDark}" pu:WindowX.IsDragMoveArea="False" BoxWidth="30"
|
||||
ToolTip="{ll:Str '当宠物口渴或者饥饿的时候会自己买东西吃\ 请注意,宠物可能会乱花钱和吃错误的东西\ 额外加收20%外卖运送费用'}"
|
||||
Loaded="Switch_Loaded_1" />
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</pu:WindowXCaption.HeaderTemplate>
|
||||
|
@ -193,12 +193,11 @@ namespace VPet_Simulator.Windows
|
||||
//PageDetail.RaiseEvent(eventArg);
|
||||
}
|
||||
bool showeatanm = true;
|
||||
|
||||
private void BtnBuy_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
var Button = sender as Button;
|
||||
var item = Button.DataContext as Food;
|
||||
|
||||
//看是什么模式
|
||||
if (mw.Set.EnableFunction)
|
||||
{
|
||||
@ -209,58 +208,7 @@ namespace VPet_Simulator.Windows
|
||||
, "金钱不足".Translate());
|
||||
return;
|
||||
}
|
||||
|
||||
//获取吃腻时间
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime eattime = mw.Set.PetData.GetDateTime("buytime_" + item.Name, now);
|
||||
double eattimes = 0;
|
||||
if (eattime <= now)
|
||||
{
|
||||
eattime = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
eattimes = (eattime - now).TotalHours;
|
||||
}
|
||||
//开始加点
|
||||
mw.Core.Save.EatFood(item, Math.Max(0.5, 1 - Math.Pow(eattimes, 2) * 0.01));
|
||||
//吃腻了
|
||||
eattimes += 2;
|
||||
mw.Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes));
|
||||
//通知
|
||||
item.LoadEatTimeSource(mw);
|
||||
item.NotifyOfPropertyChange(DateTime.Now.ToString());
|
||||
|
||||
mw.Core.Save.Money -= item.Price;
|
||||
//统计
|
||||
mw.Set.Statistics[(gint)("buy_" + item.Name)]++;
|
||||
mw.Set.Statistics[(gdbe)"stat_betterbuy"] += item.Price;
|
||||
switch (item.Type)
|
||||
{
|
||||
case Food.FoodType.Food:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_food"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Drink:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_drink"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Drug:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_drug"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Snack:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_snack"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Functional:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_functional"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Meal:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_meal"] += item.Price;
|
||||
break;
|
||||
case Food.FoodType.Gift:
|
||||
mw.Set.Statistics[(gdbe)"stat_bb_gift"] += item.Price;
|
||||
break;
|
||||
}
|
||||
|
||||
mw.TakeItem(item);
|
||||
}
|
||||
if (showeatanm)
|
||||
{//显示动画
|
||||
@ -278,18 +226,12 @@ namespace VPet_Simulator.Windows
|
||||
gt = GraphType.Gift;
|
||||
break;
|
||||
}
|
||||
var name = mw.Core.Graph.FindName(gt);
|
||||
var ig = mw.Core.Graph.FindGraph(name, AnimatType.Single, mw.Core.Save.Mode);
|
||||
if (ig != null)
|
||||
mw.Main.Display(gt, item.ImageSource, () =>
|
||||
{
|
||||
var b = mw.Main.FindDisplayBorder(ig);
|
||||
ig.Run(b, item.ImageSource, () =>
|
||||
{
|
||||
showeatanm = true;
|
||||
mw.Main.DisplayToNomal();
|
||||
mw.Main.EventTimer_Elapsed();
|
||||
});
|
||||
}
|
||||
showeatanm = true;
|
||||
mw.Main.DisplayToNomal();
|
||||
mw.Main.EventTimer_Elapsed();
|
||||
});
|
||||
}
|
||||
if (!_puswitch.IsChecked.Value)
|
||||
{
|
||||
@ -394,5 +336,22 @@ namespace VPet_Simulator.Windows
|
||||
rMoney = sender as Run;
|
||||
rMoney.Text = mw.Core.Save.Money.ToString("f2");
|
||||
}
|
||||
private Switch _puswitchautobuy;
|
||||
private void Switch_Loaded_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_puswitchautobuy = sender as Switch;
|
||||
_puswitchautobuy.IsChecked = mw.Set.AutoBuy;
|
||||
_puswitchautobuy.Click += Switch_AutoBuy_Checked;
|
||||
}
|
||||
private void Switch_AutoBuy_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_puswitchautobuy.IsChecked.Value && mw.Core.Save.Money < 100)
|
||||
{
|
||||
_puswitchautobuy.IsChecked = false;
|
||||
MessageBoxX.Show(mw, "余额不足100,无法开启自动购买".Translate(), "更好买".Translate());
|
||||
return;
|
||||
}
|
||||
mw.Set.AutoBuy = _puswitchautobuy.IsChecked.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
<Window x:Class="VPet_Simulator.Windows.WinDesign.winTrusteeShip"
|
||||
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="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||
Title="{ll:Str 自动托管}" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
@ -1,27 +0,0 @@
|
||||
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>
|
||||
/// winTrusteeShip.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class winTrusteeShip : Window
|
||||
{
|
||||
public winTrusteeShip()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -14,4 +14,7 @@
|
||||
使用桌宠选项式\r聊天功能#Use vpet option type\rchat function:|
|
||||
支持MOD与创意工坊添加聊天内容#Support MOD and creative workshop add chat content:|
|
||||
按经验值#Exp:|
|
||||
删错误#Delete error:|
|
||||
删错误#Delete error:|
|
||||
余额不足100,无法开启自动购买#Balance is less than 100, unable to open automatic purchase:|
|
||||
让宠物自己买东西吃#Let the pet buy self:|
|
||||
当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#When the pet is thirsty or hungry, it will buy something to eat it self\rPlease note that the pet may spend money and eat the wrong things\rExtra 20% takeout delivery fee:|
|
@ -14,4 +14,7 @@
|
||||
使用桌宠选项式\r聊天功能#使用桌宠选项式\r聊天功能:|
|
||||
支持MOD与创意工坊添加聊天内容#支持MOD与创意工坊添加聊天内容:|
|
||||
按经验值#按经验值:|
|
||||
删错误#删错误:|
|
||||
删错误#删错误:|
|
||||
余额不足100,无法开启自动购买#余额不足100,无法开启自动购买:|
|
||||
让宠物自己买东西吃#让宠物自己买东西吃:|
|
||||
当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用:|
|
@ -14,4 +14,7 @@
|
||||
使用桌宠选项式\r聊天功能#使用桌寵選項式\r聊天功能:|
|
||||
支持MOD与创意工坊添加聊天内容#支持MOD與創意工坊添加聊天內容:|
|
||||
按经验值#按經驗值:|
|
||||
删错误#刪錯誤:|
|
||||
删错误#刪錯誤:|
|
||||
余额不足100,无法开启自动购买#餘額不足100,無法開啟自動購買:|
|
||||
让宠物自己买东西吃#讓寵物自己買東西吃:|
|
||||
当宠物口渴或者饥饿的时候会自己买东西吃\r请注意,宠物可能会乱花钱和吃错误的东西\r额外加收20%外卖运送费用#當寵物口渴或者饑餓的時候會自己買東西吃\r請注意,寵物可能會亂花錢和吃錯誤的東西\r額外加收20%外賣運送費用:|
|
Loading…
Reference in New Issue
Block a user