_xiaofang/xiaofang/Assets/Script/UI/PanelUI/DistributionPanel.cs
2024-12-24 23:00:40 +08:00

150 lines
5.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json.Schema;
using System;
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;
public SelectScenePanel selectScenePanel;
public JSONReader jsonReader;
// 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);
}
}
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)
{
string a=CheckMissingRoles(scene.sceneId);
scenetext.lockText.text = a;
if(a==null)
{
scenetext.lockBg.SetActive(false);
}
else
{
scenetext.lockText.transform.SetParent(scenetext.lockBg.transform);
scenetext.lockBg.SetActive(true);
}
}
}
}
public void CreateFirstLable()
{
GameObject fistLable = Instantiate<GameObject>(personnelLable, personnelContent);
PersonnelInfo personnelItem = fistLable.GetComponent<PersonnelInfo>();
}
public string CheckMissingRoles(string sceneID)
{
List<SelectedInfo> info = null;
// <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)
{
string roleLimit = jsonReader.GetAreaDateById(int.Parse(sceneID)).RoleLimit;
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)
{
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(',');
if (limit.Length == 4)
{
string sceneLimitId = limit[0];
string difficultyLimitId = limit[1];
string dutyId = limit[2];
string dutyNum = limit[3];
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ϳ<EFBFBD><CFB3><EFBFBD>ID<49><44><EFBFBD>Ѷ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (sceneLimitId == selectedSceneId && difficultyLimitId == selectedDifficultyId&& dutyNum!="-1")
{
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȱ<EFBFBD><C8B1>ְҵ
if (!selectedDutyIds.Contains(dutyId))
{
missingDutyIds.Add(dutyId);
}
}
}
}
// <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>
missingCountMessage += jsonReader.SetUIText(missingDutyId) + " ";
}
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>Ϣ
}
}
else
{
return <><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> sceneID <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>"; // û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> sceneID <20><>Ϣ
}
}
}