mirror of
https://github.com/milimoe/FunGame-Testing.git
synced 2026-01-19 22:18:26 +00:00
适配 API
This commit is contained in:
parent
2ccc1d718c
commit
5970feca31
@ -2,6 +2,7 @@
|
|||||||
using Milimoe.FunGame.Core.Interface.Entity;
|
using Milimoe.FunGame.Core.Interface.Entity;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
using Milimoe.FunGame.Core.Model;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
||||||
{
|
{
|
||||||
@ -203,14 +204,14 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
return false;
|
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()
|
public async Task UpdateCharacterPositionsOnMap()
|
||||||
|
|||||||
@ -59,11 +59,13 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
c.Level = clevel;
|
c.Level = clevel;
|
||||||
c.NormalAttack.Level = mlevel;
|
c.NormalAttack.Level = mlevel;
|
||||||
FunGameService.AddCharacterSkills(c, 1, slevel, slevel);
|
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);
|
c.Skills.Add(skill);
|
||||||
|
}
|
||||||
foreach (Skill skillLoop in FunGameConstant.CommonPassiveSkills)
|
foreach (Skill skillLoop in FunGameConstant.CommonPassiveSkills)
|
||||||
{
|
{
|
||||||
Skill passive = skillLoop.Copy();
|
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);
|
if (team1 != null && team2 != null) await Controller.SetTeamCharacters(team1.Members, team2.Members);
|
||||||
|
|
||||||
|
// 启用调试模式
|
||||||
|
_gamingQueue.IsDebug = true;
|
||||||
|
|
||||||
// 加载地图和绑定事件
|
// 加载地图和绑定事件
|
||||||
_gamingQueue.LoadGameMap(GameMap);
|
_gamingQueue.LoadGameMap(GameMap);
|
||||||
_gamingQueue.UseQueueProtected = false;
|
_gamingQueue.UseQueueProtected = false;
|
||||||
@ -321,7 +326,8 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
|
|
||||||
// 检查是否有角色可以行动
|
// 检查是否有角色可以行动
|
||||||
Character? characterToAct = await _gamingQueue.NextCharacterAsync();
|
Character? characterToAct = await _gamingQueue.NextCharacterAsync();
|
||||||
await Controller.UpdateQueue();
|
DecisionPoints dp = GetDP(_gamingQueue);
|
||||||
|
await Controller.UpdateQueue(dp);
|
||||||
await Controller.UpdateCharacterPositionsOnMap();
|
await Controller.UpdateCharacterPositionsOnMap();
|
||||||
|
|
||||||
// 处理回合
|
// 处理回合
|
||||||
@ -361,8 +367,9 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
double timeLapse = await _gamingQueue.TimeLapse();
|
double timeLapse = await _gamingQueue.TimeLapse();
|
||||||
totalTime += timeLapse;
|
totalTime += timeLapse;
|
||||||
nextDropItemTime -= timeLapse;
|
nextDropItemTime -= timeLapse;
|
||||||
await Controller.UpdateBottomInfoPanel();
|
dp = GetDP(_gamingQueue);
|
||||||
await Controller.UpdateQueue();
|
await Controller.UpdateBottomInfoPanel(dp);
|
||||||
|
await Controller.UpdateQueue(dp);
|
||||||
await Controller.UpdateCharacterPositionsOnMap();
|
await Controller.UpdateCharacterPositionsOnMap();
|
||||||
if (team1 != null && team2 != null) await Controller.SetTeamCharacters(team1.Members, team2.Members);
|
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;
|
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();
|
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)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,11 +615,11 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
return selectedSkill;
|
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];
|
double ht = queue.HardnessTime[character];
|
||||||
await Controller.SetPredictCharacter(character.NickName, ht);
|
await Controller.SetPredictCharacter(character.NickName, ht);
|
||||||
await Controller.UpdateBottomInfoPanel();
|
await Controller.UpdateBottomInfoPanel(dp);
|
||||||
if (!_fastMode)
|
if (!_fastMode)
|
||||||
{
|
{
|
||||||
if (IsRoundHasPlayer_OnlyTest(queue, character))
|
if (IsRoundHasPlayer_OnlyTest(queue, character))
|
||||||
@ -630,11 +637,12 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
else await Task.Delay(100);
|
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))
|
if (IsPlayer_OnlyTest(queue, character))
|
||||||
{
|
{
|
||||||
// 通过UI按钮请求行动类型
|
// 通过UI按钮请求行动类型
|
||||||
|
await Controller.UpdateCharacterPositionsOnMap();
|
||||||
CharacterActionType actionType = await Controller.RequestActionType(character, items);
|
CharacterActionType actionType = await Controller.RequestActionType(character, items);
|
||||||
await Controller.ResolveActionType(actionType);
|
await Controller.ResolveActionType(actionType);
|
||||||
return actionType;
|
return actionType;
|
||||||
@ -642,6 +650,21 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
return CharacterActionType.None; // 非玩家角色,由AI处理,或默认None
|
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)
|
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);
|
return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && player == current && !queue.IsCharacterInAIControlling(current);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Runtime.Intrinsics.Arm;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
@ -48,6 +49,8 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
// 新增:用于移动目标选择UI的ObservableCollection
|
// 新增:用于移动目标选择UI的ObservableCollection
|
||||||
public ObservableCollection<Grid> SelectedTargetGrid { get; set; } = [];
|
public ObservableCollection<Grid> SelectedTargetGrid { get; set; } = [];
|
||||||
|
|
||||||
|
public DecisionPoints DP { get; set; } = new();
|
||||||
|
|
||||||
// 新增:倒计时相关的字段
|
// 新增:倒计时相关的字段
|
||||||
private int _remainingCountdownSeconds;
|
private int _remainingCountdownSeconds;
|
||||||
private Action<bool>? _currentContinueCallback;
|
private Action<bool>? _currentContinueCallback;
|
||||||
@ -301,7 +304,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
private static void OnCurrentCharacterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void OnCurrentCharacterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
GameMapViewer viewer = (GameMapViewer)d;
|
GameMapViewer viewer = (GameMapViewer)d;
|
||||||
_ = viewer.UpdateBottomInfoPanel();
|
_ = viewer.UpdateBottomInfoPanel(viewer.DP);
|
||||||
_ = viewer.UpdateCharacterStatisticsPanel(); // 角色改变时也更新统计面板
|
_ = viewer.UpdateCharacterStatisticsPanel(); // 角色改变时也更新统计面板
|
||||||
// 角色改变时,清除装备/状态/技能/物品描述和高亮
|
// 角色改变时,清除装备/状态/技能/物品描述和高亮
|
||||||
viewer.ResetDescriptionAndHighlights(); // 使用新的重置方法
|
viewer.ResetDescriptionAndHighlights(); // 使用新的重置方法
|
||||||
@ -311,7 +314,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
private static void OnCharacterQueueDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void OnCharacterQueueDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
GameMapViewer viewer = (GameMapViewer)d;
|
GameMapViewer viewer = (GameMapViewer)d;
|
||||||
_ = viewer.UpdateLeftQueuePanelGrid();
|
_ = viewer.UpdateLeftQueuePanelGrid(viewer.DP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增:当CharacterStatistics属性改变时,更新数据统计面板
|
// 新增:当CharacterStatistics属性改变时,更新数据统计面板
|
||||||
@ -583,15 +586,16 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新左侧动态队列面板,显示角色及其AT Delay。
|
/// 更新左侧动态队列面板,显示角色及其AT Delay。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task UpdateLeftQueuePanelGrid()
|
public async Task UpdateLeftQueuePanelGrid(DecisionPoints dp)
|
||||||
{
|
{
|
||||||
// 确保在UI线程上执行
|
// 确保在UI线程上执行
|
||||||
if (!this.Dispatcher.CheckAccess())
|
if (!this.Dispatcher.CheckAccess())
|
||||||
{
|
{
|
||||||
await this.Dispatcher.InvokeAsync(async () => await UpdateLeftQueuePanelGrid());
|
await this.Dispatcher.InvokeAsync(async () => await UpdateLeftQueuePanelGrid(dp));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DP = dp;
|
||||||
CharacterQueueItems.Clear(); // 清除现有项
|
CharacterQueueItems.Clear(); // 清除现有项
|
||||||
|
|
||||||
if (CharacterQueueData != null)
|
if (CharacterQueueData != null)
|
||||||
@ -612,15 +616,17 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新底部信息面板显示当前角色的详细信息、装备和状态。
|
/// 更新底部信息面板显示当前角色的详细信息、装备和状态。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task UpdateBottomInfoPanel()
|
public async Task UpdateBottomInfoPanel(DecisionPoints dp)
|
||||||
{
|
{
|
||||||
// 确保在UI线程上执行
|
// 确保在UI线程上执行
|
||||||
if (!this.Dispatcher.CheckAccess())
|
if (!this.Dispatcher.CheckAccess())
|
||||||
{
|
{
|
||||||
await this.Dispatcher.InvokeAsync(async () => await UpdateBottomInfoPanel());
|
await this.Dispatcher.InvokeAsync(async () => await UpdateBottomInfoPanel(dp));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DP = dp;
|
||||||
|
|
||||||
// 每次更新面板时,清除所有描述和高亮
|
// 每次更新面板时,清除所有描述和高亮
|
||||||
ResetDescriptionAndHighlights(true);
|
ResetDescriptionAndHighlights(true);
|
||||||
|
|
||||||
@ -1352,7 +1358,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting
|
|||||||
);
|
);
|
||||||
if (result == MessageBoxResult.Yes)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -90,13 +90,13 @@ Console.ReadKey();
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await FunGameSimulation.StartSimulationGame(true, true, true, true, useStore: false);
|
await FunGameSimulation.StartSimulationGame(true, false, true, false, useStore: false);
|
||||||
ConsoleKeyInfo key = Console.ReadKey();
|
ConsoleKeyInfo key = Console.ReadKey();
|
||||||
if (key.Key == ConsoleKey.Escape)
|
if (key.Key == ConsoleKey.Escape)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await FunGameSimulation.StartSimulationGame(true, false, false, true);
|
await FunGameSimulation.StartSimulationGame(true, false, false, false);
|
||||||
key = Console.ReadKey();
|
key = Console.ReadKey();
|
||||||
if (key.Key == ConsoleKey.Escape)
|
if (key.Key == ConsoleKey.Escape)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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))
|
if (IsPlayer_OnlyTest(queue, character))
|
||||||
{
|
{
|
||||||
@ -418,7 +418,7 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
await Task.CompletedTask;
|
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))
|
if (IsPlayer_OnlyTest(queue, character))
|
||||||
{
|
{
|
||||||
@ -634,7 +634,7 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
return skill;
|
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))
|
if (IsRoundHasPlayer_OnlyTest(queue, character))
|
||||||
{
|
{
|
||||||
@ -645,7 +645,7 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
await Task.CompletedTask;
|
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;
|
CharacterActionType type = CharacterActionType.None;
|
||||||
if (IsPlayer_OnlyTest(queue, character))
|
if (IsPlayer_OnlyTest(queue, character))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user