AttackResult修改
This commit is contained in:
@@ -128,6 +128,7 @@ namespace Continentis.MainGame
|
||||
|
||||
public OrderedDictionary<string, PrioritizedAction<CharacterBase, IntendedCard, CharacterBase>> onOpponentDecideAction; //对手AI决定行动时,参数为对手,和原定的目标角色
|
||||
|
||||
public OrderedDictionary<string, PrioritizedAction<AttackResult>> onDealAttack; //造成伤害后,参数为伤害结果
|
||||
public OrderedDictionary<string, PrioritizedAction<AttackResult>> onGetAttacked; //被攻击后,参数为伤害结果
|
||||
|
||||
public OrderedDictionary<string, PrioritizedAction<CardInstance>> onDrawCard; //抽到卡牌时
|
||||
@@ -147,6 +148,7 @@ namespace Continentis.MainGame
|
||||
onActionStart = new OrderedDictionary<string, PrioritizedAction>();
|
||||
onActionEnd = new OrderedDictionary<string, PrioritizedAction>();
|
||||
|
||||
onDealAttack = new OrderedDictionary<string, PrioritizedAction<AttackResult>>();
|
||||
onGetAttacked = new OrderedDictionary<string, PrioritizedAction<AttackResult>>();
|
||||
onOpponentDecideAction = new OrderedDictionary<string, PrioritizedAction<CharacterBase, IntendedCard, CharacterBase>>();
|
||||
|
||||
|
||||
@@ -76,10 +76,13 @@ namespace Continentis.MainGame.Character
|
||||
/// <param name="ignoreBlock">是否无视格挡</param>
|
||||
/// <param name="ignoreShield">是否无视护盾</param>
|
||||
/// <returns>实际造成的伤害</returns>
|
||||
public AttackResult Attack(CharacterBase target, int startDamage, bool triggerAttackEvent = true, bool ignoreDodge = false, bool ignoreBlock = false, bool ignoreShield = false)
|
||||
public AttackResult Attack(CharacterBase target, int startDamage, CardInstance attackCard = null, bool triggerAttackEvent = true, bool ignoreDodge = false, bool ignoreBlock = false, bool ignoreShield = false)
|
||||
{
|
||||
eventSubmodule.onStartAttack.Invoke(new List<CharacterBase> { target });
|
||||
|
||||
if (triggerAttackEvent)
|
||||
{
|
||||
eventSubmodule.onStartAttack.Invoke(target);
|
||||
}
|
||||
|
||||
//闪避检测:如果闪避成功,直接结束
|
||||
int modifiedStartDamageForDodge = Mathf.RoundToInt(startDamage * GetRawAttribute("DodgeCheckStartDamageMultiplier", 1));
|
||||
bool dodged = !ignoreDodge && target.CheckDodge(modifiedStartDamageForDodge);
|
||||
@@ -105,10 +108,14 @@ namespace Continentis.MainGame.Character
|
||||
}
|
||||
|
||||
target.characterView.hudContainer.enablingHUDs["MainAttributesBar"].UpdateHud();
|
||||
AttackResult attackResult = new AttackResult(this, startDamage, dodged, blocked, shielded, hurt);
|
||||
AttackResult attackResult = new AttackResult(this, target, startDamage, attackCard, dodged, blocked, shielded, hurt);
|
||||
if (triggerAttackEvent)
|
||||
{
|
||||
eventSubmodule.onFinishAttack.Invoke(new List<CharacterBase> { target }, new List<AttackResult> { attackResult });
|
||||
eventSubmodule.onFinishAttack.Invoke(target, attackResult);
|
||||
combatBuffSubmodule.buffList.For(buff =>
|
||||
{
|
||||
buff.eventSubmodule.onDealAttack.Invoke(attackResult);
|
||||
});
|
||||
}
|
||||
|
||||
return attackResult;
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Continentis.MainGame.Character
|
||||
public OrderedDictionary<string, PrioritizedAction> onRoundStart; //每回合开始时
|
||||
public OrderedDictionary<string, PrioritizedAction> onRoundEnd; //每回合结束时
|
||||
|
||||
public OrderedDictionary<string, PrioritizedAction<List<CharacterBase>>> onStartAttack; //开始攻击时,参数为被攻击目标列表
|
||||
public OrderedDictionary<string, PrioritizedAction<List<CharacterBase>, List<AttackResult>>> onFinishAttack; //完成攻击时,参数为被攻击目标列表和对应的攻击结果列表
|
||||
public OrderedDictionary<string, PrioritizedAction<CharacterBase>> onStartAttack; //开始攻击时,参数为被攻击目标
|
||||
public OrderedDictionary<string, PrioritizedAction<CharacterBase, AttackResult>> onFinishAttack; //完成攻击时,参数为被攻击目标和对应的攻击结果
|
||||
public OrderedDictionary<string, PrioritizedAction<CharacterBase, AttackResult>> onGetAttacked; //被攻击时,参数为攻击者和攻击结果
|
||||
|
||||
public OrderedDictionary<string, PrioritizedAction> onActionStart; //每次行动开始时
|
||||
@@ -35,8 +35,8 @@ namespace Continentis.MainGame.Character
|
||||
onActionStart = new OrderedDictionary<string, PrioritizedAction>();
|
||||
onActionEnd = new OrderedDictionary<string, PrioritizedAction>();
|
||||
|
||||
onStartAttack = new OrderedDictionary<string, PrioritizedAction<List<CharacterBase>>>();
|
||||
onFinishAttack = new OrderedDictionary<string, PrioritizedAction<List<CharacterBase>, List<AttackResult>>>();
|
||||
onStartAttack = new OrderedDictionary<string, PrioritizedAction<CharacterBase>>();
|
||||
onFinishAttack = new OrderedDictionary<string, PrioritizedAction<CharacterBase, AttackResult>>();
|
||||
onGetAttacked = new OrderedDictionary<string, PrioritizedAction<CharacterBase, AttackResult>>();
|
||||
|
||||
onBeforePlayCard = new OrderedDictionary<string, PrioritizedAction<CardInstance, List<CharacterBase>>>();
|
||||
@@ -82,6 +82,8 @@ namespace Continentis.MainGame.Character
|
||||
public class AttackResult
|
||||
{
|
||||
public CharacterBase attacker; //攻击者
|
||||
public CharacterBase target; //被攻击者
|
||||
public CardInstance attackCard; //使用的攻击卡牌
|
||||
public int startDamage; //攻击开始时的原始伤害值
|
||||
public bool isDodged; //是否被闪避
|
||||
public int blockedDamage; //格挡掉的伤害
|
||||
@@ -90,9 +92,11 @@ namespace Continentis.MainGame.Character
|
||||
|
||||
public bool IsHurt => hurtDamage > 0; //是否实际受到伤害
|
||||
|
||||
public AttackResult(CharacterBase attacker, int startDamage, bool isDodged, int blocked, int shielded, int hurt)
|
||||
public AttackResult(CharacterBase attacker, CharacterBase target, int startDamage, CardInstance attackCard, bool isDodged, int blocked, int shielded, int hurt)
|
||||
{
|
||||
this.attacker = attacker;
|
||||
this.target = target;
|
||||
this.attackCard = attackCard;
|
||||
this.startDamage = startDamage;
|
||||
this.isDodged = isDodged;
|
||||
this.blockedDamage = blocked;
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace Continentis.Mods
|
||||
|
||||
[Button]
|
||||
private void CollectAllHUDData() => hudDataIDList = CollectData<HUDData>();
|
||||
|
||||
[Button]
|
||||
private void CollectAllLocalizations() => localizationFiles = CollectLocalizations();
|
||||
}
|
||||
|
||||
public partial class ModManifest
|
||||
@@ -97,6 +100,30 @@ namespace Continentis.Mods
|
||||
Debug.Log($"Collected {collectedDataIDList.Count} CardData assets.");
|
||||
return collectedDataIDList;
|
||||
}
|
||||
|
||||
private List<TextAsset> CollectLocalizations()
|
||||
{
|
||||
string inEditorModPath = "Assets/Mods/" + inEditorModFolder;
|
||||
string dataTypeName = nameof(TextAsset);
|
||||
string[] guids = UnityEditor.AssetDatabase.FindAssets($"t:{dataTypeName}", new[] { inEditorModPath });
|
||||
List<TextAsset> collectedTextAssets = new List<TextAsset>();
|
||||
Debug.Log($"Found {guids.Length} TextAsset assets.");
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
string assetFileName = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
TextAsset data = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(path);
|
||||
|
||||
if (assetFileName.Contains("Localization"))
|
||||
{
|
||||
collectedTextAssets.Add(data);
|
||||
Debug.Log($"Collected localization TextAsset: {assetFileName}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"Collected {collectedTextAssets.Count} localization TextAssets.");
|
||||
return collectedTextAssets;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user