Team:NYU Shanghai/Code

using UnityEngine; using System.Collections; public class SceneTransition : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetMouseButtonDown (0)){ Application.LoadLevel (2); //0is the bacteria, 1 is the outside school 2 is the lab } } } using UnityEngine; using System.Collections; public class SinWaveMover : MonoBehaviour { Vector3 m_centerPosition; float m_degrees; [SerializeField] float m_speed = 1.0f; [SerializeField] float m_amplitude = 1.0f; [SerializeField] float m_period = 1.0f; //SteamBotAI checker; void Start () { m_centerPosition = transform.position; m_period = Random.Range (5.0f, 10.0f); m_speed = Random.Range (0.1f, 0.5f); } void Update () { //checker = gameObject.transform.GetComponent (); //if (!checker.isVenting) { float deltaTime = Time.deltaTime; // Move center along x axis // m_centerPosition.x += deltaTime * m_speed; // Update degrees float degreesPerSecond = 360.0f / m_period; m_degrees = Mathf.Repeat (m_degrees + (deltaTime * degreesPerSecond), 360.0f); float radians = m_degrees * Mathf.Deg2Rad; // Offset by sin wave Vector3 offset = new Vector3 (0.0f, m_amplitude * Mathf.Sin (radians), 0.0f); transform.position = m_centerPosition + offset; //} } } using UnityEngine; using System.Collections; public class transpositioncameradirectly : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } } using UnityEngine; using System.Collections; public class cameratrans2 : MonoBehaviour { // Use this for initialization public float transitionDuration = 2.5f; public Transform target; public float position; public float speed = 1.0f; public int counter = 1; public float zoom = 100; public float before = 9000; void Start () { //target.position = new Vector3(-22, 87 ,1); } // Update is called once per frame if (Input.GetKeyDown ("space") void Update () { if (Input.GetMouseButtonDown (0)) { counter ++; StartCoroutine (Transition ()); float a = 0.0f; while (a < 1.0f) { a += Time.deltaTime * (Time.timeScale / transitionDuration); Camera.main.orthographicSize = Mathf.Lerp (before, zoom, a); } if (Input.GetMouseButtonDown (0) && counter == 2) { StartCoroutine (Transition5 ()); } if (Input.GetMouseButtonDown (0) && counter == 4) { Application.LoadLevel(3); } } }//I just add a } after the success of moving, not sure if it will go wrong IEnumerator Transition() { float t = 0.0f; Vector3 startingPos = transform.position; Quaternion startingRot = transform.rotation; Vector3 endingPos1 = new Vector3 (100 ,210, -70); //Quaternion endingRot = new Quaternion (0, 1, 1, 1); while (t < 1.0f) { t += Time.deltaTime * (Time.timeScale/transitionDuration); transform.position = Vector3.Lerp(startingPos, endingPos1, t); //transform.rotation = Quaternion .Lerp(startingRot, endingRot, t); yield return 0; } } IEnumerator Transition5() { float t3 = 0.0f; Vector3 startingPos = transform.position; Vector3 endingPos = new Vector3 (50 ,600, -1000); while (t3 < 1.0f) { t3 += Time.deltaTime * (Time.timeScale/transitionDuration); transform.position = Vector3.Lerp(startingPos, endingPos, t3); yield return 0; } } } using UnityEngine; using System.Collections; public class SinWaveMover : MonoBehaviour { Vector3 m_centerPosition; float m_degrees; [SerializeField] float m_speed = 1.0f; [SerializeField] float m_amplitude = 1.0f; [SerializeField] float m_period = 1.0f; //SteamBotAI checker; void Start () { m_centerPosition = transform.position; m_period = Random.Range (5.0f, 10.0f); m_speed = Random.Range (0.1f, 0.5f); } void Update () { //checker = gameObject.transform.GetComponent (); //if (!checker.isVenting) { float deltaTime = Time.deltaTime; // Move center along x axis // m_centerPosition.x += deltaTime * m_speed; // Update degrees float degreesPerSecond = 360.0f / m_period; m_degrees = Mathf.Repeat (m_degrees + (deltaTime * degreesPerSecond), 360.0f); float radians = m_degrees * Mathf.Deg2Rad; // Offset by sin wave Vector3 offset = new Vector3 (0.0f, m_amplitude * Mathf.Sin (radians), 0.0f); transform.position = m_centerPosition + offset; //} } }