You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.3 KiB
99 lines
2.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using UnityEngine.UI;
|
|
|
|
public class MoveCamera : MonoBehaviour
|
|
{
|
|
public Transform[] CameraPoints;
|
|
public string[] NameArr;
|
|
private int currentIndex = 0;
|
|
|
|
public Text RoadName;
|
|
|
|
public float turnTime = 0.5f;
|
|
|
|
|
|
|
|
private void Start()
|
|
{
|
|
if (CameraPoints.Length != 0)
|
|
{
|
|
transform.position = CameraPoints[currentIndex].position;
|
|
transform.eulerAngles = CameraPoints[currentIndex].eulerAngles;
|
|
ChangeRoadName();
|
|
}
|
|
|
|
}
|
|
|
|
public void MoveToPoint(Transform point)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
transform.DOMove(point.position, turnTime);
|
|
transform.DORotate(point.eulerAngles, turnTime);
|
|
}
|
|
public void MoveToPoint(Vector3 pos,Vector3 eur)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
transform.DOMove(pos, turnTime);
|
|
transform.DORotate(eur, turnTime);
|
|
}
|
|
public void MoveToPoint(Vector3 point,bool isrote)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
transform.DOMove(point, turnTime);
|
|
if (isrote)
|
|
{
|
|
transform.DORotate(point, turnTime);
|
|
}
|
|
|
|
}
|
|
|
|
public void MoveToCurrentPoint()
|
|
{
|
|
transform.DOMove(CameraPoints[currentIndex].position, turnTime);
|
|
transform.DORotate(CameraPoints[currentIndex].eulerAngles, turnTime);
|
|
}
|
|
|
|
public void MoveLastPoint()
|
|
{
|
|
currentIndex--;
|
|
currentIndex = Mathf.Clamp(currentIndex, 0, CameraPoints.Length-1);
|
|
|
|
//更换路段名
|
|
if (RoadName != null)
|
|
{
|
|
ChangeRoadName();
|
|
}
|
|
|
|
|
|
transform.DOMove(CameraPoints[currentIndex].position, turnTime);
|
|
transform.DORotate(CameraPoints[currentIndex].eulerAngles, turnTime);
|
|
}
|
|
public void MoveNextPoint()
|
|
{
|
|
currentIndex++;
|
|
currentIndex = Mathf.Clamp(currentIndex, 0, CameraPoints.Length - 1);
|
|
|
|
//更换路段名
|
|
if (RoadName != null)
|
|
{
|
|
ChangeRoadName();
|
|
}
|
|
|
|
transform.DOMove(CameraPoints[currentIndex].position, turnTime);
|
|
transform.DORotate(CameraPoints[currentIndex].eulerAngles, turnTime);
|
|
}
|
|
|
|
|
|
|
|
private void ChangeRoadName()
|
|
{
|
|
RoadName.text = NameArr[currentIndex];
|
|
|
|
}
|
|
|
|
|
|
}
|