三级面板重构

This commit is contained in:
lq 2024-12-19 14:11:11 +08:00
parent ebffbfdcf8
commit fd1fac3e63
9 changed files with 107 additions and 50 deletions

View File

@ -523,8 +523,8 @@ MonoBehaviour:
personelPanelText: {fileID: 5900002971283911308}
personelNumText: {fileID: 5900002969924403207}
personelContent: {fileID: 5900002971599260874}
panelInfo: {fileID: 0}
personelItem: {fileID: 6026028542083999128, guid: 93710d87e1c578748b4ef94ce0d38198, type: 3}
firstLablePrefab: {fileID: 0}
--- !u!1 &5900002971283911298
GameObject:
m_ObjectHideFlags: 0
@ -641,7 +641,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 560.5, y: -44}
m_AnchoredPosition: {x: 560.5, y: -109}
m_SizeDelta: {x: 1121, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &5900002971599260725

View File

@ -315,10 +315,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 888f2cd11d6d3ea4c9383ac4808687dc, type: 3}
m_Name:
m_EditorClassIdentifier:
sceneId:
sceneType: 0
sceneName: {fileID: 4948242154808829858}
sceneImage: {fileID: 4948242153488973719}
maskImage: {fileID: 7234877009697728443}
IsOpen: 0
roleLimit:
limitNum: 0
dutyId:
jsonReader: {fileID: 0}
--- !u!1 &4948242154808829860
GameObject:
m_ObjectHideFlags: 0

View File

@ -7,7 +7,7 @@
"Group": "-1",
"GroupLeader": "3",
"IsLeadingNPC": "0",
"ICON": "ICON_312",
"ICON": "UIImage/Vocational/icn_commander",
"WeightLimit": "-1",
"Stats": "-1",
"Skills": "4001,-1|4003,202|4005,-1",
@ -22,7 +22,7 @@
"Group": "-1",
"GroupLeader": "2",
"IsLeadingNPC": "0",
"ICON": "ICON_313",
"ICON": "UIImage/Vocational/icn_commander",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -37,7 +37,7 @@
"Group": "8003",
"GroupLeader": "0",
"IsLeadingNPC": "0",
"ICON": "ICON_314",
"ICON": "UIImage/Vocational/icn_redcue",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -52,7 +52,7 @@
"Group": "-1",
"GroupLeader": "1",
"IsLeadingNPC": "0",
"ICON": "ICON_315",
"ICON": "UIImage/Vocational/icn_redcue",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -67,7 +67,7 @@
"Group": "8005",
"GroupLeader": "0",
"IsLeadingNPC": "0",
"ICON": "ICON_316",
"ICON": "UIImage/Vocational/icn_dedicalrescue",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -82,7 +82,7 @@
"Group": "-1",
"GroupLeader": "1",
"IsLeadingNPC": "0",
"ICON": "ICON_317",
"ICON": "UIImage/Vocational/icn_dedicalrescue",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -97,7 +97,7 @@
"Group": "8001",
"GroupLeader": "0",
"IsLeadingNPC": "1",
"ICON": "ICON_318",
"ICON": "UIImage/Vocational/icn_guidance01",
"WeightLimit": "-1",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -112,7 +112,7 @@
"Group": "8001",
"GroupLeader": "0",
"IsLeadingNPC": "1",
"ICON": "ICON_319",
"ICON": "UIImage/Vocational/icn_guidance02",
"WeightLimit": "-1",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -127,7 +127,7 @@
"Group": "8009",
"GroupLeader": "0",
"IsLeadingNPC": "0",
"ICON": "ICON_320",
"ICON": "UIImage/Vocational/icn_support",
"WeightLimit": "10",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -142,7 +142,7 @@
"Group": "-1",
"GroupLeader": "1",
"IsLeadingNPC": "0",
"ICON": "ICON_321",
"ICON": "UIImage/Vocational/icn_support",
"WeightLimit": "10",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -157,7 +157,7 @@
"Group": "8001",
"GroupLeader": "0",
"IsLeadingNPC": "0",
"ICON": "ICON_322",
"ICON": "UIImage/Vocational/icn_search",
"WeightLimit": "5",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",
@ -172,7 +172,7 @@
"Group": "8001",
"GroupLeader": "0",
"IsLeadingNPC": "1",
"ICON": "ICON_323",
"ICON": "UIImage/Vocational/icn_doormhead",
"WeightLimit": "-1",
"Stats": "1,6.5|2,1.8|3,1|6,100",
"Skills": "4001,-1|4003,202|4005,-1",

View File

@ -2216,6 +2216,7 @@ MonoBehaviour:
scrollRect: {fileID: 1435623615}
panelInfo: {fileID: 618256462}
personnelPanel2: {fileID: 0}
distributionPanel: {fileID: 0}
--- !u!1 &618256458
GameObject:
m_ObjectHideFlags: 0
@ -14120,7 +14121,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -1792, y: 479}
m_SizeDelta: {x: 0, y: 479}
m_Pivot: {x: 0, y: 1}
--- !u!1 &7468736063766177857
GameObject:
@ -15716,9 +15717,9 @@ RectTransform:
m_Father: {fileID: 7468736064579811971}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 917, y: -588.335}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1834, y: 473.3535}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7468736064494885175
@ -15739,7 +15740,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &7468736064548566944
RectTransform:
m_ObjectHideFlags: 0

View File

@ -115,27 +115,27 @@ public class Panel : MonoBehaviour
//动态加载人员
public async void DynamicLoadingPeople()
{
//for(int i=0;i<10;i++)
//{
// GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent);
// PeopleItem peopleItem = item.GetComponent<PeopleItem>();
// peopleItem.nameText.text = "角色1";
// peopleItem.peopleId = "0";
// Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>();
// peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson));
// peopleList.Add(item);// 将每个实例化的角色添加到列表中
//}
PlayerListResponse playerListResponse = await userInfo.GetPlayerList();
foreach (PlayerListData player in playerListResponse.data)
for (int i = 0; i < 10; i++)
{
GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent);
PeopleItem peopleItem = item.GetComponent<PeopleItem>();
peopleItem.nameText.text = player.NickName;
peopleItem.peopleId = player.UserId;
peopleItem.nameText.text = "角色1";
peopleItem.peopleId = "0";
Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>();
peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson));
peopleList.Add(item);// 将每个实例化的角色添加到列表中
}
//PlayerListResponse playerListResponse = await userInfo.GetPlayerList();
//foreach (PlayerListData player in playerListResponse.data)
//{
// GameObject item = GameObject.Instantiate<GameObject>(peoplePrefab, peopleCountent);
// PeopleItem peopleItem = item.GetComponent<PeopleItem>();
// peopleItem.nameText.text = player.NickName;
// peopleItem.peopleId = player.UserId;
// Button peoplebutton = item.transform.Find("TextBtn").GetComponent<Button>();
// peoplebutton.onClick.AddListener(() => OnPeopleItemClicked(item, Color.yellow, selectedPerson));
// peopleList.Add(item);// 将每个实例化的角色添加到列表中
//}
}
//动态加载职责
@ -186,7 +186,7 @@ public class Panel : MonoBehaviour
dutyItem.dutyNameText.text = showText;
dutyItem.leader = npcData.GroupLeader;
dutyItem.dutyId = npcData.ID;
//dutyItem.dutyImage.sprite = Resources.Load<Sprite>("UIImage/Vocational/icn_commander");
dutyItem.dutyImage.sprite = Resources.Load<Sprite>(npcData.ICON);
peopleList.Add(item);
}
}
@ -310,6 +310,7 @@ public class Panel : MonoBehaviour
ManagerPanel.gameObject.SetActive(true);
}
}
//根据选择的职责加载出对应场景
public void SetScene(int id)
{
@ -466,7 +467,6 @@ public class Panel : MonoBehaviour
{
sceneDataDictionary[sceneName] = new List<SelectedInfo>();
}
// 1. 判断整个 sceneDataDictionary 中是否存在相同的人名
SelectedInfo existingPerson = null;
string existingSceneName = null;

View File

@ -0,0 +1,34 @@
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;
// 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 CreateFirstLable()
{
GameObject fistLable = Instantiate<GameObject>(personnelLable, personnelContent);
PersonnelInfo personnelItem = fistLable.GetComponent<PersonnelInfo>();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e79e38f63a45f349ae0255b8ad27430
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -26,6 +26,7 @@ public class ManagerPanel : MonoBehaviour
private Vector3 originalScale; // 记录选中项的原始大小
public Panel panelInfo;
public PersonnelPanel personnelPanel2;
public DistributionPanel distributionPanel;
// Start is called before the first frame update
void Start()
@ -114,20 +115,20 @@ public class ManagerPanel : MonoBehaviour
public void OnClickPeopleWindows()
{
peopleWindowsPrefab.gameObject.SetActive(true);
foreach (Transform child in personnelPanelCount)
{
Destroy(child.gameObject);
}
CreateFirstLable();
foreach (var sceneEntry in panelInfo.sceneDataDictionary)
{
GameObject managerPanelInstance = Instantiate(personnelPanel, personnelPanelCount);
PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
//foreach(var item in panelInfo.peopleList)
scenetext.personelPanelText.text = sceneEntry.Key;
scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
scenetext.CreatePeopleItem(sceneEntry.Value);
}
//foreach (Transform child in personnelPanelCount)
//{
// Destroy(child.gameObject);
//}
//CreateFirstLable();
//foreach (var sceneEntry in panelInfo.sceneDataDictionary)
//{
// GameObject managerPanelInstance = Instantiate(personnelPanel, personnelPanelCount);
// PersonnelPanel scenetext = managerPanelInstance.GetComponent<PersonnelPanel>();
// scenetext.personelPanelText.text = sceneEntry.Key;
// scenetext.personelNumText.text = sceneEntry.Value.Count.ToString();
// scenetext.CreatePeopleItem(sceneEntry.Value);
//}
distributionPanel.CreateFirstLable();
//CreatePeopleItem();
}

View File

@ -40,6 +40,11 @@ public class PersonnelPanel : MonoBehaviour
PersonnelInfo personnelItem = item.GetComponent<PersonnelInfo>();
personnelItem.nameText.text = person.name; // ÉèÖÃÐÕÃû
}
public void CreateSceneItem(SelectedInfo person, Transform parentTransform)
{
GameObject item = Instantiate(personelItem, parentTransform);
PersonnelInfo personnelItem = item.GetComponent<PersonnelInfo>();
}
public void OnClickBtn()
{
transform.gameObject.SetActive(false);