public void InitializeMovement() { //print(Vector2.Distance(new Vector2(-1.7f, 3.7f), new Vector2(-1.4f, 3.8f))); // If empty, create it. // ReSharper disable once ConvertIfStatementToNullCoalescingAssignment if (AllFinalPositionsRanged == null) { AllFinalPositionsRanged = new List <Vector3>(); } attackStarted = false; canMove = true; DisableEnemyMovement(false); GetSpawnArea(GetPosition()); spawnManager = SpawnManager.instance; _enemyRangedAttackType = GetComponent <IRangedAttackType>(); // Ranged Attack Interface CalculateFinalPosition(); CheckValidRangedFinalPosition(); SetForwardVector(finalPosition); }
// Testing //private Color _color; // Start is called before the first frame update void Start() { // Check if this is a ranged enemy, then modify the minimum distance to player // so the final position is never behind the last zigzag position _rangedAttackType = GetComponent <IRangedAttackType>(); if (_rangedAttackType != null) { minimumDistanceToPlayer = GetPosition().y >= 0 ? finalPosition.y + 0.5f : finalPosition.y - 0.5f; } // Calculate all the coords for the zigzag and store them in a queue while (!_pickedZigZagCoordinates) { if (CalculateInitialZigZagPositions()) { continue; } SetInitialWayPoint(); CreateZigzagPositionsQueue(); } }