状态切换播放切换动画

This commit is contained in:
ZouJin 2023-08-11 02:07:28 +10:00
parent 2c7e01db2b
commit 487d4039d7
4 changed files with 46 additions and 9 deletions

View File

@ -37,7 +37,7 @@ namespace VPet_Simulator.Core
DisplaySleep(true);
return;
case WorkingState.Work:
Core.Graph.GraphConfig.Works[StateID].Display(this);
nowWork.Display(this);
return;
case WorkingState.Travel:
//TODO

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using static VPet_Simulator.Core.GraphInfo;
@ -145,7 +146,7 @@ namespace VPet_Simulator.Core
Core.Save.FeelingChange(-freedrop / 2);
break;
case WorkingState.Work:
var nowwork = Core.Graph.GraphConfig.Works[StateID];
var nowwork = nowWork;
var needfood = TimePass * nowwork.StrengthFood;
var needdrink = TimePass * nowwork.StrengthDrink;
double efficiency = 0;
@ -261,15 +262,39 @@ namespace VPet_Simulator.Core
var newmod = Core.Save.CalMode();
if (Core.Save.Mode != newmod)
{
//TODO:切换显示动画
//切换显示动画
playSwitchAnimat(Core.Save.Mode, newmod);
Core.Save.Mode = newmod;
//看情况播放停止工作动画
if (newmod == GameSave.ModeType.Ill && State != WorkingState.Nomal && State != WorkingState.Sleep)
if (newmod == GameSave.ModeType.Ill && State == WorkingState.Work)
{
WorkTimer.Stop();
}
}
}
private void playSwitchAnimat(GameSave.ModeType before, GameSave.ModeType after)
{
if (DisplayType.Type != GraphType.Default)
{
return;
}
else if (before == after)
{
DisplayToNomal();
return;
}
else if (before < after)
{
Display(Core.Graph.FindGraph(Core.Graph.FindName(GraphType.Switch_Down), AnimatType.Single, before),
() => playSwitchAnimat((GameSave.ModeType)(((int)before) + 1), after));
}
else
{
Display(Core.Graph.FindGraph(Core.Graph.FindName(GraphType.Switch_Up), AnimatType.Single, before),
() => playSwitchAnimat((GameSave.ModeType)(((int)before) - 1), after));
}
}
/// <summary>
/// 状态计算Handle
/// </summary>
@ -406,6 +431,10 @@ namespace VPet_Simulator.Core
/// </summary>
public int StateID = 0;
/// <summary>
/// 当前工作
/// </summary>
public GraphHelper.Work nowWork => Core.Graph.GraphConfig.Works[StateID];
/// <summary>
/// 当前正在的状态
/// </summary>
public enum WorkingState

View File

@ -124,23 +124,29 @@ namespace VPet_Simulator.Windows.Interface
sb.Append("健康".Translate() + ":\t").Append(Health > 0 ? "+" : "").Append(Health.ToString("f2")).Append("\t\t");
if (Likability != 0)
sb.Append("好感度".Translate() + ":\t").Append(Likability > 0 ? "+" : "").Append(Likability.ToString("f2"));
sb.AppendLine().Append(Desc.Translate());
desc = sb.ToString();
}
DateTime now = DateTime.Now;
DateTime eattime = imw.Set.PetData.GetDateTime("buytime_" + Name, now);
double eattimes = 0;
string descs;
if (eattime <= now)
{
if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink)
descs = "腻味程度".Translate();
descs = "喜好度".Translate();
else
descs = "有效度".Translate();
descs += ":\t100%";
}
else
{
eattimes = (eattime - now).TotalHours;
if (Type == FoodType.Meal || Type == FoodType.Snack || Type == FoodType.Drink)
descs = "喜好度".Translate();
else
descs = "有效度".Translate();
descs += Math.Max(0.5, 1 - Math.Pow((eattime - now).TotalHours, 2) * 0.01).ToString("p0");
descs += "\t\t" + "恢复".Translate() + ":\t" + (eattime).ToString("MM/dd HH");
}
return desc;
return desc + '\n' + descs + '\n' + Desc.Translate();
}
}
/// <summary>

View File

@ -193,6 +193,8 @@ namespace VPet_Simulator.Windows
//吃腻了
eattimes += 2;
mw.Set.PetData.SetDateTime("buytime_" + item.Name, now.AddHours(eattimes));
//通知
item.NotifyOfPropertyChange("Eattime");
mw.Core.Save.Money -= item.Price;
//统计