//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Wednesday, September 06, 2017 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using vnxbqy.UI; namespace vnxbqy.UI { public class LocalMapEventPointToggle : ScrollItem { [SerializeField] RectTransform m_LayoutLeft; [SerializeField] ButtonEx m_Button; [SerializeField] TextEx m_Title; [SerializeField] Text m_Description; [SerializeField] Transform m_Selected; [SerializeField] Button m_FlyBoot; [SerializeField] Image m_MonsterType; [SerializeField] FontColorSizeConfig m_FontColor; int m_EventId; MapModel model { get { return ModelCenter.Instance.GetModel(); } } PackModel playerPack { get { return ModelCenter.Instance.GetModel(); } } PlayerMainDate mainModel { get { return ModelCenter.Instance.GetModel(); } } public override void Display(object _data) { base.Display(_data); m_EventId = (int)_data; var mapConfig = MapConfig.Get(PlayerDatas.Instance.baseData.MapID); m_LayoutLeft.SetActive(mapConfig.MapFBType == (int)MapType.OpenCountry && !GeneralDefine.neutralMaps.Contains(PlayerDatas.Instance.baseData.MapID)); DisplayEventInfo(); OnSelected(model.selectedMapEventPoint); model.selectMapEventPointEvent += OnSelected; } public override void Dispose() { base.Dispose(); model.selectMapEventPointEvent -= OnSelected; } private void Awake() { this.m_Button.SetListener(SelectEventPoint); this.m_FlyBoot.SetListener(FlyToEventPoint); } private void DisplayEventInfo() { var config = MapEventPointConfig.Get(this.m_EventId); var npcConfig = NPCConfig.Get(config.NPCID); this.m_Title.text = npcConfig != null ? npcConfig.charName : ""; if (npcConfig.NPCType == 0) { this.m_Description.text = config.NpcDescription; this.m_MonsterType.SetActive(true); } else { if (config.LowLV == config.HighestLV) { this.m_Description.text = Language.Get("Z1024", config.LowLV); } else { if(MapLevelModel.Instance.GetSelectIndex() != 0) { int lowLV = MapLevelModel.Instance.GetSelectLowLV(config.NPCID); if (lowLV == 0) { this.m_Description.text = StringUtility.Contact(Language.Get("Z1024", config.LowLV), "-", config.HighestLV); } else { this.m_Description.text = StringUtility.Contact(Language.Get("Z1024", lowLV), "-", MapLevelModel.Instance.GetSelectHighestLV(config.NPCID)); } } else { this.m_Description.text = StringUtility.Contact(Language.Get("Z1024", config.LowLV), "-", config.HighestLV); } } this.m_MonsterType.SetActive(false); this.m_MonsterType.SetSprite(StringUtility.Contact("MapNPC_Colour_", config.Colour)); } } private void FlyToEventPoint() { var free = ModelCenter.Instance.GetModel().GetVipPrivilegeCnt(VipPrivilegeType.FreeTransfer) > 0; if (free) { MoveToNpc(); return; } var hasFlyBoot = playerPack.GetItemCountByID(PackType.Item, GeneralDefine.flyBootItemId) > 0; if (hasFlyBoot) { MoveToNpc(); return; } if (mainModel.IsFlyShoseBool) { int NeedMoney = (int)UIHelper.GetMoneyCnt(2); if (NeedMoney >= GeneralDefine.flyBootItemMoney) { MapTransferUtility.Instance.StopMovetoNpc(); MoveToNpc(); } else { SysNotifyMgr.Instance.ShowTip("GoldPaperErr"); //WindowCenter.Instance.Open(); } } else { FlyShoseConfirmwin.useEnvironment = FlyShoseConfirmwin.UseEnvironment.LocalMap; FlyShoseConfirmwin.confirmCallBack = MoveToNpc; WindowCenter.Instance.Open(); } } private void MoveToNpc() { var config = MapEventPointConfig.Get(m_EventId); MapTransferUtility.Instance.MissionFlyTo(PlayerDatas.Instance.baseData.MapID, config.NPCID); WindowCenter.Instance.Close(); WindowCenter.Instance.Close(); WindowCenter.Instance.Open(); } private void SelectEventPoint() { model.selectedMapEventPoint = m_EventId; } private void OnSelected(int _event) { var selected = _event == m_EventId; m_Selected.SetActive(selected); this.m_Title.color = this.m_Description.color = m_FontColor.GetColorSize(selected ? "Selected" : "Normal").color; } } }