适配 API

This commit is contained in:
milimoe 2025-12-31 01:29:42 +08:00
parent 2ccc1d718c
commit 5970feca31
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
5 changed files with 62 additions and 32 deletions

View File

@ -2,6 +2,7 @@
using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Common.Addon;
using Milimoe.FunGame.Core.Library.Constant;
using Milimoe.FunGame.Core.Model;
namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
{
@ -203,14 +204,14 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
return false;
}
public async Task UpdateBottomInfoPanel()
public async Task UpdateBottomInfoPanel(DecisionPoints dp)
{
await UI.InvokeAsync(UI.UpdateBottomInfoPanel);
await UI.InvokeAsync(async () => await UI.UpdateBottomInfoPanel(dp));
}
public async Task UpdateQueue()
public async Task UpdateQueue(DecisionPoints dp)
{
await UI.InvokeAsync(UI.UpdateLeftQueuePanelGrid);
await UI.InvokeAsync(async () => await UI.UpdateLeftQueuePanelGrid(dp));
}
public async Task UpdateCharacterPositionsOnMap()

View File

@ -59,11 +59,13 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
c.Level = clevel;
c.NormalAttack.Level = mlevel;
FunGameService.AddCharacterSkills(c, 1, slevel, slevel);
Skill skill = new (c)
foreach (Skill skillLoop in FunGameConstant.Skills)
{
Level = slevel
};
Skill skill = skillLoop.Copy();
skill.Character = c;
skill.Level = slevel;
c.Skills.Add(skill);
}
foreach (Skill skillLoop in FunGameConstant.CommonPassiveSkills)
{
Skill passive = skillLoop.Copy();
@ -168,6 +170,9 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
}
if (team1 != null && team2 != null) await Controller.SetTeamCharacters(team1.Members, team2.Members);
// 启用调试模式
_gamingQueue.IsDebug = true;
// 加载地图和绑定事件
_gamingQueue.LoadGameMap(GameMap);
_gamingQueue.UseQueueProtected = false;
@ -321,7 +326,8 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
// 检查是否有角色可以行动
Character? characterToAct = await _gamingQueue.NextCharacterAsync();
await Controller.UpdateQueue();
DecisionPoints dp = GetDP(_gamingQueue);
await Controller.UpdateQueue(dp);
await Controller.UpdateCharacterPositionsOnMap();
// 处理回合
@ -361,8 +367,9 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
double timeLapse = await _gamingQueue.TimeLapse();
totalTime += timeLapse;
nextDropItemTime -= timeLapse;
await Controller.UpdateBottomInfoPanel();
await Controller.UpdateQueue();
dp = GetDP(_gamingQueue);
await Controller.UpdateBottomInfoPanel(dp);
await Controller.UpdateQueue(dp);
await Controller.UpdateCharacterPositionsOnMap();
if (team1 != null && team2 != null) await Controller.SetTeamCharacters(team1.Members, team2.Members);
@ -530,22 +537,22 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
return selectedTargetGrid ?? Grid.Empty;
}
private async Task GamingQueue_CharacterMove(GamingQueue queue, Character actor, Grid grid)
private async Task GamingQueue_CharacterMove(GamingQueue queue, Character actor, DecisionPoints dp, Grid grid)
{
await Controller.UpdateCharacterPositionsOnMap();
}
private async Task GamingQueue_QueueUpdated(GamingQueue queue, List<Character> characters, Character character, double hardnessTime, QueueUpdatedReason reason, string msg)
private async Task GamingQueue_QueueUpdated(GamingQueue queue, List<Character> characters, Character character, DecisionPoints dp, double hardnessTime, QueueUpdatedReason reason, string msg)
{
if (reason != QueueUpdatedReason.Action)
{
await Controller.UpdateQueue();
await Controller.UpdateQueue(dp);
}
}
private async Task<bool> GamingQueue_TurnStart(GamingQueue queue, Character character, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
private async Task<bool> GamingQueue_TurnStart(GamingQueue queue, Character character, DecisionPoints dp, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
{
await Controller.UpdateBottomInfoPanel();
await Controller.UpdateBottomInfoPanel(dp);
return true;
}
@ -608,11 +615,11 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
return selectedSkill;
}
private async Task GamingQueue_TurnEnd(GamingQueue queue, Character character)
private async Task GamingQueue_TurnEnd(GamingQueue queue, Character character, DecisionPoints dp)
{
double ht = queue.HardnessTime[character];
await Controller.SetPredictCharacter(character.NickName, ht);
await Controller.UpdateBottomInfoPanel();
await Controller.UpdateBottomInfoPanel(dp);
if (!_fastMode)
{
if (IsRoundHasPlayer_OnlyTest(queue, character))
@ -630,11 +637,12 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
else await Task.Delay(100);
}
private async Task<CharacterActionType> GamingQueue_DecideAction(GamingQueue queue, Character character, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
private async Task<CharacterActionType> GamingQueue_DecideAction(GamingQueue queue, Character character, DecisionPoints dp , List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
{
if (IsPlayer_OnlyTest(queue, character))
{
// 通过UI按钮请求行动类型
await Controller.UpdateCharacterPositionsOnMap();
CharacterActionType actionType = await Controller.RequestActionType(character, items);
await Controller.ResolveActionType(actionType);
return actionType;
@ -642,6 +650,21 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
return CharacterActionType.None; // 非玩家角色由AI处理或默认None
}
private static DecisionPoints GetDP(GamingQueue queue)
{
if (queue.CustomData.TryGetValue("player", out object? value) && value is Character player)
{
if (queue.CharacterDecisionPoints.TryGetValue(player, out DecisionPoints? dp) && dp != null)
{
return dp;
}
dp = new();
queue.CharacterDecisionPoints[player] = dp;
return dp;
}
return new();
}
private static bool IsPlayer_OnlyTest(GamingQueue queue, Character current)
{
return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && player == current && !queue.IsCharacterInAIControlling(current);

View File

@ -1,5 +1,6 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Runtime.Intrinsics.Arm;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
@ -48,6 +49,8 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
// 新增用于移动目标选择UI的ObservableCollection
public ObservableCollection<Grid> SelectedTargetGrid { get; set; } = [];
public DecisionPoints DP { get; set; } = new();
// 新增:倒计时相关的字段
private int _remainingCountdownSeconds;
private Action<bool>? _currentContinueCallback;
@ -301,7 +304,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
private static void OnCurrentCharacterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
GameMapViewer viewer = (GameMapViewer)d;
_ = viewer.UpdateBottomInfoPanel();
_ = viewer.UpdateBottomInfoPanel(viewer.DP);
_ = viewer.UpdateCharacterStatisticsPanel(); // 角色改变时也更新统计面板
// 角色改变时,清除装备/状态/技能/物品描述和高亮
viewer.ResetDescriptionAndHighlights(); // 使用新的重置方法
@ -311,7 +314,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
private static void OnCharacterQueueDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
GameMapViewer viewer = (GameMapViewer)d;
_ = viewer.UpdateLeftQueuePanelGrid();
_ = viewer.UpdateLeftQueuePanelGrid(viewer.DP);
}
// 新增当CharacterStatistics属性改变时更新数据统计面板
@ -583,15 +586,16 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
/// <summary>
/// 更新左侧动态队列面板显示角色及其AT Delay。
/// </summary>
public async Task UpdateLeftQueuePanelGrid()
public async Task UpdateLeftQueuePanelGrid(DecisionPoints dp)
{
// 确保在UI线程上执行
if (!this.Dispatcher.CheckAccess())
{
await this.Dispatcher.InvokeAsync(async () => await UpdateLeftQueuePanelGrid());
await this.Dispatcher.InvokeAsync(async () => await UpdateLeftQueuePanelGrid(dp));
return;
}
DP = dp;
CharacterQueueItems.Clear(); // 清除现有项
if (CharacterQueueData != null)
@ -612,15 +616,17 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
/// <summary>
/// 更新底部信息面板显示当前角色的详细信息、装备和状态。
/// </summary>
public async Task UpdateBottomInfoPanel()
public async Task UpdateBottomInfoPanel(DecisionPoints dp)
{
// 确保在UI线程上执行
if (!this.Dispatcher.CheckAccess())
{
await this.Dispatcher.InvokeAsync(async () => await UpdateBottomInfoPanel());
await this.Dispatcher.InvokeAsync(async () => await UpdateBottomInfoPanel(dp));
return;
}
DP = dp;
// 每次更新面板时,清除所有描述和高亮
ResetDescriptionAndHighlights(true);
@ -1352,7 +1358,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
);
if (result == MessageBoxResult.Yes)
{
_resolveActionType.Invoke(GamingQueue.GetActionType(0.33, 0.33, 0.34));
_resolveActionType.Invoke(GamingQueue.GetActionType(DP, 0.33, 0.33, 0.34));
}
else
{

View File

@ -90,13 +90,13 @@ Console.ReadKey();
while (true)
{
await FunGameSimulation.StartSimulationGame(true, true, true, true, useStore: false);
await FunGameSimulation.StartSimulationGame(true, false, true, false, useStore: false);
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key == ConsoleKey.Escape)
{
break;
}
await FunGameSimulation.StartSimulationGame(true, false, false, true);
await FunGameSimulation.StartSimulationGame(true, false, false, false);
key = Console.ReadKey();
if (key.Key == ConsoleKey.Escape)
{

View File

@ -397,7 +397,7 @@ namespace Milimoe.FunGame.Testing.Tests
}
}
private static async Task GamingQueue_QueueUpdated(GamingQueue queue, List<Character> characters, Character character, double hardnessTime, QueueUpdatedReason reason, string msg)
private static async Task GamingQueue_QueueUpdated(GamingQueue queue, List<Character> characters, Character character, DecisionPoints dp, double hardnessTime, QueueUpdatedReason reason, string msg)
{
if (IsPlayer_OnlyTest(queue, character))
{
@ -418,7 +418,7 @@ namespace Milimoe.FunGame.Testing.Tests
await Task.CompletedTask;
}
private static async Task<bool> GamingQueue_TurnStart(GamingQueue queue, Character character, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
private static async Task<bool> GamingQueue_TurnStart(GamingQueue queue, Character character, DecisionPoints dp, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
{
if (IsPlayer_OnlyTest(queue, character))
{
@ -634,7 +634,7 @@ namespace Milimoe.FunGame.Testing.Tests
return skill;
}
private static async Task GamingQueue_TurnEnd(GamingQueue queue, Character character)
private static async Task GamingQueue_TurnEnd(GamingQueue queue, Character character, DecisionPoints dp)
{
if (IsRoundHasPlayer_OnlyTest(queue, character))
{
@ -645,7 +645,7 @@ namespace Milimoe.FunGame.Testing.Tests
await Task.CompletedTask;
}
private static async Task<CharacterActionType> GamingQueue_DecideAction(GamingQueue queue, Character character, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
private static async Task<CharacterActionType> GamingQueue_DecideAction(GamingQueue queue, Character character, DecisionPoints dp, List<Character> enemys, List<Character> teammates, List<Skill> skills, List<Item> items)
{
CharacterActionType type = CharacterActionType.None;
if (IsPlayer_OnlyTest(queue, character))