293 lines
9.5 KiB
C#
293 lines
9.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using GCGame.Table;
|
|
using Games.Mission;
|
|
using Module.Log;
|
|
|
|
public class CrossServerMap : MonoBehaviour {
|
|
|
|
private static CrossServerMap instance;
|
|
public static CrossServerMap Instance
|
|
{
|
|
get { return instance; }
|
|
}
|
|
|
|
public RawImage MapImage;
|
|
public GameObject m_pointMainPlayer;
|
|
public GameObject m_pointGharry;
|
|
public GameObject m_pointGharryPath;
|
|
public GameObject m_pointDot;
|
|
public GameObject m_pointBoss;
|
|
public GameObject m_MoveBtn;
|
|
|
|
private MapInterface m_mapInterface = new MapInterface();
|
|
private MapInterface.MapDynamicPointHub _GharryPathPointHub;
|
|
private MapInterface.MapDynamicPointHub _BossPointHub;
|
|
|
|
void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
_GharryPathPointHub = new MapInterface.MapDynamicPointHub(m_pointGharryPath);
|
|
_BossPointHub = new MapInterface.MapDynamicPointHub(m_pointBoss);
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
if (instance != null)
|
|
{
|
|
instance = null;
|
|
}
|
|
}
|
|
|
|
public void InitCrossServerBoss(bool state = true)
|
|
{
|
|
if(state)
|
|
{
|
|
_BossPointHub.StartSet();
|
|
Dictionary<int, Tab_WorldBoss> bossInfos = TableManager.GetWorldBoss();
|
|
foreach (var boss in bossInfos)
|
|
{
|
|
if (boss.Value.SceneID != GameManager.gameManager.RunningScene || boss.Value.Type != 3)
|
|
continue;
|
|
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(boss.Value.Id, 0);
|
|
if (role == null)
|
|
continue;
|
|
Tab_CharModel charModel = TableManager.GetCharModelByID(role.CharModelID, 0);
|
|
if (charModel == null)
|
|
continue;
|
|
Vector3 newPos = SceneMapFix.Instance().ScenePosToMapPosVec3(new Vector3(boss.Value.PosX,0,boss.Value.PosZ), MapImage.rectTransform);
|
|
RectTransform rect = _BossPointHub.SetPointPosition(newPos);
|
|
if(rect!=null)
|
|
{
|
|
Image BossIcon = rect.gameObject.GetComponent<Image>();
|
|
if(BossIcon!=null)
|
|
LoadAssetBundle.Instance.SetImageSprite(BossIcon, charModel.HeadPic);
|
|
Text BossName = rect.GetComponentInChildren<Text>();
|
|
if (BossName != null)
|
|
BossName.text = role.Name;
|
|
}
|
|
}
|
|
_BossPointHub.EndSet();
|
|
}
|
|
else
|
|
{
|
|
_BossPointHub.StartSet();
|
|
_BossPointHub.EndSet();
|
|
}
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.OnChangeSceneOver, OnChangeScene);
|
|
if (MissionDialogAndLeftTabsLogic.Instance() != null)
|
|
{
|
|
MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false);
|
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.CrossServerMap);
|
|
}
|
|
|
|
//跨服BOSS活动开启
|
|
if (ActivityDataManager.Instance.IsActivityState((int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_CROSSSERVERBOSS, ActivityDataManager.ActivityState.Playing))
|
|
{
|
|
InitCrossServerBoss();
|
|
}
|
|
else
|
|
{
|
|
InitCrossServerBoss(false);
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
m_MoveBtn.SetActive(false);
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.OnChangeSceneOver, OnChangeScene);
|
|
if (MissionDialogAndLeftTabsLogic.Instance() != null)
|
|
MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(true);
|
|
}
|
|
|
|
public void OnChangeScene(object param)
|
|
{
|
|
if (MissionDialogAndLeftTabsLogic.Instance() != null)
|
|
{
|
|
MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false);
|
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.CrossServerMap);
|
|
}
|
|
}
|
|
|
|
public void OpenMissionLeftTab()
|
|
{
|
|
if (MissionDialogAndLeftTabsLogic.Instance() == null)
|
|
{
|
|
UIManager.ShowUI(UIInfo.MissionInfoController, delegate (bool bSuccess, object param)
|
|
{
|
|
if (bSuccess == false)
|
|
return;
|
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.CrossServerMap);
|
|
MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn();
|
|
UIManager.CloseUI(UIInfo.CrossServerMap);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(true);
|
|
MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.CrossServerMap);
|
|
MissionDialogAndLeftTabsLogic.Instance().SetSwitchBtn();
|
|
UIManager.CloseUI(UIInfo.CrossServerMap);
|
|
}
|
|
}
|
|
|
|
//点击场景地图图片时的寻路
|
|
public void OnSceneMapClick(PointerEventData eventData)
|
|
{
|
|
if (m_mapInterface != null)
|
|
{
|
|
var mainPlayer = Singleton<ObjManager>.Instance.MainPlayer;
|
|
if (mainPlayer != null)
|
|
{
|
|
if (mainPlayer.isAutoCombat)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{9009}"));
|
|
return;
|
|
}
|
|
|
|
var movePos = m_mapInterface.ScreenPosToScenePos(eventData.position);
|
|
if (movePos == null)
|
|
mainPlayer.StopMove();
|
|
else
|
|
mainPlayer.MainPlayMoveToPos(movePos.Value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void MoveBtn_Click()
|
|
{
|
|
if (GameManager.gameManager.RunningScene == Games.GlobeDefine.GlobeVar.CROSSSERVER_SIGNPOSTSCENE)
|
|
{
|
|
AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, Singleton<SignPostManager>.Instance.GhattyCurrPosition.x, Singleton<SignPostManager>.Instance.GhattyCurrPosition.z, -1, AutoSearchPoint.ChangeMap_Type.WORLDMAP, Games.GlobeDefine.GlobeVar.INVALID_GUID);
|
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|
{
|
|
GameManager.gameManager.AutoSearch.BuildPath(point, false, "");
|
|
}
|
|
}
|
|
}
|
|
|
|
#region Hide anim
|
|
|
|
private static Vector2 _ShowPos = new Vector2(0, 0);
|
|
private static Vector2 _HidePos = new Vector2(-355, 0);
|
|
public RectTransform _AnimPanel;
|
|
public GameObject _BtnHide;
|
|
public GameObject _BtnShow;
|
|
|
|
public void Init()
|
|
{
|
|
ShowPanel();
|
|
}
|
|
|
|
public void ShowPanel()
|
|
{
|
|
_AnimPanel.anchoredPosition = _ShowPos;
|
|
_BtnShow.SetActive(false);
|
|
_BtnHide.SetActive(true);
|
|
}
|
|
|
|
public void HidePanel()
|
|
{
|
|
_AnimPanel.anchoredPosition = _HidePos;
|
|
_BtnShow.SetActive(true);
|
|
_BtnHide.SetActive(false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
void Start()
|
|
{
|
|
if (null == SceneMapFix.Instance())
|
|
{
|
|
ResourceManager.InstantiateResource("Prefab/Logic/SceneMapFix", "SceneMapFix");
|
|
}
|
|
|
|
Tab_SceneClass sceneInfo = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
|
if (sceneInfo == null)
|
|
return;
|
|
if (m_mapInterface == null)
|
|
m_mapInterface = new MapInterface();
|
|
m_mapInterface.Init(MapImage.rectTransform, null, null, null, null);
|
|
m_mapInterface.InitNavPointPrefab(m_pointDot);
|
|
if (MapImage != null && string.IsNullOrEmpty(sceneInfo.SceneMapTexture) == false)
|
|
{
|
|
m_mapInterface.SetMapImage(sceneInfo.SceneMapTexture, MapImage);
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
MainPlayerPos();
|
|
if (m_mapInterface != null)
|
|
{
|
|
m_mapInterface.UpdateNavPoint();
|
|
}
|
|
}
|
|
|
|
public void MainPlayerPos()
|
|
{
|
|
if (m_pointMainPlayer != null && Singleton<ObjManager>.Instance.MainPlayer != null && SceneMapFix.Instance() != null)
|
|
{
|
|
RectTransform rect = m_pointMainPlayer.GetComponent<RectTransform>();
|
|
Vector3 newPos = SceneMapFix.Instance().ScenePosToMapPosVec3(Singleton<ObjManager>.Instance.MainPlayer.Position, MapImage.rectTransform);
|
|
rect.anchoredPosition3D = newPos;
|
|
rect.transform.SetAsLastSibling();
|
|
}
|
|
}
|
|
|
|
#region //跨服押镖马车的
|
|
public void StartSet()
|
|
{
|
|
if (_GharryPathPointHub != null && m_mapInterface != null)
|
|
{
|
|
//_GharryPathPointHub.StartSet();
|
|
}
|
|
}
|
|
|
|
public void GharryPath(Vector3 position)
|
|
{
|
|
if(_GharryPathPointHub!=null && m_mapInterface!=null)
|
|
{
|
|
//var mapPos = m_mapInterface.ScenePosToMapPosVec3(position);
|
|
//_GharryPathPointHub.SetPointPosition(mapPos);
|
|
}
|
|
}
|
|
|
|
public void EndSet()
|
|
{
|
|
if (_GharryPathPointHub != null && m_mapInterface != null)
|
|
{
|
|
//_GharryPathPointHub.EndSet();
|
|
}
|
|
}
|
|
|
|
public void GharryPos()
|
|
{
|
|
if (m_pointGharry == null)
|
|
return;
|
|
if(Singleton<SignPostManager>.Instance.GhattyCurrPosition == Vector3.zero)
|
|
{
|
|
m_pointGharry.SetActive(false);
|
|
m_MoveBtn.SetActive(false);
|
|
return;
|
|
}
|
|
m_pointGharry.SetActive(true);
|
|
m_MoveBtn.SetActive(true);
|
|
RectTransform rect = m_pointGharry.GetComponent<RectTransform>();
|
|
Vector3 newPos = SceneMapFix.Instance().ScenePosToMapPosVec3(Singleton<SignPostManager>.Instance.GhattyCurrPosition, MapImage.rectTransform);
|
|
rect.anchoredPosition3D = newPos;
|
|
|
|
}
|
|
#endregion
|
|
}
|