更新工作相关逻辑

This commit is contained in:
ZouJin 2024-03-14 15:36:13 +08:00
parent 4ceb1577bb
commit ace7662d2c
4 changed files with 51 additions and 20 deletions

View File

@ -168,7 +168,7 @@ namespace VPet_Simulator.Core
if (freedrop < 1)
freedrop = 0.25 * TimePass;
else
freedrop = Math.Sqrt(freedrop) * TimePass / 2;
freedrop = Math.Min(Math.Sqrt(freedrop) * TimePass / 2, Core.Save.FeelingMax / 400);
switch (State)
{
case WorkingState.Sleep:
@ -233,18 +233,20 @@ namespace VPet_Simulator.Core
if (addhealth > 0)
Core.Save.Health += addhealth * TimePass;
var addmoney = Math.Max(0, nowwork.MoneyBase * (1.500000000 * efficiency - 0.5));
if (nowwork.Type == GraphHelper.Work.WorkType.Work)
if (nowwork.Type == Work.WorkType.Work)
Core.Save.Money += addmoney;
else
Core.Save.Exp += addmoney;
WorkTimer.GetCount += addmoney;
if (nowwork.Type == GraphHelper.Work.WorkType.Play)
if (nowwork.Type == Work.WorkType.Play)
{
LastInteractionTime = DateTime.Now;
Core.Save.FeelingChange(nowwork.Feeling * TimePass);
Core.Save.FeelingChange(-nowwork.Feeling * TimePass);
}
else
Core.Save.FeelingChange(-freedrop * nowwork.Feeling);
if (Core.Save.Mode == IGameSave.ModeType.Ill)//生病时候停止工作
WorkTimer.Stop();
break;
default://默认
//饮食等乱七八糟的消耗

View File

@ -199,6 +199,10 @@ namespace VPet_Simulator.Core
DisplayUI();
}
private Work nowWork;
/// <summary>
/// 停止工作
/// </summary>
/// <param name="then"></param>
public void Stop(Action @then = null)
{
if (m.State == Main.WorkingState.Work && nowWork != null)

View File

@ -22,7 +22,10 @@ namespace VPet_Simulator.Windows.Interface
/// <returns>工作获取效率</returns>
public static double Get(this Work work)
{
return MathPow(Math.Abs(work.MoneyBase) * (1 + work.FinishBonus / 2) + 1, 1.25);
if (work.Type == Work.WorkType.Work)
return MathPow(Math.Abs(work.MoneyBase) * (1 + work.FinishBonus / 2) + 1, 1.25);
else
return MathPow((Math.Abs(work.MoneyBase) * (1 + work.FinishBonus / 2) + 1) / 10, 1.25);
}
/// <summary>
/// 求幂(带符号)
@ -53,7 +56,10 @@ namespace VPet_Simulator.Windows.Interface
if (work.LevelLimit < 0)
work.LevelLimit = 0;
if (work.FinishBonus < 0)
return true;
work.FinishBonus = 0;
if (work.Type == Work.WorkType.Play && work.Feeling > 0)
work.Feeling *= -1;
var spend = work.Spend();
var get = work.Get();
var rel = get / spend;
@ -71,7 +77,7 @@ namespace VPet_Simulator.Windows.Interface
{
// 设置梯度下降的步长和最大迭代次数
double stepSize = 0.01;
int maxIterations = 1000;
int maxIterations = 100;
for (int i = 0; i < maxIterations; i++)
{
@ -122,12 +128,31 @@ namespace VPet_Simulator.Windows.Interface
// 如果仍然不合理,设定一个默认值
if (work.IsOverLoad())
{//TODO
work.MoneyBase = 10;
work.StrengthFood = 5;
work.StrengthDrink = 5;
work.Feeling = 5;
work.LevelLimit = 10;
{
switch (work.Type)
{
case Work.WorkType.Play:
work.MoneyBase = 18;
work.StrengthFood = 1;
work.StrengthDrink = 1.5;
work.Feeling = -1;
work.LevelLimit = 0;
break;
case Work.WorkType.Work:
work.MoneyBase = 8;
work.StrengthFood = 3.5;
work.StrengthDrink = 2.5;
work.Feeling = 1;
work.LevelLimit = 0;
break;
case Work.WorkType.Study:
work.MoneyBase = 80;
work.StrengthFood = 2;
work.StrengthDrink = 2;
work.Feeling = 3;
work.LevelLimit = 0;
break;
}
}
}

View File

@ -5,13 +5,13 @@ touchraised:|happy_px#0:|happy_py#50:|happy_sw#500:|happy_sh#200:|nomal_px#0:|no
pinch:|px#149:|py#128:|sw#56:|sh#59:|
raisepoint:|happy_x#290:|happy_y#128:|nomal_x#290:|nomal_y#128:|poorcondition_x#290:|poorcondition_y#128:|ill_x#225:|ill_y#115:|
work:|Type#Work:|Name#文案:|MoneyBase#8:|MoneyLevel#0.2:|Graph#workone:|StrengthFood#3.5:|StrengthDrink#2.5:|Feeling#1.5:|Time#60:|FinishBonus#0.1:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Work:|Name#清屏:|MoneyBase#16:|MoneyLevel#1.2:|Graph#workclean:|StrengthFood#5:|StrengthDrink#4:|Feeling#2.5:|Time#90:|FinishBonus#0.2:|LevelLimit#10:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Work:|Name#直播:|MoneyBase#30:|MoneyLevel#2.5:|Graph#worktwo:|StrengthFood#4.5:|StrengthDrink#8.5:|Feeling#3:|Time#180:|FinishBonus#0.25:|LevelLimit#20:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Study:|Name#学习:|MoneyBase#40:|MoneyLevel#3.5:|Graph#study:|StrengthFood#1.5:|StrengthDrink#2:|Feeling#3:|Time#45:|FinishBonus#0.2:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Study:|Name#研究:|MoneyBase#78:|MoneyLevel#10:|Graph#studytwo:|StrengthFood#1.5:|StrengthDrink#3.5:|Feeling#4:|Time#75:|FinishBonus#0.4:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|LevelLimit#15:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Play:|Name#玩游戏:|MoneyBase#20:|MoneyLevel#2.9:|Graph#playone:|StrengthFood#1:|StrengthDrink#0.5:|Feeling#4:|Time#30:|FinishBonus#0.2:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Play:|Name#删错误:|MoneyBase#20:|MoneyLevel#3:|Graph#removeobject:|StrengthFood#0.5:|StrengthDrink#0.5:|Feeling#4:|Time#60:|FinishBonus#0.25:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|LevelLimit#6:|
work:|Type#Work:|Name#文案:|MoneyBase#8:|Graph#workone:|StrengthFood#3.5:|StrengthDrink#2.5:|Feeling#1:|Time#60:|FinishBonus#0.1:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Work:|Name#清屏:|MoneyBase#16:|Graph#workclean:|StrengthFood#5:|StrengthDrink#5:|Feeling#2.5:|Time#90:|FinishBonus#0.2:|LevelLimit#10:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Work:|Name#直播:|MoneyBase#28:|Graph#worktwo:|StrengthFood#5:|StrengthDrink#10:|Feeling#4:|Time#180:|FinishBonus#0.25:|LevelLimit#20:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Study:|Name#学习:|MoneyBase#80:|Graph#study:|StrengthFood#2:|StrengthDrink#2:|Feeling#3:|Time#45:|FinishBonus#0.2:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Study:|Name#研究:|MoneyBase#120:|Graph#studytwo:|StrengthFood#2.5:|StrengthDrink#3.5:|Feeling#4:|Time#75:|FinishBonus#0.4:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|LevelLimit#15:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Play:|Name#玩游戏:|MoneyBase#18:|Graph#playone:|StrengthFood#1:|StrengthDrink#1.5:|Feeling#-1:|Time#30:|FinishBonus#0.2:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|
work:|Type#Play:|Name#删错误:|MoneyBase#20:|Graph#removeobject:|StrengthFood#0.5:|StrengthDrink#0.5:|Feeling#-1:|Time#60:|FinishBonus#0.25:|BorderBrush#000000:|Background#413d39:|ButtonBackground#322e2b:|ButtonForeground#FFFFFF:|Foreground#ccbdad:|Left#113:|Top#315:|Width#280:|LevelLimit#6:|
move:|graph#climb.left:|LocateType#Left:|LocateLength#145:|TriggerLeft#100:|TriggerTop#200:|TriggerType#65:|CheckType#64:|CheckTop#100:|SpeedY#-10:|Distance#7:|ModeType#14:|
move:|graph#climb.left:|LocateType#Left:|LocateLength#145:|TriggerLeft#100:|TriggerBottom#200:|TriggerType#129:|CheckType#128:|CheckBottom#100:|SpeedY#10:|Distance#7:|ModeType#14:|
move:|graph#climb.right:|LocateType#Right:|LocateLength#185:|TriggerRight#100:|TriggerTop#200:|TriggerType#66:|CheckType#64:|CheckTop#100:|SpeedY#-10:|Distance#7:|ModeType#14:|