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.
48 lines
1.2 KiB
48 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Video;
|
|
public class TYY : MonoBehaviour
|
|
{
|
|
//videoPlayer.url = "https://edu-xnfz.educoder.net/Test/Hejidong/ZNHome/c9.mp4";
|
|
public GameObject mubu;
|
|
bool curState = false;
|
|
public Vector3 startPos;
|
|
public float Speed;
|
|
Vector3 birthPlace;
|
|
|
|
private void Awake()
|
|
{
|
|
birthPlace = transform.position;
|
|
}
|
|
public void swap() {
|
|
if (curState)
|
|
{
|
|
curState = false;
|
|
mubu.GetComponent<VideoPlayer>().Stop();
|
|
StartCoroutine(Run(birthPlace));
|
|
}
|
|
else {
|
|
curState = true;
|
|
StartCoroutine(Run(startPos));
|
|
TaskCenter.GetInstance().FinishTask(7);
|
|
}
|
|
}
|
|
|
|
IEnumerator Run(Vector3 tragetpos)
|
|
{
|
|
Vector3 dir = tragetpos - transform.position;
|
|
while (true)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
transform.position += dir * Speed * Time.deltaTime;
|
|
if (Vector3.Distance(tragetpos, transform.position) <= 0.05f)
|
|
{
|
|
if (curState==true) { mubu.GetComponent<VideoPlayer>().Play(); }
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|