From 46620aefd7ba3946db4177bfa947d882ec0e5044 Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 3 Sep 2025 01:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=AE=E6=94=BB=E6=B7=BB=E5=8A=A0=E9=80=89?= =?UTF-8?q?=E5=8F=96=E7=9B=AE=E6=A0=87=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Skill/NormalAttack.cs | 53 ++++++++++++++++++++++++++++-- Interface/Entity/Typical/ISkill.cs | 14 ++++++-- Model/GamingQueue.cs | 6 +--- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/Entity/Skill/NormalAttack.cs b/Entity/Skill/NormalAttack.cs index de66fae..4d9c6f1 100644 --- a/Entity/Skill/NormalAttack.cs +++ b/Entity/Skill/NormalAttack.cs @@ -188,6 +188,16 @@ namespace Milimoe.FunGame.Core.Entity /// public bool CanSelectTeammate { get; set; } = false; + /// + /// 选取所有敌对角色,优先级大于 + /// + public bool SelectAllEnemies { get; set; } = false; + + /// + /// 选取所有友方角色,优先级大于 ,默认包含自身 + /// + public bool SelectAllTeammates { get; set; } = false; + /// /// 可选取的作用目标数量 /// @@ -231,17 +241,17 @@ namespace Milimoe.FunGame.Core.Entity /// /// 获取可选择的目标列表 /// - /// + /// /// /// /// - public List GetSelectableTargets(Character caster, List enemys, List teammates) + public List GetSelectableTargets(Character attacker, List enemys, List teammates) { List selectable = []; if (CanSelectSelf) { - selectable.Add(caster); + selectable.Add(attacker); } foreach (Character character in enemys) @@ -263,6 +273,43 @@ namespace Milimoe.FunGame.Core.Entity return selectable; } + + /// + /// 选取普攻目标 + /// + /// + /// + /// + /// + public List SelectTargets(Character attacker, List enemys, List teammates) + { + List tobeSelected = GetSelectableTargets(attacker, enemys, teammates); + + List targets = []; + + if (SelectAllTeammates || SelectAllEnemies) + { + if (SelectAllTeammates) + { + targets.AddRange(tobeSelected.Where(c => c == attacker || teammates.Contains(c))); + } + if (SelectAllEnemies) + { + targets.AddRange(tobeSelected.Where(enemys.Contains)); + } + } + else if (tobeSelected.Count <= CanSelectTargetCount) + { + targets.AddRange(tobeSelected); + } + else + { + targets.AddRange(tobeSelected.OrderBy(x => Random.Shared.Next()).Take(CanSelectTargetCount)); + } + + return [.. targets.Distinct()]; + } + /// /// 对目标(或多个目标)发起普通攻击 /// diff --git a/Interface/Entity/Typical/ISkill.cs b/Interface/Entity/Typical/ISkill.cs index 15e3008..4ac6619 100644 --- a/Interface/Entity/Typical/ISkill.cs +++ b/Interface/Entity/Typical/ISkill.cs @@ -1,5 +1,4 @@ -using Milimoe.FunGame.Core.Api.Utility; -using Milimoe.FunGame.Core.Entity; +using Milimoe.FunGame.Core.Entity; namespace Milimoe.FunGame.Core.Interface.Entity { @@ -52,6 +51,17 @@ namespace Milimoe.FunGame.Core.Interface.Entity /// 可选取友方角色 /// public bool CanSelectTeammate { get; } + + /// + /// 选取所有敌对角色,优先级大于 + /// + public bool SelectAllEnemies { get; } + + /// + /// 选取所有友方角色,优先级大于 ,默认包含自身 + /// + public bool SelectAllTeammates { get; } + /// /// 可选取的作用目标数量 /// diff --git a/Model/GamingQueue.cs b/Model/GamingQueue.cs index 97f1c51..42d1f27 100644 --- a/Model/GamingQueue.cs +++ b/Model/GamingQueue.cs @@ -2370,11 +2370,7 @@ namespace Milimoe.FunGame.Core.Model List targets = await OnSelectNormalAttackTargetsAsync(character, attack, enemys, teammates); if (targets.Count == 0 && CharactersInAI.Contains(character)) { - targets = character.NormalAttack.GetSelectableTargets(character, enemys, teammates); - if (targets.Count > 0) - { - targets = [targets[Random.Shared.Next(targets.Count)]]; - } + targets = character.NormalAttack.SelectTargets(character, enemys, teammates); } return targets; }