private void CalculatePosition(Vector3 target, ref UIMissionMapPoint mapPoint) { Vector3 m_Dir = target - m_WorldOrigin; float mapWidth = m_MapPointRoot.GetComponent <RectTransform>().sizeDelta.x; float mapHeight = m_MapPointRoot.GetComponent <RectTransform>().sizeDelta.y; Vector3 m_Pos = mapPoint.transform.localPosition; m_Pos.x = m_Dir.x * mapWidth / m_MapWidth - mapWidth * 0.5f; m_Pos.y = m_Dir.z * mapHeight / m_MapHeight - mapHeight * 0.5f; mapPoint.transform.localPosition = m_Pos; }
private void Update() { foreach (UIMissionMapPoint mapPoint in m_PointList) { if (Vector3.Distance(mapPoint.transform.position, m_Concentric.transform.position) < 20f) { m_Target = mapPoint; mapPoint.Highlight(); } else { if (mapPoint == m_Target) { m_Target = null; } mapPoint.Normal(); } } }
public void AddPointPrefab(GameObject target, eMapPointType type) { UIMissionMapPoint mapPoint = null; switch (type) { case eMapPointType.MISSIONTOWER: mapPoint = Instantiate(m_TowerPointPrefab, m_MapPointRoot); mapPoint.Init(target, type); break; case eMapPointType.SPAWNPOINT: mapPoint = Instantiate(m_SpawnPointPrefab, m_MapPointRoot); mapPoint.Init(target, type); m_PointList.Add(mapPoint); break; } if (mapPoint != null) { CalculatePosition(target.transform.position, ref mapPoint); } }