From 5970feca3104797e2b9a7aa87bbbf7d9e7d68040 Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 31 Dec 2025 01:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Desktop/GameMapTesting/GameMapController.cs | 9 ++-- Desktop/GameMapTesting/GameMapTesting.cs | 53 ++++++++++++++------ Desktop/GameMapTesting/GameMapViewer.xaml.cs | 20 +++++--- Library/Main.cs | 4 +- Library/Tests/FunGame.cs | 8 +-- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/Desktop/GameMapTesting/GameMapController.cs b/Desktop/GameMapTesting/GameMapController.cs index d6ff61a..8a3abac 100644 --- a/Desktop/GameMapTesting/GameMapController.cs +++ b/Desktop/GameMapTesting/GameMapController.cs @@ -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() diff --git a/Desktop/GameMapTesting/GameMapTesting.cs b/Desktop/GameMapTesting/GameMapTesting.cs index 1d0329a..da95bc8 100644 --- a/Desktop/GameMapTesting/GameMapTesting.cs +++ b/Desktop/GameMapTesting/GameMapTesting.cs @@ -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 - }; - c.Skills.Add(skill); + 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 characters, Character character, double hardnessTime, QueueUpdatedReason reason, string msg) + private async Task GamingQueue_QueueUpdated(GamingQueue queue, List 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 GamingQueue_TurnStart(GamingQueue queue, Character character, List enemys, List teammates, List skills, List items) + private async Task GamingQueue_TurnStart(GamingQueue queue, Character character, DecisionPoints dp, List enemys, List teammates, List skills, List 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 GamingQueue_DecideAction(GamingQueue queue, Character character, List enemys, List teammates, List skills, List items) + private async Task GamingQueue_DecideAction(GamingQueue queue, Character character, DecisionPoints dp , List enemys, List teammates, List skills, List 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); diff --git a/Desktop/GameMapTesting/GameMapViewer.xaml.cs b/Desktop/GameMapTesting/GameMapViewer.xaml.cs index f782484..f578f0e 100644 --- a/Desktop/GameMapTesting/GameMapViewer.xaml.cs +++ b/Desktop/GameMapTesting/GameMapViewer.xaml.cs @@ -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 SelectedTargetGrid { get; set; } = []; + public DecisionPoints DP { get; set; } = new(); + // 新增:倒计时相关的字段 private int _remainingCountdownSeconds; private Action? _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 /// /// 更新左侧动态队列面板,显示角色及其AT Delay。 /// - 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 /// /// 更新底部信息面板显示当前角色的详细信息、装备和状态。 /// - 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 { diff --git a/Library/Main.cs b/Library/Main.cs index 9f92dbd..c5d8969 100644 --- a/Library/Main.cs +++ b/Library/Main.cs @@ -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) { diff --git a/Library/Tests/FunGame.cs b/Library/Tests/FunGame.cs index fc261c2..6fd7249 100644 --- a/Library/Tests/FunGame.cs +++ b/Library/Tests/FunGame.cs @@ -397,7 +397,7 @@ namespace Milimoe.FunGame.Testing.Tests } } - private static async Task GamingQueue_QueueUpdated(GamingQueue queue, List characters, Character character, double hardnessTime, QueueUpdatedReason reason, string msg) + private static async Task GamingQueue_QueueUpdated(GamingQueue queue, List 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 GamingQueue_TurnStart(GamingQueue queue, Character character, List enemys, List teammates, List skills, List items) + private static async Task GamingQueue_TurnStart(GamingQueue queue, Character character, DecisionPoints dp, List enemys, List teammates, List skills, List 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 GamingQueue_DecideAction(GamingQueue queue, Character character, List enemys, List teammates, List skills, List items) + private static async Task GamingQueue_DecideAction(GamingQueue queue, Character character, DecisionPoints dp, List enemys, List teammates, List skills, List items) { CharacterActionType type = CharacterActionType.None; if (IsPlayer_OnlyTest(queue, character))