Files
Continentis/Assets/Scripts/MainGame/Character/CharacterSubmodules/EventSubmodule.cs
SoulliesOfficial 9b1b5ca93f initial
2025-10-03 00:02:43 -04:00

90 lines
4.0 KiB
C#

using System.Collections.Generic;
using Continentis.MainGame.Card;
using UnityEngine.Events;
using SoftCircuits.Collections;
using SoulliesFramework.General;
namespace Continentis.MainGame.Character
{
public partial class EventSubmodule : SubmoduleBase<CharacterBase>
{
public OrderedDictionary<string, EventUnit> onCombatStart; //战斗开始时
public OrderedDictionary<string, EventUnit> onCombatEnd; //战斗结束时
public OrderedDictionary<string, EventUnit> onRoundStart; //每回合开始时
public OrderedDictionary<string, EventUnit> onRoundEnd; //每回合结束时
public OrderedDictionary<string, EventUnit<List<CharacterBase>>> onStartAttack; //开始攻击时,参数为被攻击目标列表
public OrderedDictionary<string, EventUnit<List<CharacterBase>, List<AttackResult>>> onFinishAttack; //完成攻击时,参数为被攻击目标列表和对应的攻击结果列表
public OrderedDictionary<string, EventUnit<CharacterBase, AttackResult>> onGetAttacked; //被攻击时,参数为攻击者和攻击结果
public OrderedDictionary<string, EventUnit> onActionStart; //每次行动开始时
public OrderedDictionary<string, EventUnit> onActionEnd; //每次行动结束时
public OrderedDictionary<string, EventUnit<CardLogicBase>> onBeforeUseCard; //使用卡牌前,参数为使用的卡牌
public OrderedDictionary<string, EventUnit<CardLogicBase>> onAfterUseCard; //使用卡牌后,参数为使用的卡牌
public EventSubmodule(CharacterBase character) : base(character)
{
onCombatStart = new OrderedDictionary<string, EventUnit>();
onCombatEnd = new OrderedDictionary<string, EventUnit>();
onRoundStart = new OrderedDictionary<string, EventUnit>();
onRoundEnd = new OrderedDictionary<string, EventUnit>();
onActionStart = new OrderedDictionary<string, EventUnit>();
onActionEnd = new OrderedDictionary<string, EventUnit>();
onStartAttack = new OrderedDictionary<string, EventUnit<List<CharacterBase>>>();
onFinishAttack = new OrderedDictionary<string, EventUnit<List<CharacterBase>, List<AttackResult>>>();
onGetAttacked = new OrderedDictionary<string, EventUnit<CharacterBase, AttackResult>>();
onBeforeUseCard = new OrderedDictionary<string, EventUnit<CardLogicBase>>();
onAfterUseCard = new OrderedDictionary<string, EventUnit<CardLogicBase>>();
/*
OnActionStart.InsertByPriority("First", new EventAction(()=>Debug.Log("First"), 0));
OnActionStart.InsertByPriority("Third", new EventAction(()=>Debug.Log("Third"), 2));
OnActionStart.InsertByPriority("Second", new EventAction(()=>Debug.Log("Second"), 1));
foreach (var (key, action) in OnActionStart)
{
action.Invoke();
}
*/
}
}
public partial class EventSubmodule
{
protected void SetUpDefaultEvents()
{
}
}
}
namespace Continentis.MainGame.Character
{
public class AttackResult
{
public CharacterBase attacker; //攻击者
public int startDamage; //攻击开始时的原始伤害值
public bool isDodged; //是否被闪避
public int blockedDamage; //格挡掉的伤害
public int shieldedDamage; //护盾吸收的伤害
public int hurtDamage; //实际受到的伤害
public bool IsHurt => hurtDamage > 0; //是否实际受到伤害
public AttackResult(CharacterBase attacker, int startDamage, bool isDodged, int blocked, int shielded, int hurt)
{
this.attacker = attacker;
this.startDamage = startDamage;
this.isDodged = isDodged;
this.blockedDamage = blocked;
this.shieldedDamage = shielded;
this.hurtDamage = hurt;
}
}
}