using System; using Cielonos.MainGame.Characters; using UnityEngine; namespace Cielonos.MainGame { public partial class ReactionSubmodule : AttackAreaSubmoduleBase { public ReactionSubmodule(AttackAreaBase owner) : base(owner) { SetBlock(); SetDodge(); } } public partial class ReactionSubmodule { public bool canBeBlocked; public bool canBreakBlock; public bool hasPerfectBlock; public Action normalBlockAction; public Action perfectBlockAction; public Action breakBlockAction; public AttackAreaBase SetBlock(bool canBeBlocked = true, bool hasPerfectBlock = true, bool canBreakBlock = false) { this.canBeBlocked = canBeBlocked; this.hasPerfectBlock = hasPerfectBlock; this.canBreakBlock = canBreakBlock; return attackArea; } public AttackAreaBase SetBlockActions(Action normalBlockAction = null, Action perfectBlockAction = null, Action breakBlockAction = null) { this.normalBlockAction = normalBlockAction; this.perfectBlockAction = perfectBlockAction; this.breakBlockAction = breakBlockAction; return attackArea; } public bool CheckBlock(CharacterBase blocker, CharacterBase attacker, Vector3 hitPosition) { BlockSubmodule characterBlockSm = blocker?.reactionSc?.blockSm; if (characterBlockSm == null) return false; if (characterBlockSm.isBlocking) { if (canBeBlocked) { BlockSource firstBlockSource; if (hasPerfectBlock && owner.timeSm.enablingTime <= 0.2f && characterBlockSm.isPerfectBlocking) { firstBlockSource = characterBlockSm.blockSources.Find(source => source.isDuringPerfectBlock); firstBlockSource.PerfectBlock(attackArea, hitPosition); perfectBlockAction?.Invoke(blocker); } else { firstBlockSource = characterBlockSm.blockSources[0]; firstBlockSource.NormalBlock(attackArea, hitPosition); normalBlockAction?.Invoke(blocker); } return true; } if (canBreakBlock) { breakBlockAction?.Invoke(blocker); return false; } } return false; } } public partial class ReactionSubmodule { public bool canBeDodged; public bool canBreakDodge; public bool hasPerfectDodge; public Action normalDodgeAction; public Action perfectDodgeAction; public Action breakDodgeAction; public AttackAreaBase SetDodge(bool canBeDodged = true, bool hasPerfectDodge = true, bool canBreakDodge = false) { this.canBeDodged = canBeDodged; this.hasPerfectDodge = hasPerfectDodge; this.canBreakDodge = canBreakDodge; return attackArea; } public AttackAreaBase SetDodgeActions(Action normalDodgeAction = null, Action perfectDodgeAction = null, Action breakDodgeAction = null) { this.normalDodgeAction = normalDodgeAction; this.perfectDodgeAction = perfectDodgeAction; this.breakDodgeAction = breakDodgeAction; return attackArea; } public bool CheckDodge(CharacterBase dodger) { DodgeSubmodule characterDodgeSm = dodger?.reactionSc?.dodgeSm; if (characterDodgeSm == null) return false; if (characterDodgeSm.isDodging) { if (canBeDodged) { DodgeSource firstDodgeSource; if (hasPerfectDodge && owner.timeSm.enablingTime <= 0.2f && characterDodgeSm.isPerfectDodging) { firstDodgeSource = characterDodgeSm.dodgeSources.Find(source => source.isDuringPerfectDodge); firstDodgeSource.PerfectDodge(); perfectDodgeAction?.Invoke(dodger); } else { firstDodgeSource = characterDodgeSm.dodgeSources[0]; firstDodgeSource.NormalDodge(); normalDodgeAction?.Invoke(dodger); } return true; } if (canBreakDodge) { breakDodgeAction?.Invoke(dodger); return false; } } return false; } } }