_xiaofang/xiaofang/Assets/Script/UI/PanelUI/DistributionPanel.cs

149 lines
5.1 KiB
C#
Raw Normal View History

2024-12-19 21:36:02 +08:00
using Newtonsoft.Json.Schema;
using System;
2024-12-19 14:11:11 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DistributionPanel : MonoBehaviour
{
public GameObject personnelLable;
public Transform personnelContent;
public Panel panel;
2024-12-19 21:36:02 +08:00
public SelectScenePanel selectScenePanel;
public JSONReader jsonReader;
2024-12-19 14:11:11 +08:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnClickPeopleWindows()
{
foreach(Transform child in personnelContent)
{
Destroy(child.gameObject);
}
}
2024-12-19 21:36:02 +08:00
public void CreateAllLable()
{
foreach (Transform child in personnelContent)
{
Destroy(child.gameObject);
}
//CreateFirstLable();
foreach (var sceneEntry in panel.sceneDataDictionary)
{
GameObject managerPanelInstance = Instantiate(personnelLable, personnelContent);
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
scenetext.personelPanelText.text = sceneEntry.Key;
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
scenetext.CreatePeopleItem(sceneEntry.Value);
foreach(var scene in sceneEntry.Value)
{
2024-12-20 17:57:13 +08:00
string a=CheckMissingRoles(scene.sceneId);
scenetext.lockText.text = a;
2024-12-23 14:28:02 +08:00
if(a==null)
{
scenetext.lockBg.SetActive(false);
}
else
{
2024-12-23 16:02:57 +08:00
scenetext.lockText.transform.SetParent(scenetext.lockBg.transform);
2024-12-23 14:28:02 +08:00
scenetext.lockBg.SetActive(true);
}
2024-12-19 21:36:02 +08:00
}
}
}
2024-12-19 14:11:11 +08:00
public void CreateFirstLable()
{
GameObject fistLable = Instantiate<GameObject>(personnelLable, personnelContent);
PersonnelInfo personnelItem = fistLable.GetComponent<PersonnelInfo>();
2024-12-19 21:36:02 +08:00
}
2024-12-20 17:57:13 +08:00
public string CheckMissingRoles(string sceneID)
2024-12-19 21:36:02 +08:00
{
List<SelectedInfo> info = null;
2024-12-20 17:57:13 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>е<EFBFBD>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD>Ŀ
foreach (var entry in panel.sceneDataDictionary)
{
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF> List<SelectedInfo><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> sceneID
foreach (var selectedInfo in entry.Value)
{
if (selectedInfo.sceneId == sceneID) // <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> sceneId
{
// <20>ҵ<EFBFBD><D2B5><EFBFBD>Ӧ<EFBFBD><D3A6> List<SelectedInfo>
info = entry.Value;
break;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>˶<EFBFBD>Ӧ<EFBFBD><D3A6> sceneId<49><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
if (info != null)
{
break;
}
}
if (info != null)
{
2024-12-19 21:36:02 +08:00
string roleLimit = jsonReader.GetAreaDateById(int.Parse(sceneID)).RoleLimit;
2024-12-20 17:57:13 +08:00
string[] sceneLimits = roleLimit.Split('|');
// <20><EFBFBD><E6B4A2>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ְҵID<49><44><EFBFBD><EFBFBD>
HashSet<string> selectedDutyIds = new HashSet<string>();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ľ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ȡְҵID
foreach (var selectedInfo in info)
2024-12-19 21:36:02 +08:00
{
2024-12-20 17:57:13 +08:00
selectedDutyIds.Add(selectedInfo.dutyId);
}
// <20>洢ȱ<E6B4A2>ٵ<EFBFBD>ְҵID
List<string> missingDutyIds = new List<string>();
// <20><>ȡѡ<C8A1>еij<D0B5><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѷ<EFBFBD>ID
string selectedSceneId = selectScenePanel.idcidentId.ToString();
string selectedDifficultyId = selectScenePanel.difficultyId.ToString();
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȱ<EFBFBD><C8B1>ְҵ
foreach (var sceneLimit in sceneLimits)
{
string[] limit = sceneLimit.Split(',');
2024-12-19 21:36:02 +08:00
if (limit.Length == 4)
{
2024-12-20 17:57:13 +08:00
string sceneLimitId = limit[0];
string difficultyLimitId = limit[1];
string dutyId = limit[2];
2024-12-23 14:28:02 +08:00
string dutyNum = limit[3];
2024-12-20 17:57:13 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD>ID<49><44><EFBFBD>Ѷ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-23 14:28:02 +08:00
if (sceneLimitId == selectedSceneId && difficultyLimitId == selectedDifficultyId&& dutyNum!="-1")
2024-12-19 21:36:02 +08:00
{
2024-12-20 17:57:13 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȱ<EFBFBD><C8B1>ְҵ
if (!selectedDutyIds.Contains(dutyId))
2024-12-19 21:36:02 +08:00
{
2024-12-20 17:57:13 +08:00
missingDutyIds.Add(dutyId);
2024-12-19 21:36:02 +08:00
}
}
}
}
2024-12-20 17:57:13 +08:00
// <20><><EFBFBD><EFBFBD>ȱ<EFBFBD>ٵ<EFBFBD>ְҵID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (missingDutyIds.Count > 0)
{
string missingCountMessage = <><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + missingDutyIds.Count + "<22><>";
foreach (var missingDutyId in missingDutyIds)
{
// <20><>ȡְҵ<D6B0><D2B5><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD> SetUIText <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡְҵ<D6B0><D2B5><EFBFBD>ƣ<EFBFBD>
2024-12-24 23:00:40 +08:00
missingCountMessage += jsonReader.SetUIText(missingDutyId) + " ";
2024-12-20 17:57:13 +08:00
}
return missingCountMessage;
}
else
{
return null; // <20><><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B7B5><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>Ϣ
}
2024-12-19 21:36:02 +08:00
}
else
{
2024-12-20 17:57:13 +08:00
return <><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> sceneID <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>"; // û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> sceneID <20><>Ϣ
2024-12-19 21:36:02 +08:00
}
2024-12-19 14:11:11 +08:00
}
}