import { Player } from './Player.js'; export class Team { constructor(scene, color, numberOfPlayers, isPlayerTeam) { this.scene = scene; this.color = color; this.numberOfPlayers = numberOfPlayers; this.isPlayerTeam = isPlayerTeam; this.players = []; this.createTeam(); } createTeam() { for (let i = 0; i < this.numberOfPlayers; i++) { const position = this.generatePosition(i); const player = new Player(this.scene, this.color, position, this.isPlayerTeam ? 'player' : 'bot'); this.players.push(player); } } resetPositions() { for (let i = 0; i < this.players.length; i++) { const player = this.players[i]; const position = this.generatePosition(i); player.mesh.position.set(position.x, position.y, position.z); player.mesh.velocity.set(0, 0, 0); } } generatePosition(i) { if (this.isPlayerTeam) { if (i === 0) { return { x: -15, y: 1.5, z: 0 }; } else { return { x: -Math.random() * 25 - 5, // Left side y: 1.5, z: (Math.random() - 0.5) * 80 }; } } else { return { x: Math.random() * 25 + 5, // Right side y: 1.5, z: (Math.random() - 0.5) * 80 }; } } }