/// <summary> /// This controls the order of events for the UFO spawner. enables and disables the tracktor beam mesh and plays and stops the animation for the tracktor beam. /// </summary> /// <returns></returns> IEnumerator UfoSpawn() { ufo.Pause(); yield return(new WaitForSeconds(.5f)); tractorBeam.enabled = true; tracktorBeamAnimator.SetBool("isUp", false); //Spawn Enemy spawn.SpawnEnemy(); yield return(new WaitForSeconds(1f)); tracktorBeamAnimator.SetBool("isUp", true); tracktorBeamAnimator.SetBool("isUp", false); //Spawn Enemy spawn.SpawnEnemy(); yield return(new WaitForSeconds(1f)); tracktorBeamAnimator.SetBool("isUp", true); yield return(new WaitForSeconds(1f)); tracktorBeamAnimator.SetBool("isUp", false); //Spawn Enemy spawn.SpawnEnemy(); yield return(new WaitForSeconds(1f)); tracktorBeamAnimator.SetBool("isUp", true); tractorBeam.enabled = false; yield return(new WaitForSeconds(.5f)); ufo.Resume(); }
IEnumerator SplinePause() { script.Pause(); yield return(new WaitForSeconds(8f)); script.Resume(); isAttacking = false; }
public void OnFreeze(AssetBundle ab, bool bFreeze) { if (bFreeze) { Vector3 postion = transform.position; Quaternion rotation = transform.rotation; Vector3 scale = transform.localScale; transform.position = Vector3.zero; transform.rotation = Quaternion.Euler(Vector3.zero); transform.localScale = Vector3.one; Vector3 center = Vector3.zero; foreach (Renderer child in m_Renderers) { center += child.bounds.center; } center /= m_Renderers.Length; Bounds bounds = new Bounds(center, Vector3.zero); foreach (Renderer child in m_Renderers) { bounds.Encapsulate(child.bounds); } GameObject obj = (GameObject)ab.LoadAsset("Flshing_Bingdong"); obj = Instantiate(obj); obj.transform.SetParent(transform, false); obj.transform.localPosition = bounds.center - transform.position; obj.transform.localScale = bounds.size; obj.name = "Bing"; obj.layer = gameObject.layer; transform.position = postion; transform.rotation = rotation; transform.localScale = scale; if (m_SplineMove != null) { m_SplineMove.Pause(); } } else { Transform tfm = transform.Find("Bing"); if (tfm != null) { Destroy(tfm.gameObject); } if (m_SplineMove != null) { m_SplineMove.Resume(); } } }
//listens to user input void Update() { //do nothing in moving state if (myMove.tween == null || myMove.tween.IsPlaying()) { return; } //on up arrow, move forwards if (Input.GetKeyDown(KeyCode.UpArrow)) { myMove.Resume(); } }
void Update() { //do not continue if the tween reached its end if (move.tween == null || !move.tween.IsActive() || move.tween.IsComplete()) { return; } //check for user input if (Input.GetKeyDown(KeyCode.UpArrow)) { //resume tween the first time the game starts if (!move.tween.IsPlaying()) { move.Resume(); } //get desired speed after pressing the button //we add the desired value to the current speed for acceleration float speed = currentSpeed + addSpeed; //limit the speed value by the maximum value if (speed >= topSpeed) { speed = topSpeed; } //change the speed of the tween by the calculated value move.ChangeSpeed(speed); //restart slow down StopAllCoroutines(); StartCoroutine("SlowDown"); } //display values and increase timer speedDisplay.text = "YOUR SPEED: " + Mathf.Round(move.speed * 100f) / 100f; timeCounter += Time.deltaTime; timeDisplay.text = "YOUR TIME: " + Mathf.Round(timeCounter * 100f) / 100f; }