using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //学员分组训练控制器 组编号等groupsList index+1 public class GroupManager { StudentContentCtrl contentCtrl;// 可获取图标所代表学员的状态和数据 public GroupManager(StudentContentCtrl studentContent) { contentCtrl = studentContent; } List groups = new List(); /// /// 将一些学员创建为一个编组 并返回创建结果 /// /// public string CreatGroup(List selectStudents) { for (int i = 0; i < selectStudents.Count; i++)//遍历学员是否满足编组条件 { if (selectStudents[i].groupNumber != -1) { return "无法为已有编组的学员再次编组"; } if (selectStudents[i].state != LearnState.waiting) { return "无法为训练中的学员进行编组"; } } int number = groups.Count + 1; groups.Add(new GOGroup(selectStudents, number, OnGroupDestroy,contentCtrl));//创建一个新的编组 return null; } /// /// 选择一些学员移除编组 /// /// public string RemoveGroup(List selectStudents) { for (int i = 0; i < selectStudents.Count; i++) { if (selectStudents[i].groupNumber != -1) { groups[selectStudents[i].groupNumber - 1].Remove(selectStudents[i]); } } return null; } /// /// 选择一些学员 点击添加编组 /// /// public string AddGroup() { return null; } /// /// 设置组长 /// /// /// public string SetMaster(List selectStudents) { if (selectStudents.Count > 1) return "组长不能为多人"; if (selectStudents[0].groupNumber==-1) return "未分组的人员无法设为组长"; groups[selectStudents[0].groupNumber - 1].SetMaster(selectStudents[0]); return null; } /// /// 获取组内所有人员 /// /// 组编号 /// public List GetGroupStudents(int groupNumber) { return groups[groupNumber - 1].GetAllStudent(); } //组销毁执行方法 private void OnGroupDestroy(int number) { groups.RemoveAt(number - 1); } }