| | |
| | | [SerializeField] TextEx m_Level;
|
| | | [SerializeField] Button m_Moveto;
|
| | | [SerializeField] Image m_TaskState;
|
| | | [SerializeField] UIEffect m_Effect;
|
| | |
|
| | | TagType m_TagType;
|
| | | public TagType tagType {
|
| | | get {
|
| | | return m_TagType;
|
| | | }
|
| | | set {
|
| | | m_TagType = value;
|
| | | }
|
| | | get { return m_TagType; }
|
| | | set { m_TagType = value; }
|
| | | }
|
| | |
|
| | | LocalMapFindPath localMapFindPath;
|
| | | Vector3 worldPosition = Vector3.zero;
|
| | | int npcId = 0;
|
| | | int index = 0;
|
| | | TaskModel taskmodel {
|
| | | get {
|
| | | return ModelCenter.Instance.GetModel<TaskModel>();
|
| | | }
|
| | | }
|
| | |
|
| | | FairyLeagueModel fairyLeagueModel {
|
| | | get {
|
| | | return ModelCenter.Instance.GetModel<FairyLeagueModel>();
|
| | | }
|
| | | }
|
| | | MapModel mapModel { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
|
| | | TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
|
| | | FairyLeagueModel fairyLeagueModel { get { return ModelCenter.Instance.GetModel<FairyLeagueModel>(); } }
|
| | |
|
| | | public void Display(int _npcId, TextColType _colorType)
|
| | | public void Display(int npcId, TextColType colorType)
|
| | | {
|
| | | npcId = _npcId;
|
| | | this.npcId = npcId;
|
| | | switch (m_TagType)
|
| | | {
|
| | | case TagType.Function:
|
| | | var status = taskmodel.StatusLightQuery(npcId);
|
| | | var status = this.taskModel.StatusLightQuery(this.npcId);
|
| | | if (status > 0)
|
| | | {
|
| | | m_TaskState.SetSprite(StringUtility.Contact("LocalMapTaskState_", status));
|
| | |
| | | m_TaskState.SetNativeSize();
|
| | | TaskModel.Event_TaskResponse -= OnTaskStateChange;
|
| | | TaskModel.Event_TaskResponse += OnTaskStateChange;
|
| | |
|
| | | OnSelectEvent(mapModel.selectedMapEventPoint);
|
| | | mapModel.selectMapEventPointEvent -= OnSelectEvent;
|
| | | mapModel.selectMapEventPointEvent += OnSelectEvent;
|
| | | break;
|
| | | case TagType.WayPoint:
|
| | | break;
|
| | |
| | | break;
|
| | | case TagType.Elite:
|
| | | case TagType.Monster:
|
| | | var config = NPCConfig.Get(npcId);
|
| | | var config = NPCConfig.Get(this.npcId);
|
| | | m_NpcName.text = config.charName;
|
| | | m_NpcName.colorType = _colorType;
|
| | | m_NpcName.colorType = colorType;
|
| | | break;
|
| | | case TagType.Crystal:
|
| | | OnCrystalStateChange(npcId);
|
| | | this.OnCrystalStateChange(this.npcId);
|
| | | m_Moveto.RemoveAllListeners();
|
| | | m_Moveto.AddListener(MoveTo);
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
| | | fairyLeagueModel.UpdateWarCrystalEvent -= OnCrystalStateChange;
|
| | | fairyLeagueModel.UpdateWarCrystalEvent += OnCrystalStateChange;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | public void Display(int _npcId, TextColType _colorType, Vector3 _position)
|
| | | public void Display(int npcId, TextColType colorType, Vector3 _position)
|
| | | {
|
| | | worldPosition = _position;
|
| | | npcId = _npcId;
|
| | |
|
| | | this.npcId = npcId;
|
| | | switch (m_TagType)
|
| | | {
|
| | | case TagType.Boss:
|
| | | var config = NPCConfig.Get(npcId);
|
| | | var config = NPCConfig.Get(this.npcId);
|
| | | m_NpcName.text = config.charName;
|
| | | m_Level.text = Language.Get("HeadUpName_Monster", config.NPCLV);
|
| | | m_NpcName.colorType = _colorType;
|
| | | m_NpcName.colorType = colorType;
|
| | | var dangerous = PlayerDatas.Instance.baseData.LV <= config.NPCLV;
|
| | | m_Level.color = UIHelper.GetUIColor(dangerous ? TextColType.Red : TextColType.Green, false);
|
| | | m_Moveto.RemoveAllListeners();
|
| | | m_Moveto.AddListener(MoveTo);
|
| | | m_Moveto.SetListener(MoveTo);
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | public void Display(int _index)
|
| | | public void Display(int index)
|
| | | {
|
| | | index = _index;
|
| | | this.index = index;
|
| | | switch (m_TagType)
|
| | | {
|
| | | case TagType.FairyLeagueBuff:
|
| | | m_Moveto.RemoveAllListeners();
|
| | | m_Moveto.AddListener(MoveTo);
|
| | | m_Moveto.SetListener(MoveTo);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | public void Dispose()
|
| | | {
|
| | | mapModel.selectMapEventPointEvent += OnSelectEvent;
|
| | | TaskModel.Event_TaskResponse -= OnTaskStateChange;
|
| | | fairyLeagueModel.UpdateWarCrystalEvent -= OnCrystalStateChange;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | }
|
| | |
|
| | | private void OnSelectEvent(int eventId)
|
| | | {
|
| | | var config = MapEventPointConfig.Get(eventId);
|
| | |
|
| | | var isFunctionNpc = false;
|
| | | if (config != null && config.NPCID == this.npcId)
|
| | | {
|
| | | var npcConfig = NPCConfig.Get(config.NPCID);
|
| | | if (npcConfig.NPCType == 0)
|
| | | {
|
| | | isFunctionNpc = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (isFunctionNpc)
|
| | | {
|
| | | if (!m_Effect.IsPlaying)
|
| | | {
|
| | | m_Effect.Play();
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (m_Effect.IsPlaying)
|
| | | {
|
| | | m_Effect.Stop();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void MoveTo()
|
| | |
| | | {
|
| | | case TagType.FairyLeagueBuff:
|
| | | {
|
| | | var _help = fairyLeagueModel.fairyLeagueHelp;
|
| | | Vector2 _buffPos = fairyLeagueModel.crystalPosList[index];
|
| | | var _hero = PlayerDatas.Instance.hero;
|
| | | if (_hero != null)
|
| | | var buffPos = fairyLeagueModel.crystalPosList[index];
|
| | | var hero = PlayerDatas.Instance.hero;
|
| | | if (hero != null)
|
| | | {
|
| | | _hero.MoveToPosition(new Vector3(_buffPos.x, _hero.Pos.y, _buffPos.y));
|
| | | hero.MoveToPosition(new Vector3(buffPos.x, hero.Pos.y, buffPos.y));
|
| | | }
|
| | | }
|
| | | break;
|
| | | default:
|
| | | {
|
| | | var model = ModelCenter.Instance.GetModel<MapModel>();
|
| | | WindowCenter.Instance.Close<WorldMapWin>();
|
| | | WindowCenter.Instance.Close<LocalMapWin>();
|
| | | WindowCenter.Instance.Open<MainInterfaceWin>();
|
| | | MapTransferUtility.Instance.MoveToNPC(npcId);
|
| | | model.selectedMapEventPoint = -1;
|
| | | mapModel.selectedMapEventPoint = -1;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnTaskStateChange(int _nowNPCid, int _nPCLamp, Dictionary<int, int> _dic)
|
| | | private void OnTaskStateChange(int nowNpcId, int npcLamp, Dictionary<int, int> dic)
|
| | | {
|
| | | if (npcId == _nowNPCid)
|
| | | if (npcId == nowNpcId)
|
| | | {
|
| | | var status = taskmodel.StatusLightQuery(npcId);
|
| | | var status = taskModel.StatusLightQuery(npcId);
|
| | | if (status > 0)
|
| | | {
|
| | | m_TaskState.SetSprite(StringUtility.Contact("LocalMapTaskState_", status));
|
| | |
| | | OnCrystalStateChange(npcId);
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshInfoEvent(PlayerDataType _type)
|
| | | private void PlayerDataRefreshEvent(PlayerDataType type)
|
| | | {
|
| | | if (_type == PlayerDataType.Faction)
|
| | | if (type == PlayerDataType.Faction)
|
| | | {
|
| | | OnCrystalStateChange();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnCrystalStateChange(int _npcId)
|
| | | private void OnCrystalStateChange(int npcId)
|
| | | {
|
| | | if (npcId != _npcId)
|
| | | if (this.npcId != npcId)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var _index = fairyLeagueModel.GetCrystalIndex(_npcId);
|
| | | m_NpcName.text = (_index + 1).ToString();
|
| | | var _camp = fairyLeagueModel.fairyLeagueHelp.GetCrystalBelongCamp(_npcId);
|
| | | if (_camp == 0)
|
| | |
|
| | | var index = fairyLeagueModel.GetCrystalIndex(npcId);
|
| | | m_NpcName.text = (index + 1).ToString();
|
| | | var camp = fairyLeagueModel.fairyLeagueHelp.GetCrystalBelongCamp(npcId);
|
| | | if (camp == 0)
|
| | | {
|
| | | m_TaskState.SetSprite("GrayCrystal");
|
| | | m_Moveto.image.SetSprite("GreyBottom");
|
| | | return;
|
| | | }
|
| | | m_TaskState.SetSprite((FairyCampType)_camp == FairyCampType.Blue ? "BlueCrystal" : "RedCrystal");
|
| | | m_Moveto.image.SetSprite((FairyCampType)_camp == FairyCampType.Blue ? "BlueBottom" : "RedBottom");
|
| | |
|
| | | var isBlue = (FairyCampType)camp == FairyCampType.Blue;
|
| | | m_TaskState.SetSprite(isBlue ? "BlueCrystal" : "RedCrystal");
|
| | | m_Moveto.image.SetSprite(isBlue ? "BlueBottom" : "RedBottom");
|
| | | }
|
| | |
|
| | | public enum TagType
|
| | |
| | | {
|
| | | static Dictionary<int, GameObjectPoolManager.GameObjectPool> pools = new Dictionary<int, GameObjectPoolManager.GameObjectPool>();
|
| | |
|
| | | public static LocalMapTag Require(LocalMapTag.TagType _pattern)
|
| | | public static LocalMapTag Require(LocalMapTag.TagType pattern)
|
| | | {
|
| | | GameObjectPoolManager.GameObjectPool pool = null;
|
| | | var poolKey = (int)_pattern;
|
| | | var poolKey = (int)pattern;
|
| | | if (!pools.ContainsKey(poolKey))
|
| | | {
|
| | | var prefab = UILoader.LoadPrefab(StringUtility.Contact("LocalMap_", _pattern));
|
| | | var prefab = UILoader.LoadPrefab(StringUtility.Contact("LocalMap_", pattern));
|
| | | if (prefab != null)
|
| | | {
|
| | | pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
| | |
| | | {
|
| | | var instance = pool.Request();
|
| | | var npcBehaviour = instance.GetComponent<LocalMapTag>();
|
| | | npcBehaviour.tagType = _pattern;
|
| | | npcBehaviour.tagType = pattern;
|
| | | npcBehaviour.enabled = true;
|
| | | return npcBehaviour;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static void Recycle(LocalMapTag _npcBehaviour)
|
| | | public static void Recycle(LocalMapTag behaviour)
|
| | | {
|
| | | var pattern = _npcBehaviour.tagType;
|
| | | var pattern = behaviour.tagType;
|
| | | GameObjectPoolManager.GameObjectPool pool;
|
| | | if (pools.TryGetValue((int)pattern, out pool))
|
| | | {
|
| | | _npcBehaviour.enabled = false;
|
| | | pool.Release(_npcBehaviour.gameObject);
|
| | | behaviour.enabled = false;
|
| | | pool.Release(behaviour.gameObject);
|
| | | }
|
| | | }
|
| | |
|