private void Start() { plane = GameObject.Find("PaperPlane").GetComponent <PlaneController>(); rb = plane.GetComponent <Rigidbody>(); }
private void Update() { #region StartMotionControl if (motion) { if (!positionSet) { if (timeCount == 0f) { gamePlane.transform.parent = gameTransform; timeCount += Time.deltaTime; } else if (timeCount < motionTime) { gamePlane.transform.position = Vector3.Lerp(startTransform.position, gameTransform.position, timeCount / motionTime); gamePlane.transform.rotation = Quaternion.Lerp(startTransform.rotation, gameTransform.rotation, timeCount / motionTime); timeCount += Time.deltaTime; } else { Debug.Log("Finished Lerping"); gamePlane.transform.rotation = gameTransform.rotation; gamePlane.transform.position = gameTransform.position; positionSet = true; } } else if (!gameStarted) { Debug.Log("Game Started"); //animator.SetTrigger("Countdown"); planeController.enabled = true; planeController.GetComponent <Rigidbody>().drag = 0; gamePlane.transform.localPosition = Vector3.zero; gameStarted = true; planeCollider.enabled = true; motion = false; } } #endregion #region EndMotionControl if (endMotion) { endStartTransform.position = gamePlane.transform.position; endStartTransform.rotation = gamePlane.transform.rotation; if (!positionSet) { if (timeCount == 0f) { gamePlane.transform.parent = endTransform.parent; timeCount += Time.deltaTime; } else if (timeCount < motionTime) { gamePlane.transform.position = Vector3.Lerp(endStartTransform.position, endTransform.position, timeCount / motionTime); gamePlane.transform.rotation = Quaternion.Lerp(endStartTransform.rotation, endTransform.rotation, timeCount / motionTime); timeCount += Time.deltaTime; } else { Debug.Log("Finished Lerping"); gamePlane.transform.rotation = endTransform.rotation; gamePlane.transform.position = endTransform.position; positionSet = true; } } else if (!gameEnded) { Debug.Log("Game Ended"); //animator.SetTrigger("Countdown"); gameEnded = true; endMotion = false; gameController.MakeClueAvailable(); gameController.Save(); //gameController.LoadScene(0);//Default AR Scene } } #endregion }
void Update() { if (m_leftBounds) { if (m_leftBoundsTimer > 0) { m_leftBoundsTimer -= Time.deltaTime; if (m_leftBoundsTimer <= 0 && m_leftBounds) { SuicidePlayer(); } } } if (m_leftBounds) { m_missionText.SetActive(true); m_missionText.GetComponent <Text>().text = "0:0" + Mathf.CeilToInt(m_leftBoundsTimer); } else { m_missionText.GetComponent <Text>().text = ""; m_missionText.SetActive(false); } if (m_playerPlane == null) { m_isAccelerating = false; m_isTurningLeft = false; m_isTurningRight = false; return; } if (!m_isActive) { return; } m_playerPlane.GetComponent <AudioSource>().pitch = 1 + ((m_speedMultiplier - 1) / m_maxSpeedMultiplier) * 0.5f; if (Input.GetAxis("Horizontal") > 0 && !m_isTurningLeft) { m_isTurningRight = true; } else { m_isTurningRight = false; } if (Input.GetAxis("Horizontal") < 0 && !m_isTurningRight) { m_isTurningLeft = true; } else { m_isTurningLeft = false; } if (Input.GetAxis("Vertical") > 0) { m_isAccelerating = true; } else { m_isAccelerating = false; } if (Input.GetButton("Fire1")) { GetComponent <WeaponController>().FireWeapon(m_isAccelerating); } if (Input.GetButtonDown("Fire2")) { GetComponent <WeaponController>().DropBomb(); } if (Input.GetButtonDown("Fire3")) { GetComponent <WeaponController>().FireFlare(m_playerPlane.transform.position, m_playerPlane.GetComponent <Rigidbody>().velocity); } if (m_isAccelerating) { m_speedMultiplier += 3 * Time.deltaTime; } else { m_speedMultiplier -= 3 * Time.deltaTime; } if (m_speedMultiplier > m_maxSpeedMultiplier) { m_speedMultiplier = m_maxSpeedMultiplier; } else if (m_speedMultiplier < 1) { m_speedMultiplier = 1; } m_playerPlane.GetComponent <AudioSource>().pitch = 1 + ((m_speedMultiplier - 1) / m_maxSpeedMultiplier) * 0.8f; }