void OnTriggerEnter(Collider other) { if (other.CompareTag("Player") == true) { characters.Add(other); if (characters.Count >= expectedNumber) { IsTriggered = true; } else if (IsTriggered == false) { audioCache.Audio.clip = enter; audioCache.Play(); } if ((triggerOnce == true) && (IsTriggered == true)) { numberIndicator.text = "OK"; isDisplayingOK = true; } else { numberIndicator.text = string.Format("{0}/{1}", characters.Count, expectedNumber); } } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Player") == true) { characters.Add(other); numberIndicator.text = string.Format("{0}/{1}", characters.Count, expectedNumber); if (characters.Count >= expectedNumber) { MouseOrbitImproved.CurrentState = MouseOrbitImproved.State.Finished; } mutator.Audio.clip = enter; mutator.Play(); } }
public void Move(float move, bool jump) { //only control the player if grounded or airControl is turned on float moveAbs = Mathf.Abs(move); if (IsGrounded || airControl) { // The Speed animator parameter is set to the absolute value of the horizontal input. anim.SetFloat("Speed", moveAbs); // Move the character GetComponent <Rigidbody2D>().velocity = new Vector2(move * maxSpeed, GetComponent <Rigidbody2D>().velocity.y); // If the input is moving the player right and the player is facing left... if (move > 0 && !facingRight) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && facingRight) { // ... flip the player. Flip(); } } // If the player should jump... if (IsGrounded == true) { if (jump == true) { // Add a vertical force to the player. anim.SetBool("Ground", false); GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, jumpForce)); // Play the jump sound jumpAudio.Play(); jumpParticles.Stop(); jumpParticles.Play(); // Stop the running audio runningAudio.Stop(); } else if ((moveAbs > 0.1f) && (runningAudio.Audio.isPlaying == false)) { runningAudio.Play(); } else if ((moveAbs < 0.1f) && (runningAudio.Audio.isPlaying == true)) { runningAudio.Stop(); } } else if (runningAudio.Audio.isPlaying == true) { // Stop the running audio runningAudio.Stop(); } }
void PlayClip(AudioClip clip) { if (audioPlayer == null) { audioPlayer = GetComponent <AudioMutator>(); } audioPlayer.Audio.clip = clip; audioPlayer.Play(); }
void OnCollisionEnter(Collision info) { if (info.collider.CompareTag("Player")) { controllers.Add(info.collider); if ((expectedNumber > 0) && (controllers.Count >= expectedNumber)) { GetComponent <Rigidbody>().mass = originalMass; } } else { audioMutator.Play(); } }
// Use this for initialization public override void Start() { if (particlesCache == null) { particlesCache = GetComponentsInChildren <ParticleSystem>(); } if (soundCache == null) { soundCache = GetComponent <AudioMutator>(); } soundCache.Play(); foreach (ParticleSystem system in particlesCache) { system.Play(); } StartCoroutine(Die()); }
// Update is called once per frame protected void Update() { switch (state) { case State.Charging: if ((Time.time - lastShot) > charge) { foreach (Transform spawnAt in spawnPoints) { GameObject instance = Singleton.Get <PoolingManager>().GetInstance(bullets.gameObject, spawnAt.position, transform.rotation); PooledBullets bullet = instance.GetComponent <PooledBullets>(); bullet.Rotation = transform.rotation; } foreach (ParticleSystem system in allParticles) { system.Play(); } audio.Play(); lastShot = Time.time; state = State.Cooldown; } break; case State.Cooldown: if ((Time.time - lastShot) > cooldown) { lastShot = Time.time; state = State.Aiming; } break; case State.Aiming: default: lookRotation = Quaternion.LookRotation(ShipControl.TransformInfo.position - transform.position); if ((Time.time - lastShot) > shootEvery) { lastShot = Time.time; state = State.Charging; } break; } UpdateRotation(); }
void RunAnimation() { // Check if we need to clean up the animation if (itemAnimation != null) { // Clean up this item animation from the animation queue Go.removeTween(itemAnimation); itemAnimation = null; } // Create and play a new animation affectedTransform.transform.parent = transform; itemAnimation = Go.to(affectedTransform.transform, animationDuration, itemAnimationConfiguration); itemAnimation.setOnCompleteHandler(UpdatePlatform); itemAnimation.play(); // Play audio audioScript.Play(); }
private void RecoverDrill(float cooldown, bool playSound) { if ((Time.time - timeLastDrilled) > cooldown) { if ((playSound == true) && (refillSound.Audio.isPlaying == false)) { // Play the refill sound refillSound.Play(); } // Increment drill CurrentDrill += (Time.deltaTime * drillRecoverRate); // Make sure it doesn't exceed max if (CurrentDrill > drillMax) { CurrentDrill = drillMax; timeLastDrilled = -1f; } } }
bool CheckIfRamming() { bool returnFlag = false; // Check if we have the button down if (CrossPlatformInputManager.GetButton("Drill") == true) { // Check if we have any drill left if (CurrentDrill > 0) { // Indicate we are ramming returnFlag = true; // Decrement drilling CurrentDrill -= (Time.deltaTime * drillDepletionRate); } else if (emptySound.Audio.isPlaying == false) { emptySound.Play(); } // Keep track of when we were drilling timeLastDrilled = Time.time; } else if (timeLastDrilled > 0) { if (CurrentDrill > 0) { // Check if we need to recover drilling RecoverDrill(drillCooldownSmall, false); } else { // Check if we need to recover drilling RecoverDrill(drillCooldownLong, true); } } return(returnFlag); }
void FixedUpdate() { if (CurrentMode == Mode.Playing) { float h = CrossPlatformInput.GetAxis("Horizontal"); // Pass all parameters to the character control script. character.Move(h, jump); // Reset the jump input once it has been used. jump = false; // Check if we need to rotate the level if (rotationDirection != RotateDirection.None) { // Rotate the room rotateEverything.Rotate(rotationDirection); gravityAudio.Play(); rotationDirection = RotateDirection.None; } } }
void OnTriggerEnter2D(Collider2D other) { if ((other.CompareTag("Player") == true) && (Platformer2DUserControl.CurrentMode == Platformer2DUserControl.Mode.Playing) && (RotateEverything.TargetAngle == goalOrientation)) { // Indicate the level is finished Platformer2DUserControl.FinishLevel(); // Play audio mutator.Audio.clip = enter; mutator.Play(); // Transition to the next level SceneTransition transition = Singleton.Get <SceneTransition>(); if (Application.loadedLevel >= GameSettings.NumLevels) { transition.LoadLevel(GameSettings.MenuLevel); } else { transition.LoadLevel(Application.loadedLevel + 1); } } }
// Update is called once per frame protected void Update() { if (beam.IsShooting == true) { // Check if we're done if ((Time.time - lastShot) > fireDuration) { beam.IsShooting = false; lastShot = Time.time; audio.Stop(); } } else if ((Time.time - lastShot) > shootEvery) { lastShot = Time.time; beam.IsShooting = true; audio.Play(); } lookRotation = Quaternion.LookRotation(ShipControl.TransformInfo.position - transform.position); body.rotation = Quaternion.Slerp(body.rotation, lookRotation, (Time.deltaTime * rotateLerp)); beam.Body.rotation = body.rotation; }