using vnxbqy.UI; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class RichMoveEvent : TRichTextEvent { PackModel m_PlayerPackModel; PackModel playerPack { get { return m_PlayerPackModel ?? (m_PlayerPackModel = ModelCenter.Instance.GetModel()); } } VipModel m_VipModel; VipModel vipData { get { return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel()); } } MapModel m_MapModel; MapModel mapModel { get { return m_MapModel ?? (m_MapModel = ModelCenter.Instance.GetModel()); } } public RichMoveEvent() { RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.MOVENPC, this); RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.FLYNPC, this); RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.MOVEPOS, this); RichTextMgr.Inst.RegisterEvent(RichTextEventEnum.FindPlayer, this); } public override bool Execute(RichTextEventEnum type, RichTextMgr.HrefInfo href) { switch (type) { case RichTextEventEnum.MOVENPC: { int id = int.Parse(href.mSplits["movenpc"]); var movetype = 1; if (href.mSplits.ContainsKey("movetype")) { movetype = int.Parse(href.mSplits["movetype"]); } var error = 0; if (!TestMoveNpc(id, out error)) { ProcessMoveNpcError(error); return false; } GA_Hero hero = PlayerDatas.Instance.hero; if (hero != null) { PlayerDatas.Instance.hero.Behaviour.StopHandupAI(); SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(id, movetype)); } } break; case RichTextEventEnum.MOVEPOS: { float x = 0; float y = 0; if (href.mSplits.ContainsKey("x") && href.mSplits.ContainsKey("y")) { if (float.TryParse(href.mSplits["x"], out x) && float.TryParse(href.mSplits["y"], out y)) { GA_Hero hero = PlayerDatas.Instance.hero; if (hero != null) { PlayerDatas.Instance.hero.Behaviour.StopHandupAI(); SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(x / 2, hero.Pos.y, y / 2))); } } } } break; case RichTextEventEnum.FLYNPC: { int id = int.Parse(href.mSplits["flynpc"]); MapTransferUtility.Instance.MissionFlyTo(PlayerDatas.Instance.baseData.MapID, id); } break; case RichTextEventEnum.FindPlayer: { float x = 0; float y = 0; int _mapId = int.Parse(href.mSplits["mapid"]); float.TryParse(href.mSplits["x"], out x); float.TryParse(href.mSplits["y"], out y); byte line = 255; if (href.mSplits.ContainsKey("line")) { byte.TryParse(href.mSplits["line"], out line); } //var _itemCount = playerPack.GetItemCountByID(PackType.rptItem, GeneralDefine.flyBootItemId); GA_Hero hero = PlayerDatas.Instance.hero; if (hero == null) { return false; } //if (vipData.GetVipPrivilegeCnt(VipPrivilegeType.FreeTransfer) > 0) //{ // MapTransferUtility.Instance.FlyTo(_mapId, new Vector3(x / 2, hero.Pos.y, y / 2), line); //} //else if (_itemCount > 0) //{ // ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ConfirmUseTransfer"), (bool isOk) => // { // if (isOk) // { // MapTransferUtility.Instance.FlyTo(_mapId, new Vector3(x / 2, hero.Pos.y, y / 2), line); // } // else // { // MoveToMapPos(_mapId, x, y, line); // } // }); //} //else //{ MoveToMapPos(_mapId, x, y, line); //} } break; } return false; } public override string GetDisplay(RichTextEventEnum type, Dictionary dic) { return string.Empty; } private void MoveToMapPos(int _mapId, float x, float y, byte line = 255) { if (PlayerDatas.Instance.baseData.MapID != _mapId) { if (_mapId == CrossServerBossModel.DATA_MAPID) { if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.CrossServerBoss)) { FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.CrossServerBoss); return; } var model = ModelCenter.Instance.GetModel(); model.selectedBoss = model.GetRecommendNpc(); var error = 0; if (!model.CanEnter(out error)) { model.ProcessEnterError(error); return; } model.RequestEnter(); } else if (_mapId == 32080) { CrossServerMHBossModel.Instance.GotoKillBoss(); } else { var currentMapConfig = MapConfig.Get(PlayerDatas.Instance.baseData.MapID); if (currentMapConfig.MapFBType != 0) { SysNotifyMgr.Instance.ShowTip("Map_Delivery"); return; } if (mapModel.IsMapUnlocked(_mapId) == false) { SysNotifyMgr.Instance.ShowTip("Map_Delivery"); return; } mapModel.RequestMapTransport(_mapId, line); } WorldMapSkip.Instance.PushCMD(() => { SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(x / 2, 0, y / 2))); }); } else { if (PlayerDatas.Instance.baseData.FBID != line) { DTC0401_tagPlayerMapInit.OnMapInitEvent -= OnMapInitEvent; DTC0401_tagPlayerMapInit.OnMapInitEvent += OnMapInitEvent; mapModel.RequestSelectedLine(line); m_Posx = x; m_Posy = y; return; } PlayerDatas.Instance.hero.Behaviour.StopHandupAI(); SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(x / 2, 0, y / 2))); } } float m_Posx; float m_Posy; void OnMapInitEvent() { DTC0401_tagPlayerMapInit.OnMapInitEvent -= OnMapInitEvent; SnxxzGame.Instance.StartCoroutine(Co_DelayMoveTo()); } private IEnumerator Co_DelayMoveTo() { yield return WaitingForSecondConst.WaitMS1000; SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(m_Posx / 2, 0, m_Posy / 2))); } private IEnumerator WaitForSkillFinished(int id, int movetype) { GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null || _hero.SkillMgr == null) { yield break; } while (_hero != null && _hero.SkillMgr.CurCastSkill != null && _hero.SkillMgr.CurCastSkill.SkillCompelete == false) { yield return null; if (_hero == null || _hero.SkillMgr == null) { yield break; } } if (_hero == null) { yield break; } MapTransferUtility.Instance.MoveToNPC(id, 0, movetype == 1); } private IEnumerator WaitForSkillFinished(Vector3 pos) { GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null) { yield break; } while (_hero != null && _hero.SkillMgr.CurCastSkill != null && _hero.SkillMgr.CurCastSkill.SkillCompelete == false) { yield return null; } if (_hero == null) { yield break; } pos.y = _hero.Pos.y; _hero.MoveToPosition(pos); } private bool TestMoveNpc(int npcId, out int error) { error = 0; return true; } void ProcessMoveNpcError(int error) { } }