2018-11-20 20:10:49 +01:00
|
|
|
using Fie.Manager;
|
|
|
|
using Fie.Object;
|
|
|
|
using Spine;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2023-07-24 21:52:50 +02:00
|
|
|
using Event = Spine.Event;
|
2018-11-20 20:10:49 +01:00
|
|
|
|
|
|
|
namespace Fie.Enemies.HoovesRaces.ChangelingAlpha
|
|
|
|
{
|
|
|
|
public class FieStateMachineChangelingAlphaShoot : FieStateMachineGameCharacterBase
|
|
|
|
{
|
|
|
|
private enum ShootState
|
|
|
|
{
|
|
|
|
STATE_PREPARE,
|
|
|
|
STATE_SHOOT
|
|
|
|
}
|
|
|
|
|
|
|
|
private ShootState _shootState;
|
|
|
|
|
|
|
|
private bool _isEnd;
|
|
|
|
|
|
|
|
public override void initialize(FieGameCharacter gameCharacter)
|
|
|
|
{
|
|
|
|
gameCharacter.isEnableAutoFlip = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void updateState<T>(ref T gameCharacter)
|
|
|
|
{
|
|
|
|
FieChangelingAlpha changelingAlpha = gameCharacter as FieChangelingAlpha;
|
|
|
|
if (!(changelingAlpha == null))
|
|
|
|
{
|
|
|
|
if (changelingAlpha.detector.getLockonEnemyTransform() == null)
|
|
|
|
{
|
|
|
|
_isEnd = true;
|
|
|
|
}
|
|
|
|
else if (_shootState == ShootState.STATE_PREPARE)
|
|
|
|
{
|
|
|
|
TrackEntry trackEntry = changelingAlpha.animationManager.SetAnimation(8, isLoop: false, isForceSet: true);
|
|
|
|
if (trackEntry != null)
|
|
|
|
{
|
|
|
|
autoFlipToEnemy(changelingAlpha);
|
2023-07-24 21:52:50 +02:00
|
|
|
trackEntry.Event += delegate(TrackEntry state, Event trackIndex)
|
2018-11-20 20:10:49 +01:00
|
|
|
{
|
2023-07-24 21:52:50 +02:00
|
|
|
if (trackIndex.Data.Name == "fire")
|
2018-11-20 20:10:49 +01:00
|
|
|
{
|
|
|
|
FieManagerBehaviour<FieEmittableObjectManager>.I.EmitObject<FieEmitObjectChangelingAlphaShot>(changelingAlpha.hornTransform, changelingAlpha.flipDirectionVector, changelingAlpha.detector.getLockonEnemyTransform(isCenter: true), changelingAlpha);
|
|
|
|
}
|
2023-07-24 21:52:50 +02:00
|
|
|
if (trackIndex.Data.Name == "move")
|
2018-11-20 20:10:49 +01:00
|
|
|
{
|
|
|
|
Vector3 flipDirectionVector = changelingAlpha.flipDirectionVector;
|
2023-07-24 21:52:50 +02:00
|
|
|
Vector3 moveForce = flipDirectionVector * trackIndex.Float;
|
2018-11-20 20:10:49 +01:00
|
|
|
changelingAlpha.resetMoveForce();
|
|
|
|
changelingAlpha.setMoveForce(moveForce, 0f, useRound: false);
|
|
|
|
}
|
2023-07-24 21:52:50 +02:00
|
|
|
if (trackIndex.Data.Name == "finished")
|
2018-11-20 20:10:49 +01:00
|
|
|
{
|
|
|
|
_isEnd = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
trackEntry.Complete += delegate
|
|
|
|
{
|
|
|
|
_isEnd = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_isEnd = true;
|
|
|
|
}
|
|
|
|
_shootState = ShootState.STATE_SHOOT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool isEnd()
|
|
|
|
{
|
|
|
|
return _isEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Type getNextState()
|
|
|
|
{
|
|
|
|
return typeof(FieStateMachineCommonIdle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override List<Type> getAllowedStateList()
|
|
|
|
{
|
|
|
|
List<Type> list = new List<Type>();
|
|
|
|
list.Add(typeof(FieStateMachineChangelingAlphaConcentration));
|
|
|
|
list.Add(typeof(FieStateMachineChangelingAlphaShout));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|