62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using VOID.Generic.Objects.Abstract;
|
|
using VOID.Generic.Objects.Unit.Actions.Exceptions;
|
|
using VOID.Generic.Objects.Unit.Events;
|
|
using VOID.Generic.Util;
|
|
|
|
namespace VOID.Generic.Objects.Unit.Actions
|
|
{
|
|
public class TalkAction : AbstractAction
|
|
{
|
|
private readonly UnitObject _unit;
|
|
private readonly UnitObject _targetObject;
|
|
|
|
public TalkAction(UnitObject unit, UnitObject targetObject)
|
|
{
|
|
_unit = unit;
|
|
_targetObject = targetObject;
|
|
}
|
|
|
|
public override bool IsInRange()
|
|
{
|
|
return RangeUtil.IsInRange(_unit, _targetObject, _unit.unitData.talkRange);
|
|
}
|
|
|
|
protected override void OnEndIt() { }
|
|
|
|
protected override void OnCancelIt() { }
|
|
|
|
public override void CanDoIt()
|
|
{
|
|
Check(
|
|
_unit.unitData.canTalk,
|
|
UnitActionErrorType.ThisUnitCantTalk);
|
|
Check(
|
|
_targetObject.unitData.canBeTalked,
|
|
UnitActionErrorType.OtherUnitCantBeTalked);
|
|
Check(
|
|
state == ActionState.Ready,
|
|
UnitActionErrorType.ActionStateIsNotReady);
|
|
Check(
|
|
!_unit.basicState.turnManager,
|
|
UnitActionErrorType.TalkNotAvailableWhenTurnActive);
|
|
Check(
|
|
_unit.unitState.isControllable,
|
|
UnitActionErrorType.UnitStateIsNotControllable);
|
|
Check(
|
|
_unit.unitState.isControllable,
|
|
UnitActionErrorType.UnitStateIsNotControllable);
|
|
Check(
|
|
IsInRange(),
|
|
UnitActionErrorType.NotInRange);
|
|
}
|
|
|
|
protected override void OnDoIt()
|
|
{
|
|
new RotateAction(_unit, _targetObject).DoIt();
|
|
BeforePerform();
|
|
// Tutaj rozmowa
|
|
AfterPerform();
|
|
EndIt();
|
|
}
|
|
}
|
|
} |