| using System; | 
| using System.Collections; | 
| using System.Collections.Generic; | 
|   | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
| namespace vnxbqy.UI | 
| { | 
|     public class FairyLeagueDungeonResourceBehaviour : MonoBehaviour | 
|     { | 
|         [SerializeField] List<CampResource> campRes; | 
|   | 
|         FairyLeagueModel m_Model; | 
|         FairyLeagueModel model | 
|         { | 
|             get | 
|             { | 
|                 return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<FairyLeagueModel>()); | 
|             } | 
|         } | 
|   | 
|         KingFairyModel m_KingFairyModel; | 
|         KingFairyModel kingFairyModel | 
|         { | 
|             get | 
|             { | 
|                 return m_KingFairyModel ?? (m_KingFairyModel = ModelCenter.Instance.GetModel<KingFairyModel>()); | 
|             } | 
|         } | 
|   | 
|         private void OnEnable() | 
|         { | 
|             model.UpdateFairyWarHelpEvent += UpdateMissionEvent; | 
|             UpdateMissionEvent(); | 
|         } | 
|   | 
|         private void UpdateMissionEvent() | 
|         { | 
|             var _help = model.fairyLeagueHelp; | 
|             if (_help.fairyWarHelpInfos == null) | 
|             { | 
|                 return; | 
|             } | 
|             var _camp = PlayerDatas.Instance.baseData.faction; | 
|             for (int i = 0; i < model.fairyLeagueHelp.fairyWarHelpInfos.Length; i++) | 
|             { | 
|                 var _helpInfo = _help.fairyWarHelpInfos[i]; | 
|                 var _campRes = campRes.Find((x) => | 
|                 { | 
|                     return (int)x.campType == i + 1; | 
|                 }); | 
|                 //if(_camp == (int)_campRes.campType&& _campRes.m_ContainerRect.GetSiblingIndex() != 0) | 
|                 //{ | 
|                 //    _campRes.m_ContainerRect.SetAsFirstSibling(); | 
|                 //} | 
|                 _campRes.m_ResourceTxt.text = StringUtility.Contact(_camp == (int)_campRes.campType ? Language.Get("FamilyMatchOurResources") : | 
|                     Language.Get("FamilyMatchEnimyResources"), (int)_helpInfo.ResPoint, "/", model.fairyWarResUpperLimit); | 
|                 _campRes.m_MemberCntTxt.text = StringUtility.Contact(Language.Get("FamilyMatchNumOfPeople"), _helpInfo.MemCount); | 
|                 var _crystalDict = _help.fairyWarCrystalDict; | 
|                 _campRes.m_CrystalCntTxt.text = StringUtility.Contact(Language.Get("FamilyMatchResources"), | 
|                     _crystalDict.ContainsKey(i + 1) ? _crystalDict[i + 1].Length : 0); | 
|                 float _propertyUpper = 0; | 
|                 if (_help.fairyWarEnter.WinCount != null && _help.fairyWarEnter.WinCount[1 - i] != 0 | 
|                     && (model.fairyLeagueSession == 1 || model.BattleChampion())) | 
|                 { | 
|                     var _buffLv = kingFairyModel.GetWinStreakBuffLv(_help.fairyWarEnter.WinCount[1 - i]); | 
|                     SkillConfig _multipleWinBuff = SkillConfig.Get(kingFairyModel.multipleWinBuffTypeId + | 
|                         _buffLv - 1); | 
|                     _propertyUpper += _multipleWinBuff.EffectValue11; | 
|                 } | 
|                 if (_helpInfo.BuffAttrLV != 0) | 
|                 { | 
|                     _propertyUpper += model.GetRandomAttrBuff(_helpInfo.BuffAttrLV).EffectValue11; | 
|                 } | 
|                 _campRes.m_AttrPromoteTxt.text = Language.Get("FamilyMatchAttUp", _propertyUpper / 100); | 
|                 _campRes.m_SpeedTxt.SetActive(_helpInfo.BuffResPointPer > 0); | 
|                 if (_helpInfo.BuffResPointPer > 0) | 
|                 { | 
|                     _campRes.m_SpeedTxt.text = Language.Get("FamilyMatchBuffAccelerate", _helpInfo.BuffResPointPer / 100); | 
|                 } | 
|                 _campRes.m_BuffCntTxt.text = StringUtility.Contact(Language.Get("FamilyMatchBuffResources"), _helpInfo.BuffResPoint); | 
|             } | 
|         } | 
|   | 
|         private void OnDisable() | 
|         { | 
|             model.UpdateFairyWarHelpEvent -= UpdateMissionEvent; | 
|         } | 
|         [Serializable] | 
|         public class CampResource | 
|         { | 
|             public FairyCampType campType; | 
|             public RectTransform m_ContainerRect; | 
|             public Text m_SpeedTxt; | 
|             public Text m_ResourceTxt; | 
|             public Text m_MemberCntTxt; | 
|             public Text m_CrystalCntTxt; | 
|             public Text m_BuffCntTxt; | 
|             public Text m_AttrPromoteTxt; | 
|         } | 
|     } | 
| } |