154 lines
6.3 KiB
C#
154 lines
6.3 KiB
C#
|
using Obi;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using static UnityEditor.Progress;
|
|||
|
|
|||
|
public class RequirementPanel : MonoBehaviour
|
|||
|
{
|
|||
|
[Header("<22><><EFBFBD><EFBFBD>")]
|
|||
|
public GameObject sceneLable;
|
|||
|
[Header("<22><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>content")]
|
|||
|
public Transform content;
|
|||
|
[Header("<22>رհ<D8B1>ť")]
|
|||
|
public Button closeBtn;
|
|||
|
public Panel panel;
|
|||
|
public SelectScenePanel selectScenePanel;
|
|||
|
public JSONReader jsonReader;
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
closeBtn.onClick.AddListener(() => ClosePanel());
|
|||
|
}
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
//<2F><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lable
|
|||
|
|
|||
|
public void LoadingSceneLable()
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
foreach (Transform child in content)
|
|||
|
{
|
|||
|
Destroy(child.gameObject);
|
|||
|
}
|
|||
|
// <20><><EFBFBD>ڼ<EFBFBD>¼<EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>صij<D8B5><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
HashSet<string> loadedSceneNames = new HashSet<string>();
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD>
|
|||
|
foreach (var sceneEntry in jsonReader.locationDictionary)
|
|||
|
{
|
|||
|
// <20><><EFBFBD>ֽ<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
|||
|
string[] limit = sceneEntry.Value.RoleLimit.Split('|');
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ
|
|||
|
bool missingJob = false;
|
|||
|
foreach (var entry in limit)
|
|||
|
{
|
|||
|
string[] limitDetails = entry.Split(',');
|
|||
|
if (limitDetails.Length == 4)
|
|||
|
{
|
|||
|
string sceneLimitId = limitDetails[0]; // <20>¹<EFBFBD>λ<EFBFBD><CEBB>ID
|
|||
|
string difficultyLimitId = limitDetails[1]; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѷ<EFBFBD>ID
|
|||
|
string dutyId = limitDetails[2]; // ְҵID
|
|||
|
string dutyNum = limitDetails[3]; // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (dutyNum == "-1")
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
if (sceneLimitId == selectScenePanel.idcidentId.ToString() && difficultyLimitId == selectScenePanel.difficultyId.ToString())
|
|||
|
{
|
|||
|
// <20>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (loadedSceneNames.Contains(sceneEntry.Key.ToString()))
|
|||
|
{
|
|||
|
continue; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
// ʵ<><CAB5><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
GameObject managerPanelInstance = Instantiate(sceneLable, content);
|
|||
|
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
|
|||
|
scenetext.personelPanelText.text = jsonReader.SetUIText(sceneEntry.Value.Name.ToString());
|
|||
|
loadedSceneNames.Add(sceneEntry.Key.ToString()); // <20><>¼<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD>
|
|||
|
if (dutyNum == "-1")
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
foreach (var Entry in panel.sceneDataDictionary)
|
|||
|
{
|
|||
|
string sceneId = Entry.Key;
|
|||
|
List<SelectedInfo> selectedInfoList = Entry.Value; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
|
|||
|
foreach (var selectedInfo in selectedInfoList)
|
|||
|
{
|
|||
|
if (selectedInfo.sceneId == sceneEntry.Key.ToString())
|
|||
|
{
|
|||
|
scenetext.LoadingpersonelItem(scenetext.personelContent, selectedInfo.name.ToString());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Debug.Log($"<22><><EFBFBD><EFBFBD> {sceneEntry.Key} û<><C3BB><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// <20><><EFBFBD>Ҹó<D2B8><C3B3><EFBFBD><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD>
|
|||
|
foreach (var sceneData in panel.sceneDataDictionary)
|
|||
|
{
|
|||
|
var dutyCount = new Dictionary<string, int>();
|
|||
|
|
|||
|
foreach (var npc in sceneData.Value)
|
|||
|
{
|
|||
|
if (npc.sceneId == sceneEntry.Key.ToString())
|
|||
|
{
|
|||
|
// ͳ<>Ƹ<EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (dutyCount.ContainsKey(npc.dutyId))
|
|||
|
{
|
|||
|
dutyCount[npc.dutyId]++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
dutyCount[npc.dutyId] = 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// <20>жϸ<D0B6>ְҵ<D6B0>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>
|
|||
|
int requiredDutyNum = int.Parse(dutyNum);
|
|||
|
if (!dutyCount.ContainsKey(dutyId))
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ְҵ
|
|||
|
Debug.Log($"!!!!!!!!!!!!!!!!!!<21><><EFBFBD><EFBFBD> {sceneEntry.Key} ȱ<><C8B1>ְҵ {dutyId}");
|
|||
|
int missingNum = requiredDutyNum;
|
|||
|
scenetext.lockText.text = $"ȱ<><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{missingNum}<7D><>{jsonReader.SetUIText(dutyId)}";
|
|||
|
missingJob = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// <20>жϸ<D0B6>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
|
|||
|
int currentDutyCount = dutyCount[dutyId];
|
|||
|
if (currentDutyCount < requiredDutyNum)
|
|||
|
{
|
|||
|
int missingNum = requiredDutyNum - currentDutyCount;
|
|||
|
scenetext.lockText.text = $"ȱ<><C8B1>{missingNum}<7D><>{jsonReader.SetUIText(dutyId)}";
|
|||
|
missingJob = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>κη<CEBA><CEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְҵ<D6B0><D2B5><EFBFBD><EFBFBD>ʾȱ<CABE>ٵ<EFBFBD>ְҵ
|
|||
|
if (!missingJob)
|
|||
|
{
|
|||
|
scenetext.lockText.text = $"ȱ<><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{dutyNum}<7D><>{jsonReader.SetUIText(dutyId)}";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void ClosePanel()
|
|||
|
{
|
|||
|
transform.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|