MinMap.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using DG.Tweening;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class MinMap : MonoBehaviour
  7. {
  8. public RectTransform mapPlayer;
  9. public Transform CrystalsParent;
  10. public Image point;
  11. public LineRenderer LineItem;
  12. public Transform LineParent;
  13. public RectTransform Rpoint;
  14. public Image Map;
  15. /// <summary>
  16. /// 所有路线
  17. /// </summary>
  18. private List<LineRenderer> list_route = new List<LineRenderer>();
  19. /// <summary>
  20. /// 小地图上所有Image
  21. /// </summary>
  22. public List<Image> listAllPoint;
  23. /// <summary>
  24. /// 显示角色在小地图的位置 ( Position EulerAngles)
  25. /// </summary>
  26. public void ShowPlayer(Vector3 pos, float rot)
  27. {
  28. mapPlayer.localPosition = pos;
  29. mapPlayer.localRotation = Quaternion.Euler(0, 0, -rot);
  30. }
  31. /// <summary>
  32. /// 显示所有水晶点 (所有可触发交互的地方)
  33. /// </summary>
  34. /// <param name="list_Point"></param>
  35. public void ShowPoint(List<Vector3> list_Point)
  36. {
  37. for (int i = 0; i < list_Point.Count; i++)
  38. {
  39. var pos = list_Point[i];
  40. Image newPoint = Instantiate(point, CrystalsParent);
  41. newPoint.GetComponent<RectTransform>().localPosition = new Vector3(pos.x, -pos.y, 0);
  42. newPoint.gameObject.SetActive(true);
  43. listAllPoint.Add(newPoint.GetComponent<Image>());
  44. }
  45. mapPlayer.transform.SetAsLastSibling();
  46. }
  47. public void SetRoute(int index, bool isshow)
  48. {
  49. list_route[index].gameObject.SetActive(isshow);
  50. }
  51. public void SettingMapRoute(List<Vector3> listMapRoutePos, string linename)
  52. {
  53. var line = Instantiate(LineItem, LineParent);
  54. line.name = linename;
  55. line.transform.localPosition = Vector3.zero;
  56. line.startWidth = 3;
  57. line.endWidth = 3;
  58. line.positionCount = 0;
  59. line.positionCount = listMapRoutePos.Count;
  60. for (int i = 0; i < listMapRoutePos.Count; i++)
  61. {
  62. line.SetPosition(i, listMapRoutePos[i]);
  63. }
  64. list_route.Add(line);
  65. }
  66. }