//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, April 16, 2019 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; namespace vnxbqy.UI { public class TipPetMountSkillWidget : MonoBehaviour { [SerializeField] ScrollerController m_Scroll; public void Display(PetMountTipWin.ShowType showType, int itemId) { var skillInfos = new List(); switch (showType) { case PetMountTipWin.ShowType.Pet: var petId = PetInfoConfig.GetItemUnLockPet(itemId); var petConfig = PetInfoConfig.Get(petId); var min = Mathf.Min(petConfig.SkillID.Length, petConfig.SkillUnLock.Length); for (var i = 0; i < min; i++) { var skillId = petConfig.SkillID[i]; var unlockLevel = petConfig.SkillUnLock[i]; skillInfos.Add(new SkillInfo() { skillId = skillId, unlockLevel = unlockLevel }); } break; case PetMountTipWin.ShowType.Mount: break; } m_Scroll.OnRefreshCell -= OnRefreshCell; m_Scroll.OnRefreshCell += OnRefreshCell; //m_Scroll.Init(skillInfos); m_Scroll.Refresh(); foreach (var skillinfo in skillInfos) { CellInfo info = new CellInfo(); info.infoInt1 = skillinfo.unlockLevel; m_Scroll.AddCell(ScrollerDataType.Header, skillinfo.skillId, info); } m_Scroll.Restart(); } void OnRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell as TipPetMountSkillBehaviour; _cell.Display(cell.index, cell.info.Value.infoInt1); } public struct SkillInfo { public int skillId; public int unlockLevel; } } }