diff --git a/Desktop/GameMapTesting/GameMapController.cs b/Desktop/GameMapTesting/GameMapController.cs index 06b5d38..3c9b89d 100644 --- a/Desktop/GameMapTesting/GameMapController.cs +++ b/Desktop/GameMapTesting/GameMapController.cs @@ -1,4 +1,5 @@ -using Milimoe.FunGame.Core.Entity; +using System.Threading.Tasks; +using Milimoe.FunGame.Core.Entity; using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Common.Addon; using Milimoe.FunGame.Core.Library.Constant; @@ -55,14 +56,14 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting ); } - public async Task> RequestTargetSelection(Character actor, List potentialTargets, ISkill skill, long maxTargets, bool canSelectSelf, bool canSelectEnemy, bool canSelectTeammate) + public async Task> RequestTargetSelection(Character character, ISkill skill, List enemys, List teammates) { - await WriteLine($"请为 {actor.NickName} 选择目标 (最多 {maxTargets} 个)。"); + await WriteLine($"请为 {character.NickName} 选择目标 (最多 {skill.CanSelectTargetCount} 个)。"); List targetIds = await _targetSelectionRequester.RequestInput( - (callback) => UI.Invoke(() => UI.ShowTargetSelectionUI(actor, potentialTargets, skill, maxTargets, canSelectSelf, canSelectEnemy, canSelectTeammate, callback)) + (callback) => UI.Invoke(() => UI.ShowTargetSelectionUI(character, skill, enemys, teammates, callback)) ) ?? []; if (targetIds == null) return []; - return [.. potentialTargets.Where(targetIds.Contains)]; + return [.. enemys.Where(targetIds.Contains), .. teammates.Where(targetIds.Contains)]; } public async Task RequestSkillSelection(Character character, List availableSkills) @@ -154,19 +155,19 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting return false; } - public void UpdateBottomInfoPanel() + public async Task UpdateBottomInfoPanel() { - UI.Invoke(UI.UpdateBottomInfoPanel); + await UI.Invoke(UI.UpdateBottomInfoPanel); } - public void UpdateQueue() + public async Task UpdateQueue() { - UI.Invoke(UI.UpdateLeftQueuePanel); + await UI.Invoke(UI.UpdateLeftQueuePanel); } - public void UpdateCharacterPositionsOnMap() + public async Task UpdateCharacterPositionsOnMap() { - UI.Invoke(UI.UpdateCharacterPositionsOnMap); + await UI.Invoke(UI.UpdateCharacterPositionsOnMap); } public void SetQueue(Dictionary dict) diff --git a/Desktop/GameMapTesting/GameMapTesting.cs b/Desktop/GameMapTesting/GameMapTesting.cs index 8950796..94f1f7f 100644 --- a/Desktop/GameMapTesting/GameMapTesting.cs +++ b/Desktop/GameMapTesting/GameMapTesting.cs @@ -219,8 +219,8 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting // 检查是否有角色可以行动 Character? characterToAct = await _gamingQueue.NextCharacterAsync(); - Controller.UpdateQueue(); - Controller.UpdateCharacterPositionsOnMap(); + await Controller.UpdateQueue(); + await Controller.UpdateCharacterPositionsOnMap(); // 处理回合 if (characterToAct != null) @@ -252,9 +252,9 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting double timeLapse = await _gamingQueue.TimeLapse(); totalTime += timeLapse; nextDropItemTime -= timeLapse; - Controller.UpdateBottomInfoPanel(); - Controller.UpdateQueue(); - Controller.UpdateCharacterPositionsOnMap(); + await Controller.UpdateBottomInfoPanel(); + await Controller.UpdateQueue(); + await Controller.UpdateCharacterPositionsOnMap(); if (roundMsg != "") { @@ -390,7 +390,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting private async Task GamingQueue_CharacterMove(GamingQueue queue, Character actor, Grid grid) { - Controller.UpdateCharacterPositionsOnMap(); + await Controller.UpdateCharacterPositionsOnMap(); await Task.CompletedTask; } @@ -398,7 +398,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting { if (reason != QueueUpdatedReason.Action) { - Controller.UpdateQueue(); + await Controller.UpdateQueue(); } if (IsPlayer_OnlyTest(queue, character)) { @@ -418,7 +418,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting private async Task GamingQueue_TurnStart(GamingQueue queue, Character character, List enemys, List teammates, List skills, List items) { - Controller.UpdateBottomInfoPanel(); + await Controller.UpdateBottomInfoPanel(); if (IsPlayer_OnlyTest(queue, character)) { // 确保玩家角色在回合开始时取消AI托管,以便玩家可以控制 @@ -432,20 +432,12 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting { if (!IsPlayer_OnlyTest(queue, character)) return []; - List potentialTargets = []; - if (attack.CanSelectEnemy) potentialTargets.AddRange(enemys); - if (attack.CanSelectTeammate) potentialTargets.AddRange(teammates); - if (attack.CanSelectSelf) potentialTargets.Add(character); - // 通过UI请求目标选择 List selectedTargets = await Controller.RequestTargetSelection( character, - potentialTargets, attack, - attack.CanSelectTargetCount, - attack.CanSelectSelf, - attack.CanSelectEnemy, - attack.CanSelectTeammate + enemys, + teammates ); Controller.ResolveTargetSelection(selectedTargets); @@ -474,12 +466,9 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting // 通过UI请求目标选择 List? selectedTargets = await Controller.RequestTargetSelection( caster, - potentialTargets, skill, - skill.CanSelectTargetCount, - skill.CanSelectSelf, - skill.CanSelectEnemy, - skill.CanSelectTeammate + enemys, + teammates ); Controller.ResolveTargetSelection(selectedTargets); @@ -500,7 +489,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting { double ht = queue.HardnessTime[character]; Controller.SetPredictCharacter(character.NickName, ht); - Controller.UpdateBottomInfoPanel(); + await Controller.UpdateBottomInfoPanel(); if (IsRoundHasPlayer_OnlyTest(queue, character)) { // 玩家回合结束,等待玩家确认 diff --git a/Desktop/GameMapTesting/GameMapViewer.xaml b/Desktop/GameMapTesting/GameMapViewer.xaml index 6e3d477..534b7d8 100644 --- a/Desktop/GameMapTesting/GameMapViewer.xaml +++ b/Desktop/GameMapTesting/GameMapViewer.xaml @@ -119,9 +119,9 @@ - + - + @@ -407,11 +407,46 @@ - - -