//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, August 16, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //神兽强化 namespace Snxxz.UI { public class GodBeastClass { public int GodBeastNumber;//神兽编号 public int GodBeastPart;//神兽部位 public int GodBeastLv;//神兽等级 public int GodBeasProficiency;//熟练度 public int GodBeastQuality;//神兽品质 public int GodBeastStar;//神兽星级 public int LocationMarker;//位置标记 public int EquipScore;//装备评分 } public class GodBeastReinforcementWin : Window { [SerializeField] ScrollerController m_ScrollerController; [SerializeField] GodBeastSlidingList m_GodBeastSlidingList; [SerializeField] GameObject m_Listprompt_Text; [SerializeField] GodBeastAttributes m_GodBeastAttributes; DogzModel Dogz_model; DogzModel dogz_model { get { return Dogz_model ?? (Dogz_model = ModelCenter.Instance.GetModel()); } } public static event Action ChooseToModify; private List GodBeastList = new List(); private int CurrentlySelected = 0; #region Built-in protected override void BindController() { } protected override void AddListeners() { } protected override void OnPreOpen() { CurrentlySelected = 0; GetGodBeast();//获取神兽强化装备信息 if (GodBeastList.Count > 0) { CurrentlySelected = GodBeastList[0].LocationMarker; m_ScrollerController.JumpIndex(0); } m_ScrollerController.OnRefreshCell += OnRefreshGridCell; OnCreateGridLineCell(m_ScrollerController); m_GodBeastSlidingList.Init(); m_GodBeastAttributes.Init(); m_GodBeastAttributes.GetGodBeastLocationMarker(CurrentlySelected); } protected override void OnAfterOpen() { } protected override void OnPreClose() { m_ScrollerController.OnRefreshCell -= OnRefreshGridCell; } protected override void OnAfterClose() { } #endregion private void GetGodBeast()//存储神兽强化列表数据和排序 { GodBeastList.Clear(); var DogzEquipDict = dogz_model.dogzAssistStateDict; foreach (var key in DogzEquipDict.Keys) { if (DogzEquipDict[key] == 1) { List itemModel = dogz_model.GetDogzEquips(key); for (int i = 0; i < itemModel.Count; i++) { GodBeastClass godBeastClass = new GodBeastClass(); godBeastClass.GodBeastNumber = key; godBeastClass.GodBeastPart = itemModel[i].EquipPlace; godBeastClass.GodBeastQuality = itemModel[i].chinItemModel.ItemColor; godBeastClass.GodBeastStar = itemModel[i].chinItemModel.StarLevel; godBeastClass.EquipScore = itemModel[i].equipScore; var IudetDogzEquipPlus = itemModel[i].GetUseDataModel((int)ItemUseDataKey.Def_IudetDogzEquipPlus);// 神兽装备强化信息列表 [强化等级, 强化熟练度] if (IudetDogzEquipPlus == null) { godBeastClass.GodBeastLv = 0; godBeastClass.GodBeasProficiency = 0; } else { godBeastClass.GodBeastLv = IudetDogzEquipPlus[0]; godBeastClass.GodBeasProficiency = IudetDogzEquipPlus[1]; } godBeastClass.LocationMarker=itemModel[i].EquipPlace*100+key; GodBeastList.Add(godBeastClass); } } } GodBeastList.Sort(Compare); } int Compare(GodBeastClass x, GodBeastClass y) { if (x.GodBeastQuality.CompareTo(y.GodBeastQuality) != 0)//品质 { return -x.GodBeastQuality.CompareTo(y.GodBeastQuality); } if (x.GodBeastStar.CompareTo(y.GodBeastStar) != 0)//星级 { return -x.GodBeastStar.CompareTo(y.GodBeastStar); } if (x.GodBeastPart.CompareTo(y.GodBeastPart) != 0)//装备位 { return x.GodBeastPart.CompareTo(y.GodBeastPart); } if (x.GodBeastLv.CompareTo(y.GodBeastLv) != 0)//强化等级 { return -x.GodBeastLv.CompareTo(y.GodBeastLv); } if (x.GodBeasProficiency.CompareTo(y.GodBeasProficiency) != 0)//熟练度 { return -x.GodBeasProficiency.CompareTo(y.GodBeasProficiency); } if (x.EquipScore.CompareTo(y.EquipScore) != 0)//装备评分 { return -x.EquipScore.CompareTo(y.EquipScore); } return 1; } void OnCreateGridLineCell(ScrollerController gridCtrl) { gridCtrl.Refresh(); if (GodBeastList.Count > 0) { m_Listprompt_Text.SetActive(false); } else { m_Listprompt_Text.SetActive(true); } for (int i = 0; i < GodBeastList.Count; i++) { int locationMarker = GodBeastList[i].LocationMarker; gridCtrl.AddCell(ScrollerDataType.Header, locationMarker); } gridCtrl.Restart(); } private void OnRefreshGridCell(ScrollerDataType type, CellView cell) { GodBeastEntry godBeastEntry = cell.GetComponent(); int locationMarker = cell.index; godBeastEntry.GetGodBeastLocationMarker(locationMarker, CurrentlySelected); godBeastEntry.GodBeastButton.RemoveAllListeners(); godBeastEntry.GodBeastButton.AddListener(()=> { if (locationMarker != CurrentlySelected) { CurrentlySelected = locationMarker; m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 if (ChooseToModify != null) { ChooseToModify(CurrentlySelected); } } }); } } }