2023-09-03 15:06:43 +00:00
|
|
|
|
using CSCore.CoreAudioAPI;
|
2023-03-13 15:40:04 +00:00
|
|
|
|
using LinePutScript;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
using LinePutScript.Dictionary;
|
2023-07-01 07:46:08 +00:00
|
|
|
|
using LinePutScript.Localization.WPF;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
using Panuon.WPF.UI;
|
2023-08-12 16:01:34 +00:00
|
|
|
|
using Steamworks;
|
2023-02-27 12:29:40 +00:00
|
|
|
|
using System;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
using System.Collections.Generic;
|
2023-02-27 12:29:40 +00:00
|
|
|
|
using System.Diagnostics;
|
2023-01-24 06:56:16 +00:00
|
|
|
|
using System.IO;
|
2023-09-10 13:52:02 +00:00
|
|
|
|
using System.Linq;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
using System.Threading;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
using System.Timers;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
using System.Web;
|
2023-04-01 19:31:28 +00:00
|
|
|
|
using System.Windows;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
using VPet_Simulator.Core;
|
2023-04-01 15:15:50 +00:00
|
|
|
|
using VPet_Simulator.Windows.Interface;
|
2023-08-25 22:08:13 +00:00
|
|
|
|
using static VPet_Simulator.Core.GraphHelper;
|
2023-07-16 23:58:09 +00:00
|
|
|
|
using static VPet_Simulator.Core.GraphInfo;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
using Timer = System.Timers.Timer;
|
2023-04-01 15:15:50 +00:00
|
|
|
|
using ToolBar = VPet_Simulator.Core.ToolBar;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
|
|
|
|
|
namespace VPet_Simulator.Windows
|
|
|
|
|
{
|
2023-04-01 15:15:50 +00:00
|
|
|
|
public partial class MainWindow : IMainWindow
|
2023-01-10 10:43:32 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly string ModPath = Environment.CurrentDirectory + @"\mod";
|
2023-04-01 19:31:28 +00:00
|
|
|
|
public bool IsSteamUser { get; }
|
|
|
|
|
public Setting Set { get; set; }
|
|
|
|
|
public List<PetLoader> Pets { get; set; } = new List<PetLoader>();
|
2023-01-10 10:43:32 +00:00
|
|
|
|
public List<CoreMOD> CoreMODs = new List<CoreMOD>();
|
2023-04-01 19:31:28 +00:00
|
|
|
|
public GameCore Core { get; set; } = new GameCore();
|
|
|
|
|
public Main Main { get; set; }
|
|
|
|
|
public UIElement TalkBox;
|
|
|
|
|
public winGameSetting winSetting { get; set; }
|
2023-06-08 08:46:53 +00:00
|
|
|
|
public winBetterBuy winBetterBuy { get; set; }
|
2023-09-03 15:06:43 +00:00
|
|
|
|
//public ChatGPTClient CGPTClient;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
public ImageResources ImageSources { get; set; } = new ImageResources();
|
2023-01-10 10:43:32 +00:00
|
|
|
|
/// <summary>
|
2023-04-01 19:31:28 +00:00
|
|
|
|
/// 所有三方插件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<MainPlugin> Plugins { get; } = new List<MainPlugin>();
|
2023-06-08 08:46:53 +00:00
|
|
|
|
public List<Food> Foods { get; } = new List<Food>();
|
2023-04-01 19:31:28 +00:00
|
|
|
|
/// <summary>
|
2023-01-10 10:43:32 +00:00
|
|
|
|
/// 版本号
|
|
|
|
|
/// </summary>
|
2023-09-17 15:49:08 +00:00
|
|
|
|
public int version { get; } = 106;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 版本号
|
|
|
|
|
/// </summary>
|
2023-08-21 04:34:50 +00:00
|
|
|
|
public string Version => $"{version / 100}.{version % 100}";
|
2023-01-10 10:43:32 +00:00
|
|
|
|
|
2023-06-18 22:20:06 +00:00
|
|
|
|
public List<LowText> LowFoodText { get; set; } = new List<LowText>();
|
|
|
|
|
|
|
|
|
|
public List<LowText> LowDrinkText { get; set; } = new List<LowText>();
|
2023-08-13 14:39:46 +00:00
|
|
|
|
|
2023-08-22 09:52:25 +00:00
|
|
|
|
public List<SelectText> SelectTexts { get; set; } = new List<SelectText>();
|
|
|
|
|
|
2023-08-13 14:39:46 +00:00
|
|
|
|
public List<ClickText> ClickTexts { get; set; } = new List<ClickText>();
|
2023-09-20 12:58:28 +00:00
|
|
|
|
|
2023-09-22 13:24:02 +00:00
|
|
|
|
public GameSave_v2 GameSavesData { get; set; }
|
2023-08-13 14:39:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得自动点击的文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>说话内容</returns>
|
|
|
|
|
public ClickText GetClickText()
|
|
|
|
|
{
|
|
|
|
|
ClickText.DayTime dt;
|
|
|
|
|
var now = DateTime.Now.Hour;
|
|
|
|
|
if (now < 6)
|
|
|
|
|
dt = ClickText.DayTime.Midnight;
|
|
|
|
|
else if (now < 12)
|
|
|
|
|
dt = ClickText.DayTime.Morning;
|
|
|
|
|
else if (now < 18)
|
|
|
|
|
dt = ClickText.DayTime.Afternoon;
|
|
|
|
|
else
|
|
|
|
|
dt = ClickText.DayTime.Night;
|
|
|
|
|
|
|
|
|
|
ClickText.ModeType mt;
|
|
|
|
|
switch (Core.Save.Mode)
|
|
|
|
|
{
|
|
|
|
|
case GameSave.ModeType.PoorCondition:
|
|
|
|
|
mt = ClickText.ModeType.PoorCondition;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case GameSave.ModeType.Nomal:
|
|
|
|
|
mt = ClickText.ModeType.Nomal;
|
|
|
|
|
break;
|
|
|
|
|
case GameSave.ModeType.Happy:
|
|
|
|
|
mt = ClickText.ModeType.Happy;
|
|
|
|
|
break;
|
|
|
|
|
case GameSave.ModeType.Ill:
|
|
|
|
|
mt = ClickText.ModeType.Ill;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var list = ClickTexts.FindAll(x => x.DaiTime.HasFlag(dt) && x.Mode.HasFlag(mt) && x.CheckState(Main));
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
return null;
|
|
|
|
|
return list[Function.Rnd.Next(list.Count)];
|
|
|
|
|
}
|
2023-08-25 22:31:44 +00:00
|
|
|
|
private Image hashcheckimg;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭该玩家的HashCheck检查
|
|
|
|
|
/// 如果你的mod属于作弊mod/有作弊内容,请在作弊前调用这个方法
|
|
|
|
|
/// </summary>
|
2023-08-25 22:31:44 +00:00
|
|
|
|
public void HashCheckOff()
|
|
|
|
|
{
|
|
|
|
|
HashCheck = false;
|
|
|
|
|
}
|
2023-08-06 02:00:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存档 Hash检查 是否通过
|
|
|
|
|
/// </summary>
|
2023-08-25 22:31:44 +00:00
|
|
|
|
public bool HashCheck
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
get => GameSavesData.HashCheck;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-22 16:18:24 +00:00
|
|
|
|
if (!value)
|
2023-09-22 13:24:02 +00:00
|
|
|
|
{
|
|
|
|
|
GameSavesData.HashCheckOff();
|
|
|
|
|
}
|
2023-08-25 22:31:44 +00:00
|
|
|
|
Main?.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (GameSavesData.HashCheck)
|
2023-08-25 22:31:44 +00:00
|
|
|
|
{
|
|
|
|
|
if (hashcheckimg == null)
|
|
|
|
|
{
|
|
|
|
|
hashcheckimg = new Image();
|
|
|
|
|
hashcheckimg.Source = new BitmapImage(new Uri("pack://application:,,,/Res/hash.png"));
|
|
|
|
|
hashcheckimg.HorizontalAlignment = HorizontalAlignment.Right;
|
|
|
|
|
hashcheckimg.ToolTip = "是没有修改过存档/使用超模MOD的玩家专属标志".Translate();
|
|
|
|
|
Grid.SetColumn(hashcheckimg, 4);
|
|
|
|
|
Grid.SetRowSpan(hashcheckimg, 2);
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Add(hashcheckimg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (hashcheckimg != null)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Remove(hashcheckimg);
|
|
|
|
|
hashcheckimg = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-10 10:43:32 +00:00
|
|
|
|
public void SetZoomLevel(double zl)
|
|
|
|
|
{
|
|
|
|
|
Set.ZoomLevel = zl;
|
2023-05-27 10:37:15 +00:00
|
|
|
|
//this.Height = 500 * zl;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
this.Width = 500 * zl;
|
2023-07-03 11:41:02 +00:00
|
|
|
|
if (petHelper != null)
|
|
|
|
|
{
|
|
|
|
|
petHelper.Width = 50 * zl;
|
|
|
|
|
petHelper.Height = 50 * zl;
|
|
|
|
|
petHelper.ReloadLocation();
|
|
|
|
|
}
|
2023-01-10 10:43:32 +00:00
|
|
|
|
}
|
2023-07-23 20:46:21 +00:00
|
|
|
|
//private DateTime timecount = DateTime.Now;
|
2023-01-24 06:56:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
2023-04-01 19:31:28 +00:00
|
|
|
|
foreach (MainPlugin mp in Plugins)
|
|
|
|
|
mp.Save();
|
2023-01-24 06:56:16 +00:00
|
|
|
|
//游戏存档
|
|
|
|
|
if (Set != null)
|
2023-05-25 17:50:38 +00:00
|
|
|
|
{
|
2023-09-22 16:59:41 +00:00
|
|
|
|
var st = Set.SaveTimesPP;
|
2023-05-27 10:37:15 +00:00
|
|
|
|
if (Main != null)
|
2023-06-08 11:44:41 +00:00
|
|
|
|
{
|
2023-05-27 10:37:15 +00:00
|
|
|
|
Set.VoiceVolume = Main.PlayVoiceVolume;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
List<string> list = new List<string>();
|
|
|
|
|
Foods.FindAll(x => x.Star).ForEach(x => list.Add(x.Name));
|
|
|
|
|
Set["betterbuy"]["star"].info = string.Join(",", list);
|
2023-09-22 13:24:02 +00:00
|
|
|
|
//GameSavesData.Statistics[(gint)"stat_time"] = (int)(DateTime.Now - timecount).TotalMinutes;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
//timecount = DateTime.Now;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
}
|
2023-09-14 11:50:36 +00:00
|
|
|
|
Set.StartRecordLastPoint = new Point(Dispatcher.Invoke(() => Left), Dispatcher.Invoke(() => Top));
|
2023-09-10 14:03:47 +00:00
|
|
|
|
File.WriteAllText(ExtensionValue.BaseDirectory + @"\Setting.lps", Set.ToString());
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-09-10 14:03:47 +00:00
|
|
|
|
if (!Directory.Exists(ExtensionValue.BaseDirectory + @"\BackUP"))
|
|
|
|
|
Directory.CreateDirectory(ExtensionValue.BaseDirectory + @"\BackUP");
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-06-22 22:09:26 +00:00
|
|
|
|
if (Core != null && Core.Save != null)
|
2023-06-23 13:15:57 +00:00
|
|
|
|
{
|
2023-09-10 14:03:47 +00:00
|
|
|
|
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\BackUP", "*.lps")).FindAll(x => x.Contains('_')).OrderBy(x =>
|
2023-09-10 13:52:02 +00:00
|
|
|
|
{
|
2023-09-22 16:37:23 +00:00
|
|
|
|
if (int.TryParse(x.Split('_')[1].Split('.')[0], out int i))
|
2023-09-10 13:52:02 +00:00
|
|
|
|
return i;
|
|
|
|
|
return 0;
|
|
|
|
|
}).ToList();
|
2023-06-23 20:08:08 +00:00
|
|
|
|
while (ds.Count > Set.BackupSaveMaxNum)
|
|
|
|
|
{
|
2023-06-23 13:15:57 +00:00
|
|
|
|
File.Delete(ds[0]);
|
2023-06-23 20:08:08 +00:00
|
|
|
|
ds.RemoveAt(0);
|
|
|
|
|
}
|
2023-09-10 14:03:47 +00:00
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps"))
|
|
|
|
|
File.Delete(ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-09-10 14:03:47 +00:00
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps"))
|
|
|
|
|
File.Move(ExtensionValue.BaseDirectory + @"\Save.lps", ExtensionValue.BaseDirectory + $"\\BackUP\\Save_{st}.lps");
|
2023-09-22 16:18:24 +00:00
|
|
|
|
|
|
|
|
|
File.WriteAllText(ExtensionValue.BaseDirectory + @"\Save.lps", GameSavesData.ToLPS().ToString());
|
2023-06-23 13:15:57 +00:00
|
|
|
|
}
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-01-24 06:56:16 +00:00
|
|
|
|
}
|
2023-04-01 19:31:28 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重载DIY按钮区域
|
|
|
|
|
/// </summary>
|
2023-02-27 12:29:40 +00:00
|
|
|
|
public void LoadDIY()
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuDIY.Items.Clear();
|
|
|
|
|
foreach (Sub sub in Set["diy"])
|
2023-05-19 08:17:51 +00:00
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.DIY, sub.Name, () =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
RunDIY(sub.Info);
|
|
|
|
|
});
|
2023-04-01 19:31:28 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//加载游戏创意工坊插件
|
|
|
|
|
foreach (MainPlugin mp in Plugins)
|
2023-04-04 16:21:46 +00:00
|
|
|
|
mp.LoadDIY();
|
2023-04-01 19:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2023-07-01 07:46:08 +00:00
|
|
|
|
new winReport(this, "由于插件引起的自定按钮加载错误".Translate() + '\n' + e.ToString()).Show();
|
2023-04-01 19:31:28 +00:00
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
2023-07-03 11:41:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载帮助器
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void LoadPetHelper()
|
2023-07-03 22:48:13 +00:00
|
|
|
|
{
|
2023-07-03 11:41:02 +00:00
|
|
|
|
petHelper = new PetHelper(this);
|
|
|
|
|
petHelper.Show();
|
|
|
|
|
}
|
2023-07-03 22:48:13 +00:00
|
|
|
|
|
2023-02-27 12:29:40 +00:00
|
|
|
|
public static void RunDIY(string content)
|
|
|
|
|
{
|
2023-04-01 15:15:50 +00:00
|
|
|
|
if (content.Contains("://") || content.Contains(@":\"))
|
2023-02-27 12:29:40 +00:00
|
|
|
|
{
|
2023-07-03 22:48:13 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Process.Start(content);
|
|
|
|
|
}
|
2023-07-12 08:37:43 +00:00
|
|
|
|
catch (Exception e)
|
2023-07-03 22:48:13 +00:00
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("快捷键运行失败:无法运行指定内容".Translate() + '\n' + e.Message);
|
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-16 10:12:25 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Forms.SendKeys.SendWait(content);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("快捷键运行失败:无法运行指定内容".Translate() + '\n' + e.Message);
|
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-01 15:15:50 +00:00
|
|
|
|
|
2023-07-16 23:58:09 +00:00
|
|
|
|
public void ShowSetting(int page = -1)
|
2023-04-01 15:15:50 +00:00
|
|
|
|
{
|
2023-07-16 23:58:09 +00:00
|
|
|
|
if (page >= 0 && page <= 6)
|
|
|
|
|
winSetting.MainTab.SelectedIndex = page;
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
}
|
|
|
|
|
public void ShowBetterBuy(Food.FoodType type)
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(type);
|
2023-04-01 15:15:50 +00:00
|
|
|
|
}
|
2023-07-12 08:37:43 +00:00
|
|
|
|
int lowstrengthAskCountFood = 20;
|
|
|
|
|
int lowstrengthAskCountDrink = 20;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
private void lowStrength()
|
|
|
|
|
{
|
2023-08-23 19:49:16 +00:00
|
|
|
|
if (Set.AutoBuy && Core.Save.Money >= 100)
|
|
|
|
|
{
|
2023-09-14 12:21:59 +00:00
|
|
|
|
var havemoney = Core.Save.Money * 1.2 - 120;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
List<Food> food = Foods.FindAll(x => x.Price >= 2 && x.Health >= 0 && x.Exp >= 0 && x.Likability >= 0 && x.Price < havemoney //桌宠不吃负面的食物
|
2023-08-23 19:50:31 +00:00
|
|
|
|
&& !x.IsOverLoad() // 不吃超模食物
|
2023-08-23 19:49:16 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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)];
|
2023-08-24 20:22:09 +00:00
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
TakeItem(item);
|
2023-08-30 15:14:41 +00:00
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
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)];
|
2023-08-24 20:22:09 +00:00
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-09-12 04:51:49 +00:00
|
|
|
|
TakeItem(item);
|
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
|
|
|
|
}
|
2023-09-13 09:29:45 +00:00
|
|
|
|
else if (Set.AutoGift && Core.Save.Feeling < 50)
|
2023-09-12 04:51:49 +00:00
|
|
|
|
{
|
|
|
|
|
food = food.FindAll(x => x.Type == Food.FoodType.Gift && x.Feeling > 10);
|
|
|
|
|
if (food.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
var item = food[Function.Rnd.Next(food.Count)];
|
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
TakeItem(item);
|
2023-08-30 15:14:41 +00:00
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Core.Save.Mode == GameSave.ModeType.Happy || Core.Save.Mode == GameSave.ModeType.Nomal)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (Core.Save.StrengthFood < 75 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0)
|
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountFood = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var txt = LowFoodText.FindAll(x => x.Mode == LowText.ModeType.H && (int)x.Like <= like);
|
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
if (Core.Save.StrengthFood > 60)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
|
|
|
|
else if (Core.Save.StrengthFood > 40)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Hunger, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Core.Save.StrengthDrink < 75 && Function.Rnd.Next(lowstrengthAskCountDrink--) == 0)
|
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountDrink = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var txt = LowDrinkText.FindAll(x => x.Mode == LowText.ModeType.H && (int)x.Like <= like);
|
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
if (Core.Save.StrengthDrink > 60)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
|
|
|
|
else if (Core.Save.StrengthDrink > 40)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Thirsty, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Core.Save.StrengthFood < 60 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0)
|
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountFood = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
|
|
|
|
var txt = LowFoodText.FindAll(x => x.Mode == LowText.ModeType.L && (int)x.Like < like);
|
|
|
|
|
if (Core.Save.StrengthFood > 40)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else if (Core.Save.StrengthFood > 20)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Hunger, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (Core.Save.StrengthDrink < 60 && Function.Rnd.Next(lowstrengthAskCountDrink--) == 0)
|
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountDrink = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
|
|
|
|
var txt = LowDrinkText.FindAll(x => x.Mode == LowText.ModeType.L && (int)x.Like < like);
|
|
|
|
|
if (Core.Save.StrengthDrink > 40)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else if (Core.Save.StrengthDrink > 20)
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2023-07-16 23:58:09 +00:00
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Thirsty, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-06-20 19:30:26 +00:00
|
|
|
|
}
|
2023-08-23 19:49:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 使用/食用物品 (不包括显示动画)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">物品</param>
|
|
|
|
|
public void TakeItem(Food item)
|
|
|
|
|
{
|
|
|
|
|
//获取吃腻时间
|
|
|
|
|
DateTime now = DateTime.Now;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
DateTime eattime = GameSavesData["buytime"].GetDateTime(item.Name, now);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
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;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
GameSavesData["buytime"].SetDateTime(item.Name, now.AddHours(eattimes));
|
2023-08-23 19:49:16 +00:00
|
|
|
|
//通知
|
|
|
|
|
item.LoadEatTimeSource(this);
|
2023-09-06 15:23:32 +00:00
|
|
|
|
item.NotifyOfPropertyChange("Description");
|
2023-08-23 19:49:16 +00:00
|
|
|
|
|
|
|
|
|
Core.Save.Money -= item.Price;
|
|
|
|
|
//统计
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)("buy_" + item.Name)]++;
|
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_betterbuy"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
switch (item.Type)
|
|
|
|
|
{
|
|
|
|
|
case Food.FoodType.Food:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_food"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Drink:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_drink"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Drug:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_drug"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Snack:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_snack"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Functional:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_functional"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Meal:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_meal"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Gift:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_gift"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 18:09:51 +00:00
|
|
|
|
|
|
|
|
|
public void RunAction(string action)
|
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case "DisplayNomal":
|
|
|
|
|
Main.DisplayNomal();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayToNomal":
|
|
|
|
|
Main.DisplayToNomal();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayTouchHead":
|
|
|
|
|
Main.DisplayTouchHead();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayTouchBody":
|
|
|
|
|
Main.DisplayTouchBody();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayIdel":
|
|
|
|
|
Main.DisplayIdel();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayIdel_StateONE":
|
|
|
|
|
Main.DisplayIdel_StateONE();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplaySleep":
|
|
|
|
|
Main.DisplaySleep();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayRaised":
|
|
|
|
|
Main.DisplayRaised();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayMove":
|
|
|
|
|
Main.DisplayMove();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-23 20:46:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Steam统计相关变化
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Statistics_StatisticChanged(Statistics sender, string name, SetObject value)
|
|
|
|
|
{
|
|
|
|
|
if (name.StartsWith("stat_"))
|
|
|
|
|
{
|
|
|
|
|
Steamworks.SteamUserStats.SetStat(name, (int)value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计算统计数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void StatisticsCalHandle()
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
var stat = GameSavesData.Statistics;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var save = Core.Save;
|
|
|
|
|
stat["stat_money"] = save.Money;
|
|
|
|
|
stat["stat_level"] = save.Level;
|
|
|
|
|
stat["stat_likability"] = save.Likability;
|
|
|
|
|
|
|
|
|
|
stat[(gi64)"stat_total_time"] += (int)Set.LogicInterval;
|
|
|
|
|
switch (Main.State)
|
|
|
|
|
{
|
|
|
|
|
case Main.WorkingState.Work:
|
2023-08-10 15:48:27 +00:00
|
|
|
|
if (Main.nowWork.Type == GraphHelper.Work.WorkType.Work)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval;
|
|
|
|
|
else
|
|
|
|
|
stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval;
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Sleep:
|
2023-08-16 04:46:20 +00:00
|
|
|
|
stat[(gi64)"stat_sleep_time"] += (int)Set.LogicInterval;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (save.Mode == GameSave.ModeType.Ill)
|
|
|
|
|
{
|
2023-08-15 07:47:49 +00:00
|
|
|
|
if (save.Money < 100)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat["stat_ill_nomoney"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Money < save.Level)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_level_g_money"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Feeling < 1)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_0_feel"] = 1;
|
|
|
|
|
if (save.StrengthDrink < 1)
|
|
|
|
|
stat["stat_0_f_sd"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Strength < 1 && save.Feeling < 1 && save.StrengthFood < 1 && save.StrengthDrink < 1)
|
|
|
|
|
stat["stat_0_all"] = 1;
|
|
|
|
|
if (save.StrengthFood < 1)
|
|
|
|
|
stat["stat_0_strengthfood"] = 1;
|
|
|
|
|
if (save.StrengthDrink < 1)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_0_strengthdrink"] = 1;
|
|
|
|
|
if (save.StrengthFood < 1)
|
|
|
|
|
stat["stat_0_sd_sf"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Strength > 99 && save.Feeling > 99 && save.StrengthFood > 99 && save.StrengthDrink > 99)
|
|
|
|
|
stat[(gint)"stat_100_all"]++;
|
|
|
|
|
|
|
|
|
|
if (IsSteamUser)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(Steamworks.SteamUserStats.StoreStats);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-30 17:44:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载游戏
|
|
|
|
|
/// </summary>
|
2023-09-22 13:24:02 +00:00
|
|
|
|
public bool GameLoad(ILPS lps)
|
2023-08-06 02:00:03 +00:00
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (lps == null)
|
2023-08-12 06:09:20 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(lps.ToString()))
|
2023-08-16 18:16:42 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSave_v2 tmp;
|
|
|
|
|
if (GameSavesData != null)
|
|
|
|
|
tmp = new GameSave_v2(lps, GameSavesData);
|
|
|
|
|
else
|
2023-09-22 16:18:24 +00:00
|
|
|
|
{
|
|
|
|
|
var data = new LPS_D();
|
|
|
|
|
foreach (var item in Set.PetData_OLD)
|
|
|
|
|
{
|
|
|
|
|
if (item.Name.Contains("_"))
|
|
|
|
|
{
|
|
|
|
|
var strs = Sub.Split(item.Name, "_", 1);
|
|
|
|
|
data[strs[0]][(gstr)strs[1]] = item.Info;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
data.Add(new Line(item.Name, item.Info));
|
|
|
|
|
}
|
|
|
|
|
tmp = new GameSave_v2(lps, Set.Statistics_OLD, olddata: data);
|
|
|
|
|
}
|
|
|
|
|
if (tmp.GameSave == null)
|
2023-08-25 22:34:31 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (tmp.GameSave.Money == 0 && tmp.GameSave.Likability == 0 && tmp.GameSave.Exp == 0
|
|
|
|
|
&& tmp.GameSave.StrengthDrink == 0 && tmp.GameSave.StrengthFood == 0)//数据全是0,可能是bug
|
|
|
|
|
return false;
|
|
|
|
|
GameSavesData = tmp;
|
|
|
|
|
Core.Save = tmp.GameSave;
|
2023-09-22 16:37:23 +00:00
|
|
|
|
HashCheck = HashCheck;
|
2023-08-12 06:09:20 +00:00
|
|
|
|
return true;
|
2023-08-06 02:00:03 +00:00
|
|
|
|
}
|
2023-08-12 16:01:34 +00:00
|
|
|
|
private void Handle_Steam(Main obj)
|
|
|
|
|
{
|
|
|
|
|
if (Core.Save.Mode == GameSave.ModeType.Ill)
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Ill");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("mode", (Core.Save.Mode.ToString() + "ly").Translate());
|
|
|
|
|
switch (obj.State)
|
|
|
|
|
{
|
|
|
|
|
case Main.WorkingState.Work:
|
|
|
|
|
SteamFriends.SetRichPresence("work", obj.nowWork.Name.Translate());
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Work");
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Sleep:
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Sleep");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (obj.DisplayType.Name == "music")
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Music");
|
|
|
|
|
else
|
2023-09-05 11:26:27 +00:00
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_IDLE");
|
2023-08-12 16:01:34 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-15 04:04:08 +00:00
|
|
|
|
private bool? AudioPlayingVolumeOK = null;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得当前系统音乐播放音量
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float AudioPlayingVolume()
|
|
|
|
|
{
|
2023-08-15 04:04:08 +00:00
|
|
|
|
if (AudioPlayingVolumeOK == null)
|
2023-08-15 06:09:48 +00:00
|
|
|
|
{//第一调用检查是否支持
|
2023-08-15 04:04:08 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
float vol = 0;
|
|
|
|
|
using (var enumerator = new MMDeviceEnumerator())
|
|
|
|
|
{
|
|
|
|
|
using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia)))
|
|
|
|
|
{
|
|
|
|
|
vol = meter.GetPeakValue();
|
|
|
|
|
AudioPlayingVolumeOK = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
AudioPlayingVolumeOK = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (AudioPlayingVolumeOK == false)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2023-08-15 06:09:48 +00:00
|
|
|
|
try
|
|
|
|
|
{//后续容错可能是偶发性
|
|
|
|
|
using (var enumerator = new MMDeviceEnumerator())
|
2023-08-10 11:34:11 +00:00
|
|
|
|
{
|
2023-08-15 06:09:48 +00:00
|
|
|
|
using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia)))
|
|
|
|
|
{
|
|
|
|
|
return meter.GetPeakValue();
|
|
|
|
|
}
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-15 06:09:48 +00:00
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 音乐检测器
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Handle_Music(Main obj)
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (MusicTimer.Enabled == false && Core.Graph.FindGraphs("music", AnimatType.B_Loop, Core.Save.Mode) != null &&
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Main.IsIdel && AudioPlayingVolume() > Set.MusicCatch)
|
|
|
|
|
{
|
|
|
|
|
catch_MusicVolSum = 0;
|
|
|
|
|
catch_MusicVolCount = 0;
|
|
|
|
|
CurrMusicType = null;
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{//等2秒看看识别结果
|
|
|
|
|
Thread.Sleep(2500);
|
|
|
|
|
|
|
|
|
|
if (CurrMusicType != null && Main.IsIdel)
|
|
|
|
|
{//识别通过,开始跑跳舞动画
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display(Core.Graph.FindGraph("music", AnimatType.A_Start, Core.Save.Mode), Display_Music);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ //失败或有东西阻塞,停止检测
|
|
|
|
|
MusicTimer.Stop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Display_Music()
|
|
|
|
|
{
|
|
|
|
|
if (CurrMusicType.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (CurrMusicType.Value)
|
|
|
|
|
{//播放更刺激的
|
2023-08-11 02:47:09 +00:00
|
|
|
|
var mg = Core.Graph.FindGraph("music", AnimatType.Single, Core.Save.Mode);
|
|
|
|
|
mg ??= Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Main.Display(mg, Display_Music);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display(Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode), Display_Music);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display("music", AnimatType.C_End, Main.DisplayToNomal);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void MusicTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (!(Main.IsIdel || Main.DisplayType.Name == "music"))//不是音乐,被掐断
|
|
|
|
|
return;
|
2023-08-10 15:48:27 +00:00
|
|
|
|
catch_MusicVolSum += AudioPlayingVolume();
|
|
|
|
|
catch_MusicVolCount++;
|
|
|
|
|
if (catch_MusicVolCount >= 20)
|
2023-08-10 11:34:11 +00:00
|
|
|
|
{
|
|
|
|
|
double ans = catch_MusicVolSum / catch_MusicVolCount;
|
2023-08-10 15:48:27 +00:00
|
|
|
|
catch_MusicVolSum /= 4;
|
|
|
|
|
catch_MusicVolCount /= 4;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
if (ans > Set.MusicCatch)
|
|
|
|
|
{
|
|
|
|
|
var bef = CurrMusicType;
|
|
|
|
|
CurrMusicType = ans > Set.MusicMax;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (bef != null && bef != CurrMusicType)
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Display_Music();
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurrMusicType = null;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (Main.DisplayType.Name == "music")
|
|
|
|
|
Main.Display("music", AnimatType.C_End, Main.DisplayToNomal);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 02:47:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
}
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Timer MusicTimer;
|
|
|
|
|
private double catch_MusicVolSum;
|
|
|
|
|
private int catch_MusicVolCount;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前音乐播放状态
|
|
|
|
|
/// </summary>
|
2023-08-10 11:34:11 +00:00
|
|
|
|
public bool? CurrMusicType { get; private set; }
|
2023-08-11 02:47:09 +00:00
|
|
|
|
|
|
|
|
|
int LastDiagnosisTime = 0;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
|
2023-08-11 02:47:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上传遥测文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DiagnosisUPLoad()
|
|
|
|
|
{
|
|
|
|
|
if (!IsSteamUser)
|
|
|
|
|
return;//不遥测非Steam用户
|
|
|
|
|
if (!Set.DiagnosisDayEnable)
|
|
|
|
|
return;//不遥测不参加遥测的用户
|
|
|
|
|
if (!Set.Diagnosis)
|
|
|
|
|
return;//不遥测不参加遥测的用户
|
|
|
|
|
if (!HashCheck)
|
|
|
|
|
return;//不遥测数据修改过的用户
|
|
|
|
|
if (LastDiagnosisTime++ < Set.DiagnosisInterval)
|
|
|
|
|
return;//等待间隔
|
|
|
|
|
LastDiagnosisTime = 0;
|
2023-08-25 17:16:54 +00:00
|
|
|
|
string _url = "http://cn.exlb.org:5810/VPET/Report";
|
2023-08-11 02:47:09 +00:00
|
|
|
|
//参数
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("action=data");
|
|
|
|
|
sb.Append($"&steamid={Steamworks.SteamClient.SteamId.Value}");
|
2023-08-21 04:34:50 +00:00
|
|
|
|
sb.Append($"&ver={version}");
|
2023-08-11 02:47:09 +00:00
|
|
|
|
sb.Append("&save=");
|
|
|
|
|
sb.AppendLine(HttpUtility.UrlEncode(Core.Save.ToLine().ToString() + Set.ToString()));
|
|
|
|
|
//游戏设置比存档更重要,桌宠大部分内容存设置里了,所以一起上传
|
|
|
|
|
var request = (HttpWebRequest)WebRequest.Create(_url);
|
|
|
|
|
request.Method = "POST";
|
|
|
|
|
request.ContentType = "application/x-www-form-urlencoded";//ContentType
|
|
|
|
|
byte[] byteData = Encoding.UTF8.GetBytes(sb.ToString());
|
|
|
|
|
int length = byteData.Length;
|
|
|
|
|
request.ContentLength = length;
|
|
|
|
|
using (Stream writer = request.GetRequestStream())
|
|
|
|
|
{
|
|
|
|
|
writer.Write(byteData, 0, length);
|
|
|
|
|
writer.Close();
|
|
|
|
|
writer.Dispose();
|
|
|
|
|
}
|
|
|
|
|
string responseString;
|
|
|
|
|
using (var response = (HttpWebResponse)request.GetResponse())
|
|
|
|
|
{
|
|
|
|
|
responseString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
|
|
|
|
response.Dispose();
|
|
|
|
|
}
|
|
|
|
|
if (responseString == "IP times Max")
|
|
|
|
|
{
|
|
|
|
|
Set.DiagnosisDayEnable = false;
|
|
|
|
|
}
|
|
|
|
|
#if DEBUG
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("诊断上传失败");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-12 07:13:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭指示器,默认为true
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool CloseConfirm { get; private set; } = true;
|
2023-09-03 18:55:41 +00:00
|
|
|
|
|
2023-09-04 08:45:32 +00:00
|
|
|
|
public List<ITalkAPI> TalkAPI { get; } = new List<ITalkAPI>();
|
2023-09-03 18:55:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前选择的对话框index
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int TalkAPIIndex = -1;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前对话框
|
|
|
|
|
/// </summary>
|
2023-09-04 08:45:32 +00:00
|
|
|
|
public ITalkAPI TalkBoxCurr
|
2023-09-03 18:55:41 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return null;
|
|
|
|
|
return TalkAPI[TalkAPIIndex];
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-04 08:45:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移除所有聊天对话框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void RemoveTalkBox()
|
|
|
|
|
{
|
|
|
|
|
if (TalkBox != null)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Remove(TalkBox);
|
|
|
|
|
TalkBox = null;
|
|
|
|
|
}
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return;
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Remove(TalkAPI[TalkAPIIndex].This);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载自定义对话框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void LoadTalkDIY()
|
|
|
|
|
{
|
|
|
|
|
RemoveTalkBox();
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return;
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Add(TalkAPI[TalkAPIIndex].This);
|
|
|
|
|
}
|
2023-08-25 22:08:13 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 超模工作检查
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool WorkCheck(Work work)
|
|
|
|
|
{
|
|
|
|
|
//看看是否超模
|
|
|
|
|
if (HashCheck && work.IsOverLoad())
|
|
|
|
|
{
|
2023-09-17 15:49:08 +00:00
|
|
|
|
var spend = ((work.StrengthFood >= 0 ? 1 : -1) * Math.Pow(work.StrengthFood * 2 + 1, 2) / 6 +
|
|
|
|
|
(work.StrengthDrink >= 0 ? 1 : -1) * Math.Pow(work.StrengthDrink * 2 + 1, 2) / 9 +
|
|
|
|
|
(work.Feeling >= 0 ? 1 : -1) * Math.Pow((work.Type == Work.WorkType.Play ? -1 : 1) * work.Feeling * 2 + 1, 2) / 12) *
|
|
|
|
|
(Math.Pow(work.LevelLimit / 2 + 1, 0.5) / 4 + 1) - 0.5;
|
2023-08-25 22:08:13 +00:00
|
|
|
|
var get = (work.MoneyBase + work.MoneyLevel * 10) * (work.MoneyLevel + 1) * (1 + work.FinishBonus / 2);
|
|
|
|
|
if (work.Type != Work.WorkType.Work)
|
|
|
|
|
{
|
|
|
|
|
get /= 12;//经验值换算
|
|
|
|
|
}
|
|
|
|
|
var rel = get / spend;
|
2023-09-17 15:49:08 +00:00
|
|
|
|
if (MessageBoxX.Show("当前工作数据属性超模,是否继续工作?\n超模工作可能会导致游戏发生不可预料的错误\n超模工作不影响大部分成就解锁\n当前数据比率 {0:f2} 推荐<1.5\n盈利速度:{1:f0} 推荐<{2}"
|
|
|
|
|
.Translate(rel, get, (work.LevelLimit + 4) * 6), "超模工作提醒".Translate(), MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
2023-08-25 22:08:13 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
HashCheck = false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-09-04 08:45:32 +00:00
|
|
|
|
|
2023-01-10 10:43:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|