/// <summary> /// Abstract Callback Function to handle blocking and everything else with the Player Unit /// </summary> /// <returns></returns> public override callbackValue callbackDamageFnc() { // Add Charge because of Perfect blocking if (perfectBlockActive && isBlocking) { if (currentCharges < maxCharges) { setCharges(currentCharges + 1); } // Camera Shake CameraEffects.ShakeOnce(ShakeLength, ShakeStrength); sparksCharged.Clear(); sparksCharged.Play(); SoundManager.Instance.playRandomSFX(parrySFX, audioSource, 0.8f, 1.2f); SoundManager.Instance.playSFX(chargeSFX, audioSource, 0.8f, 1.2f); return(callbackValue.SUCCESS); } // Normal blocking else if (!perfectBlockActive && isBlocking) { sparks.Clear(); sparks.Play(); SoundManager.Instance.playRandomSFX(parrySFX, audioSource, 0.8f, 1.2f); return(callbackValue.NOTHING); } // No blocking return(callbackValue.FAILURE); }
private void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Players") { col.gameObject.GetComponent <Rigidbody>().AddForce(transform.forward * Random.Range(350, 450)); CameraEffects.ShakeOnce(0.5f, 3, new Vector3(2, 2, 2)); } }
IEnumerator dashEffect() { isDashing = true; num_of_jumps++; dashParticles.Play(); if (Gamepad.current != null) { Gamepad.current.SetMotorSpeeds(.5f, .5f); } Vector2 direction = Vector3.zero; direction += controls.Creature.movement.ReadValue <Vector2>(); if (direction == Vector2.zero) { direction += Vector2.up; } direction.Normalize(); trail.SetActive(true); creature_rigid.velocity = direction * dashSpeed; float originalDrag = creature_rigid.drag; float originalAngularDrag = creature_rigid.angularDrag; float originalGravity = creature_rigid.gravityScale; creature_rigid.drag = 0.0001f; creature_rigid.angularDrag = 0f; creature_rigid.gravityScale = 0f; CameraEffects.ShakeOnce(0.3f, 10f); gameManager.playSound(MusicControl.SoundFX.Dash); yield return(new WaitForSeconds(dashTime * (0.75f))); creature_rigid.velocity = direction * (dashSpeed * .5f); creature_rigid.drag = 0.01f; yield return(new WaitForSeconds(dashTime * (0.25f))); if (Gamepad.current != null) { Gamepad.current.SetMotorSpeeds(0f, 0f); } dashParticles.Stop(); trail.SetActive(false); creature_rigid.velocity = Vector2.zero; creature_rigid.drag = originalDrag; creature_rigid.angularDrag = originalAngularDrag; creature_rigid.gravityScale = originalGravity; isDashing = false; // if the creature didn't leave the platform than restore the jump if (direction.y < 0 && num_of_jumps == 1) { num_of_jumps--; } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Grass") { Vibrate(0.5f, 0.5f); CameraEffects.ShakeOnce(1f, 2f); SoundManager.Instance.PlaySe("Collide"); _boatRB.velocity = new Vector3(0, 0, -10f); } }
public void Die() { PlayParticles(); PlayerScore.Instance.AddScore(enemy.PointsPerKill); Destroy(gameObject); EnemyManager.Instance.Kills++; CameraEffects.ShakeOnce(); EnemyManager.Instance.Kills++; EnemyManager.Instance.enemiesLeft--; EnemyManager.Instance.enemiesOnMap--; EnemyManager.Instance.enemiesLeftText.SetText(EnemyManager.Instance.enemiesLeft.ToString()); }
private void OnCollisionEnter(Collision collision) { if (collision.collider.tag == "Barrel") { Vibrate(0.5f, 0.5f); CameraEffects.ShakeOnce(1f, 1f); SoundManager.Instance.PlaySe("Collide"); } else if (collision.collider.tag == "Log") { Vibrate(1f, 1f); CameraEffects.ShakeOnce(1f, 5f); SoundManager.Instance.PlaySe("Collide"); } else if (collision.collider.tag == "Wall") { CameraEffects.ShakeOnce(0.2f, 0.2f); } }
// Update is called once per frame void Update() { Cursor.visible = InMenu; Curor.transform.position = Input.mousePosition; GameCanvas.gameObject.SetActive(!InMenu); MainCanvas.gameObject.SetActive(InMenu); GamePP.gameObject.SetActive(!InMenu); MenuPP.gameObject.SetActive(InMenu); if (!InMenu && Stats.Heart > 0) { if (Input.GetMouseButtonDown(0)) { if (Stats.Sheels == 0) { AudioSource.PlayClipAtPoint(ClickAudio, transform.position); } else { if (Stats.Sheels == Powers.Shells) { NextReload = 2f / (Powers.FastReload + 1); } var hits = Physics.RaycastAll(Camera.ScreenPointToRay(Input.mousePosition)); var birdHit = false; for (var i = 0; i < hits.Length; i++) { var bird = hits[i].collider.GetComponent <Bird>(); birdHit = birdHit || bird != null; if (bird != null) { bird.SetDead(); } } if (birdHit) { CameraEffects.ShakeOnce(0.5f); ScoreIteration(); UpdateGameUI(); } else { CameraEffects.ShakeOnce(0.05f); } AudioSource.PlayClipAtPoint(ShotAudio, transform.position); Stats.Sheels--; UpdateGameUI(); } } if (Input.GetKeyDown(KeyCode.Space) && Stats.Bomb > 0) { AudioSource.PlayClipAtPoint(BombAudio, transform.position); Stats.Bomb--; CameraEffects.ShakeOnce(0.5f); var birds = new List <Bird>(Bird.AllBirds); //copy because all birds change in the loop for (int i = 0; i < birds.Count; i++) { birds[i].SetDead(); ScoreIteration(); } UpdateGameUI(); } Reload(); } }