// sorts the players list by team_id then player_id private void sort_players() { GameObject[] temp_player_list = new GameObject[players.Length]; Movement2D_Base[] temp_move_list = new Movement2D_Base[players.Length]; for (int a = 0; a < players.Length; a++) { temp_move_list[a] = players[a].GetComponent <Movement2D_Base>(); } int counter = 0; for (int a = 0; a < 2; a++) // team_id { for (int b = 0; b < 2; b++) // player_id { for (int c = 0; c < players.Length; c++) { if (temp_move_list[c].team_id == a + 1 && temp_move_list[c].player_id == b + 1) { temp_player_list[counter] = players[c]; counter++; } } } } for (int a = 0; a < players.Length; a++) { players[a] = temp_player_list[a]; } }
//attempt to attach controllers to players public void AttachControllers() { // if count, assign controllers /* if (Gamepad.all.Count >= players.Count) * { * for (int a = 0; a < players.Count; a++) * { * Debug.Log("players: " + players[a].name); * players[a].GetComponent<Movement2D_Base>().AssignController(Gamepad.all[a]); * //players[a].ActivatePlayer(Gamepad.all[a], a); * } * } * else */ for (int i = 0; i < players.Count; i++) { Movement2D_Base ctrl = players[i].GetComponent <Movement2D_Base>(); if (i < Gamepad.all.Count) { Debug.Log("Ctrl: " + ctrl.name); Debug.Log("GameControls: " + _GameControls.All.name); ctrl.AssignController(_GameControls.All.GetGamePad(i)); } else { ctrl.is_keyboard = true; ctrl.keyboard_id = i + 1; } } }