using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using System.Threading.Tasks;
public class SpinAction : BaseAction
{
private float totalSpinAmount = 0;
private float originalAngle;
private void Start() {
actionCost = 1;
}
private void Update() {
if (!IsActive()) {
return;
}
float spinAddAmount = 360f * Time.deltaTime;
totalSpinAmount += spinAddAmount;
if (totalSpinAmount >= 360f) {
transform.eulerAngles = new Vector3(transform.eulerAngles.x, originalAngle, transform.eulerAngles.z);
StopAction();
} else {
transform.eulerAngles += new Vector3(0, spinAddAmount, 0);
}
}
public override CancellationToken TakeAction(in GridPosition targetGridPosition, out CancellationToken cancellationToken) {
totalSpinAmount = 0f;
originalAngle = transform.eulerAngles.y;
return StartAction(out cancellationToken);
}
public override string GetActionName() {
return "Spin";
}
protected override bool IsValidTargetPositionSpecific(in GridPosition unitGridPosition, in GridPosition testGridPosition) =>
(unitGridPosition == testGridPosition);
public override EnemyAIAction GetEnemyAIAction(GridPosition gridPosition) {
return new EnemyAIAction {
gridPosition = gridPosition,
actionValue = 0,
};
}
}