void SetupPlayers() { Vector3 position = new Vector3(4f, 1.83f, 0f); List <TeamChoiceData> team1 = new List <TeamChoiceData>(); List <TeamChoiceData> team2 = new List <TeamChoiceData>(); foreach (TeamChoice p in MainGameManager.controllers) { if (p.team == 0) { team1.Add(p.GetData()); } else if (p.team == 2) { team2.Add(p.GetData()); } } List <TeamChoiceData> teams = new List <TeamChoiceData>(); teams.AddRange(team2); teams.AddRange(team1); teams.Add(SwappingTeamMate(2)); teams.Add(SwappingTeamMate(0)); Vector3[] positions = new Vector3[] { position, new Vector3(position.x, -position.y, position.z), new Vector3(-position.x, position.y, position.z), new Vector3(-position.x, -position.y, position.z), new Vector3(4.88f, -0.18f, position.z), //swap2 new Vector3(-4.88f, -0.18f, position.z) //swap1 }; for (int i = 0; i < teams.Count; i++) { TeamChoiceData teamItem = teams[i]; GameObject player = null; if (i <= 3) { if (i % 2 == 1) { player = Instantiate(this.Fighter, positions[i], Quaternion.identity); } else { player = Instantiate(this.Defender, positions[i], Quaternion.identity); } } else { player = Instantiate(this.Collector, positions[i], Quaternion.identity); } player.GetComponent <SpriteRenderer>().color = teamItem.team == 0 ? Color.red : Color.cyan; Character character = player.GetComponent <Character>(); character.team = teamItem.team == 0 ? 1 : 2; character.pool = character.team == 1 ? this.pool1 : this.pool2; character.playerId = teamItem.playerId; } }
public TeamChoiceData GetData() { TeamChoiceData data = new TeamChoiceData(); data.team = this.team; data.playerId = this.playerId; data.confirmed = this.confirmed; return(data); }
private TeamChoiceData SwappingTeamMate(int teamId) { TeamChoiceData teamMate = new TeamChoiceData(); teamMate.playerId = 0; teamMate.team = teamId; teamMate.confirmed = true; return(teamMate); }