2018-11-20 20:10:49 +01:00
|
|
|
using Fie.Object;
|
|
|
|
using Fie.Ponies.Applejack;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
namespace Fie.AI {
|
|
|
|
public class FieAITaskApplejackBackstep : FieAITaskBase {
|
|
|
|
private enum StepState {
|
|
|
|
STATE_PREPARE,
|
|
|
|
STATE_STEP
|
|
|
|
}
|
2018-11-20 20:10:49 +01:00
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
private const float ATTACK_DISTANCE = 15f;
|
2018-11-20 20:10:49 +01:00
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
private bool _isEndState;
|
2018-11-20 20:10:49 +01:00
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
private StepState _stepState;
|
2018-11-20 20:10:49 +01:00
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
public override void Initialize(FieAITaskController manager) {
|
|
|
|
_isEndState = false;
|
|
|
|
_stepState = StepState.STATE_PREPARE;
|
|
|
|
}
|
2018-11-20 20:10:49 +01:00
|
|
|
|
2018-11-21 21:16:20 +01:00
|
|
|
public override bool Task(FieAITaskController manager) {
|
|
|
|
if (manager.ownerCharacter.groundState != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (_stepState) {
|
|
|
|
case StepState.STATE_PREPARE: {
|
|
|
|
Vector3 directionalVec = new Vector3(
|
|
|
|
Random.Range(-1f, 1f),
|
|
|
|
Random.Range(-1f, 1f),
|
|
|
|
Random.Range(-1f, 1f)
|
|
|
|
);
|
|
|
|
|
|
|
|
manager.ownerCharacter.RequestToChangeState<FieStateMachineApplejackEvasion>(directionalVec, 1f, FieGameCharacter.StateMachineType.Base);
|
|
|
|
|
|
|
|
FieStateMachineInterface currentStateMachine = manager.ownerCharacter.getStateMachine().getCurrentStateMachine();
|
|
|
|
|
|
|
|
if (currentStateMachine is FieStateMachineApplejackEvasion
|
|
|
|
|| currentStateMachine is FieStateMachineApplejackBackstep
|
|
|
|
|| currentStateMachine is FieStateMachineApplejackCharge) {
|
|
|
|
|
|
|
|
currentStateMachine.stateChangeEvent += delegate {
|
|
|
|
_isEndState = true;
|
|
|
|
};
|
|
|
|
_stepState = StepState.STATE_STEP;
|
|
|
|
} else {
|
|
|
|
_isEndState = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case StepState.STATE_STEP:
|
|
|
|
if (_isEndState) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-11-20 20:10:49 +01:00
|
|
|
}
|