async public virtual Task Move() { alertMoveCalled++; if (stateMachine.GetEnemyState() == EnemyStates.IDLE) { int nextNodeID = pathService.GetNextNodeID(currentNodeID, spawnDirection); await MoveToNextNode(nextNodeID); await currentEnemyView.RotateEnemy(GetRotation(spawnDirection)); } else if (stateMachine.GetEnemyState() == EnemyStates.CHASE || stateMachine.GetEnemyState() == EnemyStates.CONSTANT_CHASE) { int nextNodeID = alertedPathNodes[alertMoveCalled]; if (pathService.CanEnemyMoveToNode(currentNodeID, nextNodeID)) { await MoveToNextNode(nextNodeID); await currentEnemyView.RotateEnemy(GetRotation(spawnDirection)); } if (alertMoveCalled == alertedPathNodes.Count - 1) { stateMachine.ChangeEnemyState(EnemyStates.IDLE); currentEnemyView.DisableAlertView(); } } await new WaitForEndOfFrame(); }
async public void PerformAction(Directions _direction) { int nextNodeID = pathService.GetNextNodeID(GetID(), _direction); if (nextNodeID == -1) { ChangePlayerState(PlayerStates.IDLE, PlayerStates.NONE); return; } await PerformMovement(nextNodeID); }