| | |
| | | using Snxxz.UI; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TableConfig; |
| | | using UnityEngine; |
| | | public class RichMoveEvent : TRichTextEvent |
| | | { |
| | | PlayerPackModel m_PlayerPackModel; |
| | | PlayerPackModel playerPack |
| | | { |
| | | get { return m_PlayerPackModel ?? (m_PlayerPackModel = ModelCenter.Instance.GetModel<PlayerPackModel>()); } |
| | | } |
| | | |
| | | VipModel m_VipModel; |
| | | VipModel vipData |
| | | { |
| | | get |
| | | { |
| | | return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>()); |
| | | } |
| | | } |
| | | |
| | | MapModel m_MapModel; |
| | | MapModel mapModel |
| | | { |
| | | get |
| | | { |
| | | return m_MapModel ?? (m_MapModel = ModelCenter.Instance.GetModel<MapModel>()); |
| | | } |
| | | } |
| | | |
| | | 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"]); |
| | | GA_Hero hero = PlayerDatas.Instance.hero; |
| | | if (hero != null) |
| | | { |
| | | PlayerDatas.Instance.hero.Behaviour.StopHandupAI(); |
| | | SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(id)); |
| | | } |
| | | } |
| | | 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, GeneralConfig.Instance.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<string, string> dic) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | |
| | | private void MoveToMapPos(int _mapId, float x, float y, byte line = 255) |
| | | { |
| | | if (PlayerDatas.Instance.baseData.MapID != _mapId) |
| | | { |
| | | var currentMapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(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; |
| | | } |
| | | |
| | | WorldMapSkip.Instance.PushCMD(() => |
| | | { |
| | | SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(x / 2, 0, y / 2))); |
| | | }); |
| | | mapModel.RequestMapTransport(_mapId, line); |
| | | } |
| | | 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) |
| | | { |
| | | GA_Hero _hero = PlayerDatas.Instance.hero; |
| | | |
| | | if (_hero == null) |
| | | { |
| | | yield break; |
| | | } |
| | | |
| | | while (_hero.SkillMgr.CurCastSkill != null && |
| | | _hero.SkillMgr.CurCastSkill.SkillCompelete == false) |
| | | { |
| | | yield return null; |
| | | } |
| | | |
| | | MapTransferUtility.Instance.MoveToNPC(id); |
| | | } |
| | | |
| | | private IEnumerator WaitForSkillFinished(Vector3 pos) |
| | | { |
| | | GA_Hero _hero = PlayerDatas.Instance.hero; |
| | | |
| | | if (_hero == null) |
| | | { |
| | | yield break; |
| | | } |
| | | |
| | | while (_hero.SkillMgr.CurCastSkill != null && |
| | | _hero.SkillMgr.CurCastSkill.SkillCompelete == false) |
| | | { |
| | | yield return null; |
| | | } |
| | | pos.y = _hero.Pos.y; |
| | | _hero.MoveToPosition(pos); |
| | | } |
| | | } |
| | | using Snxxz.UI;
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using TableConfig;
|
| | | using UnityEngine;
|
| | | public class RichMoveEvent : TRichTextEvent
|
| | | {
|
| | | PlayerPackModel m_PlayerPackModel;
|
| | | PlayerPackModel playerPack
|
| | | {
|
| | | get { return m_PlayerPackModel ?? (m_PlayerPackModel = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
| | | }
|
| | |
|
| | | VipModel m_VipModel;
|
| | | VipModel vipData
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | MapModel m_MapModel;
|
| | | MapModel mapModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_MapModel ?? (m_MapModel = ModelCenter.Instance.GetModel<MapModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | 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 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));
|
| | | }
|
| | | }
|
| | | 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<string, string> dic)
|
| | | {
|
| | | return string.Empty;
|
| | | }
|
| | |
|
| | | private void MoveToMapPos(int _mapId, float x, float y, byte line = 255)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.MapID != _mapId)
|
| | | {
|
| | | var currentMapConfig = Config.Instance.Get<MapConfig>(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;
|
| | | }
|
| | |
|
| | | WorldMapSkip.Instance.PushCMD(() =>
|
| | | {
|
| | | SnxxzGame.Instance.StartCoroutine(WaitForSkillFinished(new Vector3(x / 2, 0, y / 2)));
|
| | | });
|
| | | mapModel.RequestMapTransport(_mapId, line);
|
| | | }
|
| | | 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)
|
| | | {
|
| | | GA_Hero _hero = PlayerDatas.Instance.hero;
|
| | |
|
| | | if (_hero == null)
|
| | | {
|
| | | yield break;
|
| | | }
|
| | |
|
| | | while (_hero.SkillMgr.CurCastSkill != null &&
|
| | | _hero.SkillMgr.CurCastSkill.SkillCompelete == false)
|
| | | {
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | MapTransferUtility.Instance.MoveToNPC(id);
|
| | | }
|
| | |
|
| | | private IEnumerator WaitForSkillFinished(Vector3 pos)
|
| | | {
|
| | | GA_Hero _hero = PlayerDatas.Instance.hero;
|
| | |
|
| | | if (_hero == null)
|
| | | {
|
| | | yield break;
|
| | | }
|
| | |
|
| | | while (_hero.SkillMgr.CurCastSkill != null &&
|
| | | _hero.SkillMgr.CurCastSkill.SkillCompelete == false)
|
| | | {
|
| | | yield return null;
|
| | | }
|
| | | pos.y = _hero.Pos.y;
|
| | | _hero.MoveToPosition(pos);
|
| | | }
|
| | |
|
| | | private bool TestMoveNpc(int npcId, out int error)
|
| | | {
|
| | | error = 0;
|
| | | var _fairyGrabBossModel = ModelCenter.Instance.GetModel<FairyGrabBossModel>();
|
| | | if (_fairyGrabBossModel.bosses.Contains(npcId))
|
| | | {
|
| | | return _fairyGrabBossModel.TestEnterDungeon(npcId, out error);
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | void ProcessMoveNpcError(int error)
|
| | | {
|
| | | var _fairyGrabBossModel = ModelCenter.Instance.GetModel<FairyGrabBossModel>();
|
| | | _fairyGrabBossModel.DisplayErrorTip(error);
|
| | | }
|
| | | }
|