1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class MinMap : MonoBehaviour
- {
- public RectTransform mapPlayer;
- public Transform CrystalsParent;
- public Image point;
- public LineRenderer LineItem;
- public Transform LineParent;
- public RectTransform Rpoint;
- public Image Map;
- /// <summary>
- /// 所有路线
- /// </summary>
- private List<LineRenderer> list_route = new List<LineRenderer>();
- /// <summary>
- /// 小地图上所有Image
- /// </summary>
- public List<Image> listAllPoint;
- /// <summary>
- /// 显示角色在小地图的位置 ( Position EulerAngles)
- /// </summary>
- public void ShowPlayer(Vector3 pos, float rot)
- {
- mapPlayer.localPosition = pos;
- mapPlayer.localRotation = Quaternion.Euler(0, 0, -rot);
- }
-
- /// <summary>
- /// 显示所有水晶点 (所有可触发交互的地方)
- /// </summary>
- /// <param name="list_Point"></param>
- public void ShowPoint(List<Vector3> list_Point)
- {
- for (int i = 0; i < list_Point.Count; i++)
- {
- var pos = list_Point[i];
- Image newPoint = Instantiate(point, CrystalsParent);
- newPoint.GetComponent<RectTransform>().localPosition = new Vector3(pos.x, -pos.y, 0);
- newPoint.gameObject.SetActive(true);
- listAllPoint.Add(newPoint.GetComponent<Image>());
- }
- mapPlayer.transform.SetAsLastSibling();
- }
- public void SetRoute(int index, bool isshow)
- {
- list_route[index].gameObject.SetActive(isshow);
- }
- public void SettingMapRoute(List<Vector3> listMapRoutePos, string linename)
- {
- var line = Instantiate(LineItem, LineParent);
- line.name = linename;
- line.transform.localPosition = Vector3.zero;
- line.startWidth = 3;
- line.endWidth = 3;
- line.positionCount = 0;
- line.positionCount = listMapRoutePos.Count;
- for (int i = 0; i < listMapRoutePos.Count; i++)
- {
- line.SetPosition(i, listMapRoutePos[i]);
- }
- list_route.Add(line);
- }
- }
|