In this paper, we propose a new algorithm, PE-PSO, for real-time trajectory planning of unmanned aerial vehicles (UAVs) in dynamic environments. To address the premature convergence and delay issues of the conventional Particle Swarm Optimization (PSO), we introduce a continuous search mechanism and an entropy-based parameter adjustment strategy. We model the trajectories using B-spline curves to ensure smooth paths and reduce the optimization complexity. For the collaboration of multiple UAVs, we develop a multi-agent framework combining genetic algorithm (GA)-based task assignment and distributed PE-PSO to support scalability and coordinated trajectory generation. Simulation results show that the proposed framework outperforms the conventional PSO and other swarm-based planners in terms of trajectory quality, energy efficiency, obstacle avoidance, and computation time.