private void SpawnRepeating() { spawnStack = ShuffledStack.CreateShuffledStack(spawnPoints); InvokeRepeating("Spawn", spawnDelay, spawnRate); InvokeRepeating("ShuffleWaypoints", 3, 3); }
/// <summary> /// Shuffle waypoints for increased random movements of enemies. /// </summary> private void ShuffleWaypoints() { var temp = waypoints.GetRange(0, waypoints.Count - 2); temp = ShuffledStack.CreateShuffledStack(temp).ToList(); temp.Add(waypoints.Last()); waypoints = temp; }
private void Spawn() { if (spawnStack.Count == 0) { spawnStack = ShuffledStack.CreateShuffledStack(spawnPoints); } var currentPoint = spawnStack.Pop(); var enemy = Instantiate(enemyPrefab, enemyParent.transform); enemy.transform.position = currentPoint.transform.position; var follower = enemy.GetComponent <WaypointFollower>(); foreach (var point in waypoints) { follower.AddPointToFollow(point.position); } follower.Speed = settings.EnemySpeed; }