//-------------------------------------------------------- 
 | 
//    [Author]:           第二世界 
 | 
//    [  Date ]:           Friday, April 26, 2019 
 | 
//-------------------------------------------------------- 
 | 
using UnityEngine; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine.UI; 
 | 
using System; 
 | 
  
 | 
namespace vnxbqy.UI 
 | 
{ 
 | 
    public class OtherPlayerSuitWidget : MonoBehaviour 
 | 
    { 
 | 
        [SerializeField] Text m_SuitName; 
 | 
        [SerializeField] StarToggle[] m_StarToggles; 
 | 
        [SerializeField] Text[] m_SuitEquipNames; 
 | 
  
 | 
        [SerializeField] EquipSuitPropertyBar m_TwoSuit; 
 | 
        [SerializeField] EquipSuitPropertyBar m_FiveSuit; 
 | 
        [SerializeField] Text m_EightSuitTitle; 
 | 
        [SerializeField] Text m_EightSuitDescription; 
 | 
  
 | 
        Dictionary<int, int> placeStars; 
 | 
        int level; 
 | 
        int job; 
 | 
        int twoSuitLevel; 
 | 
        int fiveSuitLevel; 
 | 
        int eightSuitLevel; 
 | 
  
 | 
        public void Display(OtherPlayerEquipModel.SuitInfo suitInfo) 
 | 
        { 
 | 
            placeStars = suitInfo.placeStars; 
 | 
            level = suitInfo.level; 
 | 
            job = suitInfo.job; 
 | 
            twoSuitLevel = suitInfo.suitLevels[EquipSuitType.TwoSuit]; 
 | 
            fiveSuitLevel = suitInfo.suitLevels[EquipSuitType.FiveSuit]; 
 | 
            eightSuitLevel = suitInfo.suitLevels[EquipSuitType.EightSuit]; 
 | 
  
 | 
            m_SuitName.text = EquipSuitConfig.GetConfigs(job, level, EquipSuitType.TwoSuit)[0].name; 
 | 
            var maxLevel = EquipStarModel.GetMaxStarLevel(level); 
 | 
            m_StarToggles[3].SetActive(maxLevel >= 9); 
 | 
            m_StarToggles[2].SetActive(maxLevel >= 6); 
 | 
            m_StarToggles[1].SetActive(maxLevel >= 3); 
 | 
            m_StarToggles[0].SetActive(true); 
 | 
  
 | 
            m_StarToggles[3].AddListener(() => { DisplaySuitInfo(9); }); 
 | 
            m_StarToggles[2].AddListener(() => { DisplaySuitInfo(6); }); 
 | 
            m_StarToggles[1].AddListener(() => { DisplaySuitInfo(3); }); 
 | 
            m_StarToggles[0].AddListener(() => { DisplaySuitInfo(0); }); 
 | 
  
 | 
            m_StarToggles[0].Select(); 
 | 
            DisplaySuitInfo(0); 
 | 
        } 
 | 
  
 | 
        void DisplaySuitInfo(int star) 
 | 
        { 
 | 
            DisplaySuitCollections(star); 
 | 
            DisplayProperty(star); 
 | 
        } 
 | 
  
 | 
        void DisplaySuitCollections(int star) 
 | 
        { 
 | 
            for (int i = 1; i <= 8; i++) 
 | 
            { 
 | 
                var hasSuit = placeStars.ContainsKey(i) && placeStars[i] >= star; 
 | 
                m_SuitEquipNames[i - 1].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true); 
 | 
                m_SuitEquipNames[i - 1].text = UIHelper.GetEquipPlaceName(i); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        void DisplayProperty(int star) 
 | 
        { 
 | 
            var twoConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit); 
 | 
            var fiveConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.FiveSuit); 
 | 
            var eightConfigs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.EightSuit); 
 | 
  
 | 
            var config = twoConfigs.Find(x => { return x.star == star; }); 
 | 
            var properties = new List<Int2>(); 
 | 
            var twoSuit = new EquipSuitPropertyEntry() 
 | 
            { 
 | 
                type = EquipSuitType.TwoSuit, 
 | 
                actived = twoSuitLevel >= star, 
 | 
                properties = new List<Int2>(config.attr), 
 | 
            }; 
 | 
  
 | 
            config = fiveConfigs.Find(x => { return x.star == star; }); 
 | 
            properties = new List<Int2>(); 
 | 
            var fiveSuit = new EquipSuitPropertyEntry() 
 | 
            { 
 | 
                type = EquipSuitType.FiveSuit, 
 | 
                actived = fiveSuitLevel >= star, 
 | 
                properties = new List<Int2>(config.attr), 
 | 
            }; 
 | 
  
 | 
            config = eightConfigs.Find(x => { return x.star == star; }); 
 | 
  
 | 
            m_TwoSuit.Display(twoSuit, true); 
 | 
            m_FiveSuit.Display(fiveSuit, true); 
 | 
            m_EightSuitDescription.text = GetEightSuitDescription(config.id); 
 | 
            var color = UIHelper.GetUIColor(eightSuitLevel >= star ? TextColType.Green : TextColType.White, true); 
 | 
            m_EightSuitTitle.color = color; 
 | 
            m_EightSuitDescription.color = color; 
 | 
        } 
 | 
  
 | 
        public void Dispose() 
 | 
        { 
 | 
  
 | 
        } 
 | 
  
 | 
        private string GetEightSuitDescription(int suitId) 
 | 
        { 
 | 
            var config = EquipSuitConfig.Get(suitId); 
 | 
            if (config.skillID > 0) 
 | 
            { 
 | 
                return config.description; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                return PlayerPropertyConfig.GetFullDescription(config.attr[0]); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        [System.Serializable] 
 | 
        public class StarToggle 
 | 
        { 
 | 
            public int star; 
 | 
            public Text title; 
 | 
            public Toggle toggle; 
 | 
  
 | 
            Action onSelect; 
 | 
  
 | 
            public void SetActive(bool active) 
 | 
            { 
 | 
                title.SetActive(active); 
 | 
                toggle.interactable = active; 
 | 
                if (active) 
 | 
                { 
 | 
                    toggle.SetListener(OnValueChange); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    toggle.RemoveAllListeners(); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            public void Select() 
 | 
            { 
 | 
                toggle.isOn = true; 
 | 
            } 
 | 
  
 | 
            public void AddListener(Action callBack) 
 | 
            { 
 | 
                onSelect = callBack; 
 | 
            } 
 | 
  
 | 
            private void OnValueChange(bool value) 
 | 
            { 
 | 
                if (value) 
 | 
                { 
 | 
                    if (onSelect != null) 
 | 
                    { 
 | 
                        onSelect(); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
  
 | 
        } 
 | 
  
 | 
    } 
 | 
  
 | 
} 
 |