144 lines
5.1 KiB
C#
144 lines
5.1 KiB
C#
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<CharacterBase> normalBlockAction;
|
|
public Action<CharacterBase> perfectBlockAction;
|
|
public Action<CharacterBase> 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<CharacterBase> normalBlockAction = null,
|
|
Action<CharacterBase> perfectBlockAction = null, Action<CharacterBase> 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<CharacterBase> normalDodgeAction;
|
|
public Action<CharacterBase> perfectDodgeAction;
|
|
public Action<CharacterBase> 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<CharacterBase> normalDodgeAction = null,
|
|
Action<CharacterBase> perfectDodgeAction = null, Action<CharacterBase> 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;
|
|
}
|
|
}
|
|
} |