using System.Collections.Generic; using Fort23.UTool; using GameLogic.Bag; using UnityEngine; namespace Fort23.Mono { [UIBinding(prefab = "ProfessionEquipmentPanel" )] public partial class ProfessionEquipmentPanel : UIPanel { private void Init() { } protected override void AddEvent() { } protected override void DelEvent() { } public override void AddButtonEvent() { btnBack.onClick.AddListener(OnclickBack); btnZs.onClick.AddListener(OnclickZS); btnFs.onClick.AddListener(OnclickFS); btnMs.onClick.AddListener(OnclickMS); btnYx.onClick.AddListener(OnclickYX); } private async void OnclickZS() { OpenSpecificProfessionEquipmentPanel(1); } private async void OnclickFS() { OpenSpecificProfessionEquipmentPanel(2); } private async void OnclickMS() { OpenSpecificProfessionEquipmentPanel(3); } private async void OnclickYX() { OpenSpecificProfessionEquipmentPanel(4); } /// /// 打开对应职业的装备面板 /// /// 1战士;2法师;3牧师;4游侠 private async void OpenSpecificProfessionEquipmentPanel(int zy) { SpecificProfessionEquipmentPanel specificProfessionEquipmentPanel = await UIManager.Instance.LoadAndOpenPanel(null); specificProfessionEquipmentPanel.InitPanel(zy); } private void OnclickBack() { UIManager.Instance.HideUIUIPanel(this); } public async void InitPanel() { SetZyEqs(zsEqs, 1); SetZyEqs(fsEqs, 2); SetZyEqs(msEqs, 3); SetZyEqs(yxEqs, 4); } private async void SetZyEqs(List eqs, int zy) { foreach (GameObject eqGo in eqs) { WidgetItem eqItem = await UIManager.Instance. CreateGComponentForObject(eqGo, null, root:eqGo.GetComponent()); LogTool.Log(eqGo + "设置"); eqItem.SetEmpty(); } if (BagController.Instance.EqDic.ContainsKey(zy)) { List eqList = BagController.Instance.EqDic[zy]; foreach (ItemInfo eqInfo in eqList) { if (eqInfo.eqInfo.isEquip) { // if(eqInfo.eqInfo.basicEquipConfig.Type) GameObject eqGo = eqs[eqInfo.eqInfo.basicEquipConfig.Type - 1] as GameObject; WidgetItem eqItem = await UIManager.Instance. CreateGComponentForObject(eqGo, null, root:eqGo.GetComponent()); eqItem.InitWidget(eqInfo); } } } } } }