public void SpawnEnemy() { if (spawn_points.Count > 0) { Vector3 spawn_pos = spawn_points[Random.Range(0, spawn_points.Count)].transform.position; PathManager.Path path = path_manager.GetCloserPath(spawn_pos); if (path != null) { int enemy_no = Random.Range(1, 4); GameObject enemy_go = null; switch (enemy_no) { case 1: enemy_go = yellow_enemy; break; case 2: enemy_go = pink_enemy; break; case 3: enemy_go = orange_enemy; break; } if (enemy_go != null) { GameObject curr_en = Instantiate(enemy_go, spawn_pos, Quaternion.identity); if (world_parent != null) { curr_en.transform.parent = world_parent.transform; } curr_en.transform.localRotation = Quaternion.Euler(0, 0, 0); enemies.Add(curr_en); FollowPath path_script = curr_en.GetComponent <FollowPath>(); if (path_script != null) { path_script.SetPath(path.GetPathList()); } Stats stats = curr_en.GetComponent <Stats>(); if (stats != null) { stats.SetManagers(this, event_system); } } } } }
public void SetPath(PathManager.Path lPath, int lIndex = 0) { patrolPath = lPath; targets = patrolPath.wayPoints; targetIndex = lIndex; }
private void SetClosestPath() { PathManager.Path currentPath = PathManager.instance.GetClosestActivePath(rb.position); SetPath(currentPath); SetClosestWaypoint(); }