//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Wednesday, February 27, 2019 //-------------------------------------------------------- using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; namespace vnxbqy.UI { public class EquipSuitPropertyWidget : MonoBehaviour { [SerializeField] Text m_SuitName; [SerializeField] StarToggle[] m_StarToggles; [SerializeField] Text[] m_SuitEquipNames; [SerializeField] UIEffect[] m_SuitEquipEffects; [SerializeField] EquipSuitPropertyBar m_TwoSuit; [SerializeField] EquipSuitPropertyBar m_FiveSuit; [SerializeField] Text m_EightSuitTitle; [SerializeField] Text m_EightSuitDescription; [SerializeField] UIEffect[] m_SuitLevelEffects; [SerializeField] EquipSuitActiveHand m_SuitActive2; [SerializeField] EquipSuitActiveHand m_SuitActive5; [SerializeField] EquipSuitActiveHand m_SuitActive8; [SerializeField] RedpointBehaviour[] redpointList; EquipModel model { get { return ModelCenter.Instance.GetModel(); } } int level; public void Init(int level, int eightSuitLevel) { this.level = level; var maxLevel = EquipStarModel.GetMaxStarLevel(level); for (int i = 0; i < m_StarToggles.Length; i++) { redpointList[i].redpointId = (200100 + this.level) * 100 + m_StarToggles[i].star; m_StarToggles[i].SetActive(maxLevel >= m_StarToggles[i].star); } m_SuitName.text = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit)[0].name; int selectIndex = model.GetSuitRepoindStar(level); if (selectIndex != -1) { m_StarToggles[selectIndex].Select(); return; } int jumpIndex = eightSuitLevel / 3 + 1; if (eightSuitLevel < 0) { jumpIndex = 0; } if (jumpIndex >= m_StarToggles.Length) { m_StarToggles[0].Select(); } else { m_StarToggles[jumpIndex].Select(); } } public void DisplaySuitPlaces(List places) { for (int i = 1; i <= 8; i++) { var hasSuit = places.Contains(i); m_SuitEquipNames[i - 1].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true); m_SuitEquipNames[i - 1].text = UIHelper.GetEquipPlaceName(i); } } public void DisplaySuitPlaceEffects(List places) { foreach (var place in places) { m_SuitEquipEffects[place - 1].Play(); model.RecordSuitPlaceEffectPlay(new Int2(this.level, place)); } } public void DisplayProperty(EquipSuitProperty property) { m_TwoSuit.Display(property.twoSuit, true, property.twoSuit.actived && property.handActived2); m_FiveSuit.Display(property.fiveSuit, true, property.fiveSuit.actived && property.handActived5); m_EightSuitDescription.text = GetEightSuitDescription(property.eightSuitId); var color = UIHelper.GetUIColor(property.eightActived && property.handActived8 ? TextColType.Green : TextColType.White, true); m_EightSuitTitle.color = color; m_EightSuitDescription.color = color; m_SuitActive2.DisPlay(property.twoSuit.actived && !property.handActived2, property.level, property.suitID, 2, property.star); m_SuitActive5.DisPlay(property.fiveSuit.actived && !property.handActived5, property.level, property.suitID, 5, property.star); m_SuitActive8.DisPlay(property.eightActived && !property.handActived8, property.level, property.suitID, 8, property.star); } public void DisplaySuitLevelEffects(EquipSuitActive suitActive) { if (suitActive.twoActived) { m_SuitLevelEffects[0].Play(); model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 2)); } if (suitActive.fiveActived) { m_SuitLevelEffects[1].Play(); model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 5)); } if (suitActive.eightActived) { m_SuitLevelEffects[2].Play(); model.RecordSuitLevelEffectPlay(new Int3(suitActive.level, suitActive.star, 8)); if (!model.IsSetAppearanceHinted(suitActive.level)) { model.RecordSuitSetAppearanceHint(suitActive.level); var equipSet = model.GetEquipSet(suitActive.level); var config = RealmConfig.Get(equipSet.realm); ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("WearRealmEquip", config.NameEx, config.NameEx), (bool ok) => { if (ok) { model.SetAppearance(suitActive.level); } } ); } } } 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; EquipModel model { get { return ModelCenter.Instance.GetModel(); } } public void SetActive(bool active) { toggle.isOn = false; toggle.SetActive(active); toggle.interactable = active; if (active) { toggle.SetListener(OnValueChange); } else { toggle.RemoveAllListeners(); } } public void Select() { toggle.isOn = true; } private void OnValueChange(bool value) { if (value) { model.SelectSuitStarLevel(star); } } } } }