人员数据上传

This commit is contained in:
lq 2024-12-12 15:21:07 +08:00
parent 3465b0042c
commit e34c97432c
10 changed files with 57 additions and 32 deletions

View File

@ -2256,6 +2256,7 @@ MonoBehaviour:
duty: duty:
scene: scene:
dutyId: 0 dutyId: 0
peopleId:
peopleList: [] peopleList: []
userInfo: {fileID: 1201261371} userInfo: {fileID: 1201261371}
managerPanel1: {fileID: 617308873} managerPanel1: {fileID: 617308873}

View File

@ -385,7 +385,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 488, y: -278.8} m_AnchoredPosition: {x: 488, y: -278.8}
m_SizeDelta: {x: 640, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &131408495 --- !u!222 &131408495
CanvasRenderer: CanvasRenderer:
@ -494,7 +494,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 488, y: -498.8} m_AnchoredPosition: {x: 488, y: -498.8}
m_SizeDelta: {x: 300, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &142787312 --- !u!114 &142787312
MonoBehaviour: MonoBehaviour:

View File

@ -56,7 +56,7 @@ public class PlayerList//
} }
public class NpcList//NPC列表 public class NpcList//NPC列表
{ {
public string npcId;//NPC±àºÅ-------------------------------±ØÐë public string npcId;//NPC±àºÅ--------------------------------±ØÐë
public string areaId;//区域编号------------------------------必须 public string areaId;//区域编号------------------------------必须
public int birthAreaId;//数量--------------------------------必须 public int birthAreaId;//数量--------------------------------必须
} }

View File

@ -18,8 +18,8 @@ public class SelectedInfo
public string duty;//职责 public string duty;//职责
public string scene;//场景名 public string scene;//场景名
public string leader;//是否组长 public string leader;//是否组长
public int sceneId;//场景Id public string sceneId;//场景Id
public int dutyId;//职责的Id public string dutyId;//职责的Id
public string peopleId;//角色Id public string peopleId;//角色Id
} }
@ -115,18 +115,27 @@ public class Panel : MonoBehaviour
PlayerListResponse playerListResponse=await userInfo.GetPlayerList(); PlayerListResponse playerListResponse=await userInfo.GetPlayerList();
foreach(PlayerListData player in playerListResponse.data) foreach(PlayerListData player in playerListResponse.data)
{ {
Debug.Log("Player Name: " + player.Id); Debug.Log("UserName: " + player.UserName);
Debug.Log("Id: " + player.Id);
Debug.Log("CompanyId: " + player.CompanyId);
Debug.Log("UserId: " + player.UserId);
Debug.Log("IsAdmin: " + player.IsAdmin);
Debug.Log("Status: " + player.Status);
Debug.Log("Remark: " + player.Remark);
Debug.Log("DepartmentName: " + player.DepartmentName);
Debug.Log("PostName: " + player.PostName);
Debug.Log("NickName: " + player.NickName);
Debug.Log("CreateTime: " + player.CreateTime);
GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent); GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent);
PeopleItem peopleItem = item.GetComponent<PeopleItem>(); PeopleItem peopleItem = item.GetComponent<PeopleItem>();
peopleItem.nameText.text = player.NickName; peopleItem.nameText.text = player.NickName;
peopleItem.peopleId = player.Id; peopleItem.peopleId = player.UserId;
Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>(); Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>();
peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson)); peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson));
peopleList.Add(item);// 将每个实例化的角色添加到列表中 peopleList.Add(item);// 将每个实例化的角色添加到列表中
} }
} }
//动态加载职责 //动态加载职责
public void DynamicLoadingDuty(int id) public void DynamicLoadingDuty(int id)
{ {
@ -206,8 +215,8 @@ public class Panel : MonoBehaviour
Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>(); Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene)); scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
// 设置limitNum // 设置limitNum
sceneItem.sceneId = npcData.Key; sceneItem.sceneId = npcData.Key.ToString();
sceneItem.dutyId = int.Parse(roleLimits[1]); sceneItem.dutyId = roleLimits[1];
sceneItem.limitNum = int.Parse(roleLimits[2]); sceneItem.limitNum = int.Parse(roleLimits[2]);
sceneItem.sceneName.text = npcData.Value.Note; sceneItem.sceneName.text = npcData.Value.Note;
// 将每个实例化的角色添加到列表中 // 将每个实例化的角色添加到列表中
@ -276,10 +285,10 @@ public class Panel : MonoBehaviour
} }
else else
{ {
int accidentLocationId = int.Parse(roleLimits[0]); // 事故位置ID string accidentLocationId = roleLimits[0]; // 事故位置ID
int roleId = int.Parse(roleLimits[1]); // 职业ID string roleId = roleLimits[1]; // 职业ID
int minRequired = int.Parse(roleLimits[2]); // 最低要求人数 int minRequired = int.Parse(roleLimits[2]); // 最低要求人数
if (accidentLocationId == selectScenePanel.idcidentId && roleId == id) if (accidentLocationId == selectScenePanel.idcidentId.ToString() && roleId == id.ToString())
{ {
GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount); GameObject item = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
SceneItem sceneItem = item.GetComponent<SceneItem>(); SceneItem sceneItem = item.GetComponent<SceneItem>();
@ -297,7 +306,7 @@ public class Panel : MonoBehaviour
} }
Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>(); Button scenebutton = item.transform.Find("TextBtn").GetComponent<Button>();
scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene)); scenebutton.onClick.AddListener(() => OnSceneItemClicked(item, Color.green, selectedScene));
sceneItem.sceneId = npcData.Key; sceneItem.sceneId = npcData.Key.ToString();
sceneItem.dutyId = accidentLocationId; sceneItem.dutyId = accidentLocationId;
sceneItem.limitNum = minRequired; sceneItem.limitNum = minRequired;
sceneItem.sceneName.text = npcData.Value.Note; sceneItem.sceneName.text = npcData.Value.Note;
@ -310,7 +319,7 @@ public class Panel : MonoBehaviour
} }
// 获取当前该位置该职业的已添加人数 // 获取当前该位置该职业的已添加人数
private int GetCurrentPeopleCount(int accidentLocationId, int roleId) private int GetCurrentPeopleCount(string accidentLocationId, string roleId)
{ {
int count = 0; int count = 0;
// 遍历场景数据字典,统计该事故位置和职业的人员数量 // 遍历场景数据字典,统计该事故位置和职业的人员数量
@ -357,7 +366,6 @@ public class Panel : MonoBehaviour
// 如果没有达到上限,则可以添加人员信息 // 如果没有达到上限,则可以添加人员信息
if (!isLimitReached) if (!isLimitReached)
{ {
Debug.Log(">>>>>>>>>>>>>>>>>>>"+ selectedInfo.dutyId);
// 通过创建一个新的 SelectedInfo 实例来避免引用同一个对象 // 通过创建一个新的 SelectedInfo 实例来避免引用同一个对象
SelectedInfo newSelectedInfo = new SelectedInfo SelectedInfo newSelectedInfo = new SelectedInfo
{ {
@ -377,6 +385,7 @@ public class Panel : MonoBehaviour
isPersonSelected = false; isPersonSelected = false;
isDutySelected = false; isDutySelected = false;
isSceneSelected = false; isSceneSelected = false;
UploadData(peopleId = selectedInfo.peopleId, selectedInfo.dutyId.ToString(), selectedInfo.sceneId.ToString());
// 改变已添加人员的显示颜色 // 改变已添加人员的显示颜色
UpdatePeopleListVisual(); UpdatePeopleListVisual();
} }
@ -431,10 +440,9 @@ public class Panel : MonoBehaviour
if (buttonText != null && buttonText.tag == Tags.people) // 获取标签为人员的信息 if (buttonText != null && buttonText.tag == Tags.people) // 获取标签为人员的信息
{ {
name = buttonText.text; name = buttonText.text;
PeopleItem peopleItem = buttonText.gameObject.GetComponent<PeopleItem>(); PeopleItem peopleItem = buttonText.gameObject.GetComponentInParent<PeopleItem>();
selectedInfo.name = name; selectedInfo.name = name;
//Debug.LogError("???????????????????"+ peopleItem.peopleId == null); selectedInfo.peopleId = peopleItem.peopleId;
//selectedInfo.peopleId = peopleItem.peopleId;
isPersonSelected = true; // 选择了人员 isPersonSelected = true; // 选择了人员
Debug.LogError(">>>>>>>>>>>>>>>>" + selectedInfo.peopleId); Debug.LogError(">>>>>>>>>>>>>>>>" + selectedInfo.peopleId);
} }
@ -462,7 +470,7 @@ public class Panel : MonoBehaviour
} }
dutyId = item.dutyId; dutyId = item.dutyId;
selectedInfo.duty = duty; selectedInfo.duty = duty;
selectedInfo.dutyId = dutyId; selectedInfo.dutyId = dutyId.ToString();
} }
} }
} }
@ -639,6 +647,23 @@ public class Panel : MonoBehaviour
} }
} }
} }
//上传人员数据
public void UploadData(string userId,string roleId,string areaId)
{
createTemplateInfo.Instance.auth_CreateTemplate.playerList = new List<PlayerList>();
foreach (var peopleItem in sceneDataDictionary)
{
foreach (var peopleInfo in peopleItem.Value)
{
PlayerList playerList = new PlayerList();
playerList.userId = userId;
playerList.roleId = roleId;
playerList.birthAreaId = areaId;
createTemplateInfo.Instance.auth_CreateTemplate.playerList.Add(playerList);
}
}
} }
}

View File

@ -248,7 +248,7 @@ public class EvacuationPanel : MonoBehaviour
LocationData locationData = npcData.Value; LocationData locationData = npcData.Value;
// 如果场景的 ID 匹配当前 NPC 的 ID // 如果场景的 ID 匹配当前 NPC 的 ID
if (locationData.ID == sceneInfo.sceneId) if (locationData.ID == int.Parse(sceneInfo.sceneId))
{ {
// 获取每个区域的 NpcRatio 字段 // 获取每个区域的 NpcRatio 字段
string npcRatio = locationData.NpcRatio; string npcRatio = locationData.NpcRatio;
@ -304,7 +304,7 @@ public class EvacuationPanel : MonoBehaviour
{ {
foreach (var sceneInfo in sceneEntry.Value) foreach (var sceneInfo in sceneEntry.Value)
{ {
LocationData area = js.GetAreaDateById(sceneInfo.sceneId); LocationData area = js.GetAreaDateById(int.Parse(sceneInfo.sceneId));
// 如果NpcRatio不为"-1"表示该场景有效 // 如果NpcRatio不为"-1"表示该场景有效
if (area.NpcRatio != "-1") if (area.NpcRatio != "-1")
{ {

View File

@ -42,10 +42,9 @@ public class MaterialPanel : MonoBehaviour
// 获取所有物品的数量并提交 // 获取所有物品的数量并提交
public void SubmitMaterialData() public void SubmitMaterialData()
{ {
Debug.Log("???????????????????????????????????????/" + materialItems.Count); createTemplateInfo.Instance.auth_CreateTemplate.materialList = new List<MaterialList>();
foreach (var materialItem in materialItems) foreach (var materialItem in materialItems)
{ {
createTemplateInfo.Instance.auth_CreateTemplate.materialList = new List<MaterialList>();
MaterialList materialList = new MaterialList(); MaterialList materialList = new MaterialList();
materialList.materialId = materialItem.materialId; materialList.materialId = materialItem.materialId;
Debug.Log("materialList.materialId--------------------" + materialList.materialId); Debug.Log("materialList.materialId--------------------" + materialList.materialId);

View File

@ -109,7 +109,7 @@ public class SelectScenePanel : MonoBehaviour
Debug.LogError("未知的场景类型"); Debug.LogError("未知的场景类型");
break; break;
} }
item.sceneId = sceneData.Value.ID; item.sceneId = sceneData.Value.ID.ToString();
item.sceneType = sceneData.Value.Type; item.sceneType = sceneData.Value.Type;
if (item.IsOpen) if (item.IsOpen)
{ {
@ -137,7 +137,7 @@ public class SelectScenePanel : MonoBehaviour
{ {
Destroy(child.gameObject); Destroy(child.gameObject);
} }
this.scnenId = item.sceneId; // 获取 Text 组件的文本 this.scnenId = int.Parse(item.sceneId); // 获取 Text 组件的文本
this.sceneName = item.sceneName.text; this.sceneName = item.sceneName.text;
InstantiateSchoolPrefab(scnenId); InstantiateSchoolPrefab(scnenId);
} }

View File

@ -6,7 +6,7 @@ using UnityEngine.UI;
public class PeopleItem : MonoBehaviour public class PeopleItem : MonoBehaviour
{ {
public Text nameText; // 人员名字显示 public Text nameText; // 人员名字显示
public string peopleId;
public Button button; // 按钮,用来选择人员 public Button button; // 按钮,用来选择人员
public Color defaultColor = Color.white; // 默认颜色 public Color defaultColor = Color.white; // 默认颜色
public Color addedColor = Color.gray; // 已添加颜色 public Color addedColor = Color.gray; // 已添加颜色
@ -15,7 +15,7 @@ public class PeopleItem : MonoBehaviour
public string Name { get; private set; } // 角色名字 public string Name { get; private set; } // 角色名字
private bool isAdded; // 是否已添加 private bool isAdded; // 是否已添加
private bool isSelected; // 是否选中 private bool isSelected; // 是否选中
public string peopleId;
public delegate void ClickHandler(); public delegate void ClickHandler();
public event ClickHandler onClick; // 点击事件 public event ClickHandler onClick; // 点击事件

View File

@ -6,14 +6,14 @@ using UnityEngine.UI;
public class SceneItem : MonoBehaviour public class SceneItem : MonoBehaviour
{ {
public int sceneId; public string sceneId;
public int sceneType; public int sceneType;
public Text sceneName; public Text sceneName;
public Image sceneImage; public Image sceneImage;
public Image maskImage; public Image maskImage;
public string roleLimit;//场景限制条件 public string roleLimit;//场景限制条件
public int limitNum;//限制人数 public int limitNum;//限制人数
public int dutyId; public string dutyId;
public JSONReader jsonReader; public JSONReader jsonReader;
public bool IsOpen { get; set; } = true; public bool IsOpen { get; set; } = true;
// Start is called before the first frame update // Start is called before the first frame update

View File

@ -82,7 +82,7 @@ public class JueseChoicePop : MonoBehaviour
{ {
Debug.Log("+++++++++++++++++++++++"+ int.Parse(firstElement)); Debug.Log("+++++++++++++++++++++++"+ int.Parse(firstElement));
Debug.Log("-------------------------"+ selectedInfo.dutyId); Debug.Log("-------------------------"+ selectedInfo.dutyId);
if (selectedInfo.dutyId == int.Parse(firstElement)) if (selectedInfo.dutyId == firstElement)
{ {
GameObject item = GameObject.Instantiate(classmatePrefab, content); GameObject item = GameObject.Instantiate(classmatePrefab, content);
ClassMate classMate = item.GetComponent<ClassMate>(); ClassMate classMate = item.GetComponent<ClassMate>();