691 lines
23 KiB
C#
691 lines
23 KiB
C#
using Games.Events;
|
|
using GCGame.Table;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
public class SceneMapLogicUI : MonoBehaviour
|
|
{
|
|
private static SceneMapLogicUI instance;
|
|
public static SceneMapLogicUI Instance
|
|
{
|
|
get { return instance; }
|
|
}
|
|
|
|
public class FriendNPCData
|
|
{
|
|
public int sceneId;
|
|
public int roleBaseId;
|
|
public string m_name;
|
|
public string m_headIcon;
|
|
public Vector3 m_pos;
|
|
}
|
|
|
|
public class ServerPointInfo
|
|
{
|
|
public int monsterId;
|
|
public RectTransform rect;
|
|
public Slider slider;
|
|
public bool del;
|
|
}
|
|
|
|
public GameObject m_NpcPanel;
|
|
public GameObject m_NpcPanelItem;
|
|
|
|
public GameObject m_pointMainPlayer;
|
|
public GameObject m_pointDot;
|
|
|
|
public GameObject m_pointServer;
|
|
|
|
public GameObject m_pointTransport;
|
|
public GameObject m_pointNpc;
|
|
public GameObject m_pointOtherPlayer;
|
|
public GameObject m_pointEnemy;
|
|
public GameObject m_pointFriend;
|
|
public GameObject m_pointTeam;
|
|
public GameObject m_pointMonster;
|
|
public GameObject m_PointSameForce;
|
|
public GameObject m_CallMonster;
|
|
|
|
public Text SceneName;
|
|
public RawImage m_SceneMapImage;
|
|
public RectTransform m_MapRoot;
|
|
|
|
private MapInterface m_mapInterface = new MapInterface();
|
|
|
|
private List<ServerPointInfo> serverPoints = new List<ServerPointInfo>();
|
|
int serverPoint = -1;
|
|
float lastFreshTime = 0;
|
|
int m_CurrentSceneID = -1;
|
|
void Awake()
|
|
{
|
|
if(instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
Hashtable calbackMoveparam6 = new Hashtable();
|
|
calbackMoveparam6["name"] = "OnServerPointFresh";
|
|
MessageEventCallBack fun6 = OnServerPointFresh;
|
|
calbackMoveparam6.Add("callFun", fun6);
|
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OnServerPointFresh, calbackMoveparam6);
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.UpdateUpRightSceneLineInfo, UpdateSceneLineInfo);
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.OnSceneMapFixLoadOver, InitNpcInfo);
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.OnServerPointFresh, UpdateOtherPoint);
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
if(instance != null)
|
|
{
|
|
instance = null;
|
|
}
|
|
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OnServerPointFresh, "OnServerPointFresh");
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.OnServerPointFresh, UpdateOtherPoint);
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.OnSceneMapFixLoadOver, InitNpcInfo);
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.UpdateUpRightSceneLineInfo, UpdateSceneLineInfo);
|
|
}
|
|
|
|
public void UpdateOtherPoint(object args)
|
|
{
|
|
GC_RET_SAME_FORCE_TYPE_USERS_POS packet = (GC_RET_SAME_FORCE_TYPE_USERS_POS)args;
|
|
if (packet == null || m_mapInterface==null)
|
|
return;
|
|
List<Vector3> poss = new List<Vector3>();
|
|
for(int i=0;i<packet.npcserveridCount;i++)
|
|
{
|
|
poss.Add(new Vector3(packet.npcposxList[i]/100.0f, packet.serveridList[i], packet.npcposzList[i]/100.0f));
|
|
}
|
|
m_mapInterface.UpdateOtherPoint(poss, 1);
|
|
poss.Clear();
|
|
for (int i = 0; i < packet.serveridCount; i++)
|
|
{
|
|
poss.Add(new Vector3(packet.posxList[i]/100.0f, packet.serveridList[i], packet.poszList[i]/100.0f));
|
|
}
|
|
m_mapInterface.UpdateOtherPoint(poss, 2);
|
|
}
|
|
|
|
|
|
public void UpdateSceneLineInfo(object args)
|
|
{
|
|
if (m_CurrentSceneID == GameManager.gameManager.RunningScene)
|
|
return;
|
|
CancleScenInfo();
|
|
Start();
|
|
}
|
|
|
|
public void CancleScenInfo()
|
|
{
|
|
if (m_mapInterface != null)
|
|
m_mapInterface.ClearStaticPoint();
|
|
for(int i=0;i< serverPoints.Count;i++)
|
|
{
|
|
serverPoints[i].rect.gameObject.SetActive(false);
|
|
GameObject.Destroy(serverPoints[i].rect.gameObject);
|
|
}
|
|
serverPoints.Clear();
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
if (m_CurrentSceneID == GameManager.gameManager.RunningScene)
|
|
return;
|
|
Tab_SceneClass sceneInfo = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
|
if (sceneInfo == null)
|
|
return;
|
|
if (m_mapInterface == null)
|
|
m_mapInterface = new MapInterface();
|
|
m_CurrentSceneID = GameManager.gameManager.RunningScene;
|
|
m_mapInterface.Init(m_MapRoot, m_pointFriend, m_pointEnemy, m_pointOtherPlayer, m_pointTeam);
|
|
m_mapInterface.InitNavPointPrefab(m_pointDot);
|
|
if(SceneMapFix.Instance()!=null && SceneMapFix.Instance().CurrSceneName == UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)
|
|
{
|
|
InitNpcInfo();
|
|
InitTransport();
|
|
}
|
|
SceneName.text = sceneInfo.Name;
|
|
m_mapInterface.SetMapImage(sceneInfo.SceneMapTexture, m_SceneMapImage);
|
|
serverPoint = sceneInfo.ServerPoint;
|
|
if(serverPoint > 0)
|
|
{
|
|
m_mapInterface.InitOtherPoint(m_CallMonster, m_PointSameForce);
|
|
}
|
|
_started = true;
|
|
m_mapInterface.ResetNavPoint();
|
|
}
|
|
|
|
public void InitNpcInfo(object args)
|
|
{
|
|
InitNpcInfo();
|
|
InitTransport();
|
|
}
|
|
|
|
private bool _started;
|
|
private void OnEnable()
|
|
{
|
|
if (_started)
|
|
m_mapInterface.ResetNavPoint();
|
|
if(m_CurrentSceneID != GameManager.gameManager.m_RunningScene)
|
|
{
|
|
UpdateSceneLineInfo(null);
|
|
}
|
|
|
|
Games.Events.EventDispatcher.Instance.Dispatch(Games.Events.EventId.OpenMap, null);
|
|
}
|
|
|
|
public void OnServerPointFresh(Hashtable addparam, Hashtable sendparam)
|
|
{
|
|
if (sendparam.ContainsKey("data") == false)
|
|
return;
|
|
GC_SCENE_MONSTER_INFO packet = (GC_SCENE_MONSTER_INFO)sendparam["data"];
|
|
if (packet.HasParam)
|
|
return;
|
|
for(int i=0;i<packet.InfoCount;i++)
|
|
{
|
|
MonsterInfo info = packet.GetInfo(i);
|
|
bool find = false;
|
|
for(int j = 0;j < serverPoints.Count;j++)
|
|
{
|
|
if(serverPoints[j].monsterId == info.MonsterId && serverPoints[j].del)
|
|
{
|
|
serverPoints[j].rect.anchoredPosition3D = m_mapInterface.ScenePosToMapPosVec3(new Vector3(info.MonsterPosX / 100.0f,0, info.MonsterPosY / 100.0f));
|
|
serverPoints[j].del = false;
|
|
Tab_RoleBaseAttr roleBass = TableManager.GetRoleBaseAttrByID(info.MonsterId, 0);
|
|
if (roleBass != null)
|
|
{
|
|
serverPoints[j].slider.value = (info.MonsterHP * 1.0f) / (info.MonsterMaxHP * 1.0f);
|
|
}
|
|
find = true;
|
|
break;
|
|
}
|
|
}
|
|
if (find)
|
|
continue;
|
|
CloneServerPoint(info);
|
|
}
|
|
List<int> indexs = new List<int>();
|
|
for(int i=0;i<serverPoints.Count;i++)
|
|
{
|
|
if(serverPoints[i].del)
|
|
{
|
|
indexs.Add(i);
|
|
continue;
|
|
}
|
|
serverPoints[i].del = true;
|
|
}
|
|
for(int i=0;i<indexs.Count;i++)
|
|
{
|
|
serverPoints[indexs[i]].rect.gameObject.SetActive(false);
|
|
serverPoints[indexs[i]].rect.SetParent(null);
|
|
GameObject.DestroyObject(serverPoints[indexs[i]].rect.gameObject);
|
|
serverPoints.RemoveAt(indexs[i]);
|
|
}
|
|
}
|
|
|
|
public void CloneServerPoint(MonsterInfo info)
|
|
{
|
|
if (info == null)
|
|
return;
|
|
Tab_RoleBaseAttr roleBass = TableManager.GetRoleBaseAttrByID(info.MonsterId, 0);
|
|
if (roleBass == null)
|
|
return;
|
|
GameObject pointObj = UnityEngine.Object.Instantiate(m_pointServer) as GameObject;
|
|
if (pointObj == null)
|
|
return;
|
|
RectTransform rect = pointObj.GetComponent<RectTransform>();
|
|
if (rect == null)
|
|
return;
|
|
pointObj.transform.SetParent(m_pointServer.transform.parent);
|
|
pointObj.transform.localScale = m_pointServer.transform.localScale;
|
|
if (rect != null)
|
|
{
|
|
rect.anchoredPosition3D = m_mapInterface.ScenePosToMapPosVec3(new Vector3(info.MonsterPosX / 100.0f,0, info.MonsterPosY / 100.0f));
|
|
}
|
|
pointObj.SetActive(true);
|
|
Image head = pointObj.GetComponent<Image>();
|
|
if(head != null)
|
|
{
|
|
Tab_CharModel charModel = TableManager.GetCharModelByID(roleBass.CharModelID, 0);
|
|
if(charModel!=null)
|
|
{
|
|
LoadAssetBundle.Instance.SetImageSprite(head, charModel.HeadPic);
|
|
}
|
|
}
|
|
|
|
Slider hpSlider = pointObj.GetComponentInChildren<Slider>();
|
|
if(hpSlider != null)
|
|
{
|
|
hpSlider.value = (info.MonsterHP * 1.0f) / (info.MonsterMaxHP * 1.0f);
|
|
}
|
|
Text Name = pointObj.GetComponentInChildren<Text>();
|
|
if (Name != null)
|
|
{
|
|
Name.text = roleBass.Name;
|
|
}
|
|
|
|
ServerPointInfo serverPoint = new ServerPointInfo();
|
|
serverPoint.monsterId = info.MonsterId;
|
|
serverPoint.rect = rect;
|
|
serverPoint.slider = hpSlider;
|
|
serverPoint.del = false;
|
|
serverPoints.Add(serverPoint);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
MainPlayerPos();
|
|
if (m_mapInterface != null)
|
|
{
|
|
m_mapInterface.UpdateMap();
|
|
m_mapInterface.UpdateNavPoint();
|
|
}
|
|
|
|
if(serverPoint > 0)
|
|
{
|
|
if(Time.time - lastFreshTime > 0.5f)
|
|
{
|
|
lastFreshTime = Time.time;
|
|
if(serverPoint == 1)
|
|
{
|
|
AskMonster();
|
|
}
|
|
if (serverPoint == 2)
|
|
{
|
|
AskSameForce();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void AskSameForce()
|
|
{
|
|
CG_REQ_SAME_FORCE_TYPE_USERS_POS req = (CG_REQ_SAME_FORCE_TYPE_USERS_POS)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SAME_FORCE_TYPE_USERS_POS);
|
|
req.Nilparam = 1;
|
|
req.SendPacket();
|
|
}
|
|
|
|
private void AskMonster()
|
|
{
|
|
CG_GUILD_UNION_MATCH_REQ req = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ);
|
|
req.SetParam(0);
|
|
req.SetType((int)CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.MONSTER_INFO);
|
|
req.SendPacket();
|
|
}
|
|
|
|
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, m_MapRoot);
|
|
rect.anchoredPosition3D = newPos;
|
|
}
|
|
}
|
|
|
|
public void Click_Close()
|
|
{
|
|
m_NpcPanel.SetActive(false);
|
|
UIManager.CloseUI(UIInfo.SceneMapRoot);
|
|
}
|
|
|
|
bool CanSwitchWorldMap()
|
|
{
|
|
if(GameManager.gameManager.PlayerDataPool.pvpIfo._PvpBattleSceneId == GameManager.gameManager.RunningScene)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void Click_OpenWorldMap()
|
|
{
|
|
if(!CanSwitchWorldMap())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{81002}"));
|
|
return;
|
|
}
|
|
UIManager.CloseUI(UIInfo.SceneMapRoot);
|
|
UIManager.ShowUI(UIInfo.WorldMapWindow);
|
|
}
|
|
|
|
public void InitTransport()
|
|
{
|
|
var teleTables = TableManager.GetTeleport().Values;
|
|
foreach (var tele in teleTables)
|
|
if (tele.SrcSceneID == GameManager.gameManager.RunningScene)
|
|
{
|
|
if (m_mapInterface == null)
|
|
return;
|
|
var point = new MapInterface.PointInfoData
|
|
{
|
|
m_name = tele.TeleportName,
|
|
m_pos = Games.Scene.ActiveScene.GetTerrainPosition(new Vector3(tele.SrcPosX,0, tele.SrcPosZ)),
|
|
m_cloneObj = m_pointTransport,
|
|
};
|
|
m_mapInterface.ClonePoint(point);
|
|
}
|
|
}
|
|
|
|
public void InitNpcInfo()
|
|
{
|
|
m_NPCPannels.AddRange(m_NPCCachePannels);
|
|
m_NPCCachePannels.Clear();
|
|
for(int i=0;i< m_NPCPannels.Count;i++)
|
|
{
|
|
m_NPCPannels[i].SetActive(false);
|
|
}
|
|
var curTabSceneNPCDic = TableManager.GetSceneNpc().Values;
|
|
foreach (var sceneNpcInfo in curTabSceneNPCDic)
|
|
{
|
|
if (sceneNpcInfo.SceneID == GameManager.gameManager.RunningScene)
|
|
{
|
|
Tab_RoleBaseAttr curRoleBase = TableManager.GetRoleBaseAttrByID(sceneNpcInfo.DataID, 0);
|
|
if (curRoleBase != null)
|
|
{
|
|
if (curRoleBase.Camp == 1 && curRoleBase.IsShowInMap == 1)
|
|
{
|
|
FriendNPCData data = new FriendNPCData();
|
|
data.sceneId = sceneNpcInfo.SceneID;
|
|
data.m_name = curRoleBase.Name;
|
|
data.roleBaseId = curRoleBase.Id;
|
|
data.m_headIcon = "";
|
|
Tab_CharModel modeTable = TableManager.GetCharModelByID(curRoleBase.CharModelID, 0);
|
|
if (modeTable != null)
|
|
{
|
|
data.m_headIcon = modeTable.HeadPic;
|
|
}
|
|
data.m_pos = new Vector3(sceneNpcInfo.PosX, 0, sceneNpcInfo.PosZ);
|
|
CreateNpcPoint(data);
|
|
CreateNpcPanelItem(data);
|
|
}
|
|
CreateMonsterPoint(curRoleBase);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//打开NPC列表面板
|
|
public void Click_OpenNpcPanel()
|
|
{
|
|
if (m_NpcPanel == null)
|
|
return;
|
|
if(m_NpcPanel.activeSelf)
|
|
{
|
|
m_NpcPanel.SetActive(false);
|
|
return;
|
|
}
|
|
m_NpcPanel.SetActive(true);
|
|
}
|
|
|
|
List<GameObject> m_NPCCachePannels = new List<GameObject>();
|
|
List<GameObject> m_NPCPannels = new List<GameObject>();
|
|
//创建该场景中的NPC列表
|
|
public void CreateNpcPanelItem(FriendNPCData data)
|
|
{
|
|
if (m_NpcPanelItem == null)
|
|
return;
|
|
GameObject npcItem = null;
|
|
if(m_NPCPannels.Count > 0)
|
|
{
|
|
npcItem = m_NPCPannels[0];
|
|
m_NPCPannels.RemoveAt(0);
|
|
}
|
|
if(npcItem==null)
|
|
npcItem = UnityEngine.Object.Instantiate(m_NpcPanelItem) as GameObject;
|
|
if (npcItem == null)
|
|
return;
|
|
m_NPCCachePannels.Add(npcItem);
|
|
npcItem.SetActive(true);
|
|
npcItem.transform.SetParent(m_NpcPanelItem.transform.parent, false);
|
|
npcItem.transform.localScale = m_NpcPanelItem.transform.localScale;
|
|
Transform childName = npcItem.transform.Find("name");
|
|
if(childName!=null)
|
|
{
|
|
Text name = childName.gameObject.GetComponent<Text>();
|
|
if (name != null)
|
|
name.text = data.m_name;
|
|
}
|
|
|
|
Transform childHeadIcon = npcItem.transform.Find("headIcon");
|
|
if (childHeadIcon != null)
|
|
{
|
|
Image icon = childHeadIcon.gameObject.GetComponent<Image>();
|
|
if (icon != null)
|
|
LoadAssetBundle.Instance.SetImageSprite(icon, data.m_headIcon);
|
|
}
|
|
|
|
Transform childIcon = npcItem.transform.Find("icon");
|
|
if (childIcon != null)
|
|
{
|
|
Tab_RoleBaseAttr curRoleBase = TableManager.GetRoleBaseAttrByID(data.roleBaseId, 0);
|
|
if(curRoleBase!=null && curRoleBase.SceneNpcType>=0)
|
|
{
|
|
childIcon.gameObject.SetActive(true);
|
|
Image icon = childIcon.gameObject.GetComponent<Image>();
|
|
if (icon != null)
|
|
LoadAssetBundle.Instance.SetImageSprite(icon, GetNpcTypeSprite(curRoleBase.SceneNpcType));
|
|
}
|
|
else
|
|
{
|
|
childIcon.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
Transform childButton = npcItem.transform.Find("Button");
|
|
if (childButton != null)
|
|
{
|
|
Button btn = childButton.gameObject.GetComponent<Button>();
|
|
if (btn != null)
|
|
{
|
|
btn.onClick.AddListener(delegate ()
|
|
{
|
|
TransmitPointOnClicked(data.sceneId,data.roleBaseId, data.m_pos.x, data.m_pos.z,data.m_name);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public string GetNpcTypeSprite(int type)
|
|
{
|
|
string spriteName = "";
|
|
if (type == 0) //铁匠
|
|
{
|
|
spriteName = "npctype_tiejiang";
|
|
}
|
|
else if (type == 1) //杂货铺
|
|
{
|
|
spriteName = "npctype_zahuo";
|
|
}
|
|
else if (type == 2) //裁缝
|
|
{
|
|
spriteName = "npctype_caifeng";
|
|
}
|
|
else if (type == 3) //药铺
|
|
{
|
|
spriteName = "npctype_yaodian";
|
|
}
|
|
else if (type == 4) //宝石
|
|
{
|
|
spriteName = "npctype_baoshi";
|
|
}
|
|
else if (type == 5) //仓库
|
|
{
|
|
spriteName = "npctype_cangku";
|
|
}
|
|
|
|
//其它情况是用积分的 需要屏蔽货币类型Icon
|
|
else
|
|
{
|
|
spriteName = "";
|
|
}
|
|
return spriteName;
|
|
}
|
|
|
|
//寻路
|
|
void TransmitPointOnClicked(int m_EndSceneId,int roleBaseId,float x,float z,string searchName,bool CloseUI = true)
|
|
{
|
|
//根据记录的点进行寻路
|
|
AutoSearchPoint point = new AutoSearchPoint(m_EndSceneId, x, z);
|
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|
{
|
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetName = searchName;
|
|
if(CloseUI)
|
|
Click_Close();
|
|
}
|
|
Tab_RoleBaseAttr curRoleBase = TableManager.GetRoleBaseAttrByID(roleBaseId, 0);
|
|
if (curRoleBase != null)
|
|
{
|
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = curRoleBase.DialogRadius;
|
|
}
|
|
}
|
|
|
|
//创建怪物区域
|
|
public void CreateMonsterPoint(Tab_RoleBaseAttr roleBase)
|
|
{
|
|
if (m_mapInterface == null)
|
|
return;
|
|
if (roleBase.MapX == 0 && roleBase.MapZ == 0)
|
|
return;
|
|
if (roleBase.MapX == -1 && roleBase.MapZ == -1)
|
|
return;
|
|
|
|
m_mapInterface.CloneMonsterPoint(m_pointMonster, roleBase);
|
|
}
|
|
|
|
//创建NPC目标小点
|
|
public void CreateNpcPoint(FriendNPCData pointData)
|
|
{
|
|
if (m_mapInterface == null)
|
|
return;
|
|
var point = new MapInterface.PointInfoData
|
|
{
|
|
m_cloneObj = m_pointNpc,
|
|
m_name = pointData.m_name,
|
|
m_pos = Games.Scene.ActiveScene.GetTerrainPosition(pointData.m_pos)
|
|
};
|
|
m_mapInterface.ClonePoint(point);
|
|
}
|
|
|
|
//点击场景地图图片时的寻路
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
//private List<Vector3> points = new List<Vector3>();
|
|
//private List<GameObject> dotPoints = new List<GameObject>();
|
|
//private List<GameObject> pointIndexs = new List<GameObject>();
|
|
|
|
//public void StopMove()
|
|
//{
|
|
// m_mapInterface.ClearNavPoint();
|
|
//
|
|
// //if (dotPoints.Count <= 0)
|
|
// // return;
|
|
// //points.Clear();
|
|
// //pointIndexs.Clear();
|
|
// //PointReachTime = -1;
|
|
// //for (int i = 0; i < dotPoints.Count; i++)
|
|
// // dotPoints[i].SetActive(false);
|
|
//}
|
|
|
|
//private float AddLerpDis = 2.5f; //插入点间的间距
|
|
//创建寻路目标小点
|
|
//public void CreateNavPoint(Vector3 pos)
|
|
//{
|
|
// if (m_pointDot == null)
|
|
// return;
|
|
// MapInterface.PointInfoData point = new MapInterface.PointInfoData
|
|
// {
|
|
// m_pos = pos,
|
|
// m_cloneObj = m_pointDot
|
|
// };
|
|
// GameObject dotpoint = m_mapInterface.ClonePoint(point);
|
|
// dotPoints.Add(dotpoint);
|
|
// pointIndexs.Add(dotpoint);
|
|
//}
|
|
|
|
//设置寻路路线显示
|
|
//void UpdateDotPos(Vector3 MovePos, NavMeshPath paths)
|
|
//{
|
|
// if (Singleton<ObjManager>.GetInstance().MainPlayer == null)
|
|
// {
|
|
// return;
|
|
// }
|
|
// if (Singleton<ObjManager>.GetInstance().MainPlayer.NavAgent == null)
|
|
// {
|
|
// return;
|
|
// }
|
|
// if (Singleton<ObjManager>.GetInstance().MainPlayer.NavAgent.enabled == false)
|
|
// return;
|
|
// for (int i = 0; i < dotPoints.Count; i++)
|
|
// {
|
|
// dotPoints[i].SetActive(false);
|
|
// }
|
|
//
|
|
// Vector3 lastVec = Vector3.zero;
|
|
//
|
|
// if (paths.corners.Length < 2)
|
|
// return;
|
|
//
|
|
// //两点中间插值计算点
|
|
// points.Clear();
|
|
// points.Add(paths.corners[0]);
|
|
// lastVec = paths.corners[0];
|
|
// for (int i = 1; i < paths.corners.Length; i++)
|
|
// {
|
|
// float distance = Vector3.Distance(lastVec, paths.corners[i]);
|
|
// float nextDis = AddLerpDis;
|
|
// if(distance > 1.5f)
|
|
// {
|
|
// while (nextDis < distance + 1.5f)
|
|
// {
|
|
// Vector3 newPoint = Vector3.Lerp(lastVec, paths.corners[i], nextDis / distance);
|
|
// points.Add(newPoint);
|
|
// nextDis += AddLerpDis;
|
|
// }
|
|
//
|
|
// points.Add(paths.corners[i]);
|
|
// }
|
|
// lastVec = paths.corners[i];
|
|
// }
|
|
// PointReachTime = Vector3.Distance( Singleton<ObjManager>.GetInstance().MainPlayer.Position ,points[0]) / Singleton<ObjManager>.GetInstance().MainPlayer.NavAgent.speed;
|
|
// pointIndexs.Clear();
|
|
// for (int i = 0; i < points.Count; i++)
|
|
// {
|
|
// if (dotPoints.Count > i)
|
|
// {
|
|
// dotPoints[i].SetActive(true);
|
|
// pointIndexs.Add(dotPoints[i]);
|
|
// RectTransform rect = dotPoints[i].GetComponent<RectTransform>();
|
|
// if (rect != null)
|
|
// {
|
|
// rect.anchoredPosition3D = MapInterface.ScenePosToMapPos(points[i]);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// CreateNavPoint(points[i]);
|
|
// }
|
|
// }
|
|
//}
|
|
} |