// When lives are lost: 1. Smoke animation plays, 2. Phone vibrates, 3.lives flame sprite decreased, 4. Ripple effect void Update() { if (Flame2.enabled == true) { if (ranbool2) { Instantiate(exhaust, transform.position, Quaternion.identity); camRipple.RippleEffect(); Handheld.Vibrate(); ranbool2 = false; } } if (Flame3.enabled == true) { if (ranbool3) { Instantiate(exhaust, transform.position, Quaternion.identity); camRipple.RippleEffect(); Handheld.Vibrate(); ranbool3 = false; } } if (Flame4.enabled == true) { if (ranbool4) { Instantiate(exhaust, transform.position, Quaternion.identity); camRipple.RippleEffect(); Handheld.Vibrate(); ranbool4 = false; } } }
public void OnCollisionEnter2D(Collision2D col) { if (col.transform.name == "Top Border") { rb.velocity = new Vector2(0f, -10f); highscore.addPoints(); AudioManager.instance.Play("Bounce"); } else if (col.transform.name == "Bottom Border") { rb.velocity = new Vector2(0f, 10f); highscore.addPoints(); AudioManager.instance.Play("Bounce"); } if (col.gameObject.tag == "Enemy") { GameObject other = col.gameObject; //Destroy(other); <----- Destroy and Collect Points Mode highscore.ballisActive = false; shake.Camshake(); camRipple.RippleEffect(); AudioManager.instance.Play("Player Death"); Gm.setDeath(); Instantiate(explosion, transform.position, Quaternion.identity); //Deactivate this for Weird Physics Mode (Add Borders On all 4 sides) this.gameObject.SetActive(false); } }
void Start() { FindObjectOfType <AudioManager>().Play("PlasmaCannonShoot"); camRipple = Camera.main.GetComponent <RipplePostProcessor>(); camRipple.RippleEffect(); }
void ProcessCollision(GameObject collision) { if (collision.gameObject.tag == "Player") { Instantiate(foodExplosion, transform.position, Quaternion.identity); //var splashPosition = new Vector3(transform.position.x, transform.position.y + YOffset, transform.position.z); //Instantiate(bloodSplashes[Random.Range(0, bloodSplashes.Length)], splashPosition, Quaternion.identity); Instantiate(bloodSplashes[Random.Range(0, bloodSplashes.Length)], transform.position, Quaternion.identity); // Play explosion SFX string[] SFX = new string[] { "Enemy Explosion 1", "Enemy Explosion 2" }; string randomExplosionSFX = SFX[Random.Range(0, SFX.Length)]; AudioManager.instance.Play(randomExplosionSFX); camRipple.RippleEffect(); FindObjectOfType <GameStats>().AddPoints(pointsToGive); Destroy(gameObject); } if (collision.gameObject.tag == "End") { //transform.position = startPoint.transform.position; Destroy(gameObject); } }
public void TakenDamage(int damage) { ripple.RippleEffect(); rgb.velocity = Vector2.up * 50; health = health - damage; AudioSource.PlayClipAtPoint(hurtSound, this.transform.position); player.Damage(); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { ripple.RippleEffect(); } Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = pos; }
public virtual void Die() { AudioManager.instance.Play("Splatter"); GameObject bs = Instantiate(bloodstain, transform.position, Quaternion.identity); Instantiate(deathEffect, transform.position, Quaternion.identity); Destroy(gameObject); Destroy(bs, bloodlifetime); camRipple.RippleEffect(); VirtualCamera.GetComponent <SimpleCameraShakeInCinemachine>().shake(); }
private void Update() { if (health <= 0) { Instantiate(deathEffect, transform.position, Quaternion.identity); ScoreScripts.ScoreValue += 1; FindObjectOfType <AudioManager>().Play("Explosion"); timeManager.DoSlowMotion(); camRipple.RippleEffect(); Destroy(gameObject); } }
// Update is called once per frame void Update() { if (timeBtwAttack <= 0) { if (Input.GetKeyDown(KeyCode.Space)) { ripple.RippleEffect(); Vector3 sPos = new Vector3(5f, 0f, 0f); if (playerController.facingRight) { Instantiate(slash, transform.GetChild(0).transform.position + sPos, Quaternion.identity); } else if (playerController.facingRight == false) { Instantiate(slash, transform.GetChild(0).transform.position - sPos, Quaternion.identity); } AudioSource.PlayClipAtPoint(swordSound, transform.position); playeranime.SetTrigger("Attack"); Collider2D[] enemyToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemy); for (int i = 0; i < enemyToDamage.Length; i++) { if (enemyToDamage[i].gameObject.tag == "run_ene" || enemyToDamage[i].gameObject.tag == "fly_ene") { enemyToDamage[i].GetComponent <Enemy>().TakeDamage(damage); //damage to quai. } else if (enemyToDamage[i].gameObject.tag == "roll_spawner") { enemyToDamage[i].GetComponent <Enemy>().BossTakeDam(damage); } //damage to boss else if (enemyToDamage[i].gameObject.tag == "boss1") { enemyToDamage[i].GetComponent <boss1>().TakeDame(damage); //damage to boss } else if (enemyToDamage[i].gameObject.tag == "Ghost") { enemyToDamage[i].GetComponent <ghostBehavior>().TakenDamage(damage); } } timeBtwAttack = startTimeBtwAttack; } } else { timeBtwAttack -= Time.deltaTime; } }
void Die() { if (enemyHealth <= 0) { Instantiate(bloodSplashes[Random.Range(0, bloodSplashes.Length - 1)], transform.position, Quaternion.identity); Instantiate(contactExplosion, transform.position, Quaternion.identity); // Play explosion SFX string [] SFX = new string[] { "Enemy Explosion 1", "Enemy Explosion 2" }; string randomExplosionSFX = SFX[Random.Range(0, SFX.Length)]; AudioManager.instance.Play(randomExplosionSFX); camRipple.RippleEffect(); //transform.position = startPoint.transform.position; Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { Instantiate(Killeffect, transform.position, Quaternion.identity); player.currentHealth--; Destroy(gameObject); } if (other.CompareTag("Projectile")) { Score.scoreValue += 1; camRipple.RippleEffect(); shake.CamShake(); Instantiate(Killeffect, transform.position, Quaternion.identity); Destroy(other.gameObject); Destroy(gameObject); } }
void Update() { if (health <= 0) { ripple.RippleEffect(); Instantiate(bloodStain, transform.position - new Vector3(0f, 2f), Quaternion.identity); AudioSource.PlayClipAtPoint(deadsound, transform.position); Destroy(gameObject); } if (moveLeft) { transform.Translate(Vector2.left * speed * Time.deltaTime); } else if (!moveLeft) { transform.Translate(Vector2.right * speed * Time.deltaTime); } }
private void Dash() { if (_direction == 0) { if (Input.GetKeyDown(KeyCode.LeftShift) && !IsGrounded()) { if (_playerHorizontalMove < 0) { Instantiate(_dashParticle, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), Quaternion.identity); _direction = 1; } else if (_playerHorizontalMove > 0) { Instantiate(_dashParticle, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), Quaternion.identity); _direction = 2; } _playerAnimation.Dash(); _ripple.RippleEffect(); } } else { if (_dashDuration <= 0) { _direction = 0; _dashDuration = _startDashTime; _rigid.velocity = Vector2.zero; } else { Instantiate(_dashParticle, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), Quaternion.identity); _dashDuration -= Time.deltaTime; if (_direction == 1) { _rigid.velocity = Vector2.left * _dashSpeed; } else if (_direction == 2) { _rigid.velocity = Vector2.right * _dashSpeed; } } } }
void Update() { Vector2 currentPosition = new Vector2(transform.position.x, transform.position.y); Vector2 newPosition = currentPosition + velocity * Time.deltaTime; Debug.DrawLine(currentPosition + offset, newPosition + offset, Color.red); RaycastHit2D[] hits = Physics2D.LinecastAll(currentPosition + offset, newPosition + offset); foreach (RaycastHit2D hit in hits) { GameObject other = hit.collider.gameObject; if (other != sprayer) { // Debug.Log(hit.collider.gameObject); if (other.CompareTag("Enemy")) { BulletParticle(); EnemyParticle(); camRipple.RippleEffect(); FindObjectOfType <AudioManager>().Play("EnemyHit"); spawner.EnemyDied(); Destroy(gameObject); Destroy(other); bloodSplash.SpawnEnemySplash(); Debug.Log(other.name); break; } if (other.CompareTag("Walls")) { BulletParticle(); FindObjectOfType <AudioManager>().Play("WallHit"); Destroy(gameObject); Debug.Log(other.name); break; } } } transform.position = newPosition; }
private void OnTriggerEnter2D(Collider2D collision) { if (!Score.stop) { if (collision.gameObject.tag == "bonus") { if (!doublePoints) { points.text = "+2"; Score.score += 2; } else { points.text = "+4"; Score.score += 4; } gj.SetActive(true); //pointsp.Play("points"); points.color = new Color(1, 0.52f, 0, 1); //pointsp.SetBool("points",true); ChangeColor.Cchange("bonus"); } else if (collision.gameObject.tag == "losebox") { if (!doublePoints) { points.text = "-1"; Score.score += -1; } else { points.text = "-2"; Score.score += -2; } gj.SetActive(true); points.color = new Color(0.77f, 0.21f, 0.13f, 1); //pointsp.SetBool("points", true); ChangeColor.Cchange("lose"); } else if (collision.gameObject.tag == "mysterybox") { gj.SetActive(true); points.color = new Color(0.49f, 0.12f, 0.65f, 1); //pointsp.SetBool("points", true); int a = Random.Range(2, 20); if (!doublePoints) { points.text = "+" + a; Score.score += a; } else { points.text = "+" + a + "* 2 =" + 2 * a; Score.score += 2 * a; } ChangeColor.Cchange("mystery"); } else if (collision.gameObject.tag == "blackbox") { if (!doublePoints) { points.text = "-10"; Score.score += -10; } else { points.text = "-20"; Score.score += -20; } gj.SetActive(true); points.color = new Color(0f, 0f, 0f, 1); //pointsp.SetBool("points", true); ChangeColor.Cchange("black"); } else if (collision.gameObject.tag == "bomb") { points.text = "BOOOOM"; Score.stop = true; gj.SetActive(true); points.color = new Color(0f, 0f, 0f, 1); // pointsp.SetBool("points", true); ChangeColor.Cchange("bomb"); Debug.Log("You Lost"); bigExplosion.Play(); StartCoroutine(MyCoroutine()); // Score.score = 0; } else if (collision.gameObject.tag == "bluepotion") { points.text = "Shrink it dude"; gj.SetActive(true); points.color = new Color(0.23f, 0.855f, 1f); ChangeColor.Cchange("blue"); shreder.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f); StartCoroutine(EffectDuration()); } else if (collision.gameObject.tag == "redpotion") { points.text = "Bigger Dude"; gj.SetActive(true); points.color = new Color(1f, 0.25f, 0.388f); ChangeColor.Cchange("red"); shreder.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); StartCoroutine(EffectDuration()); } else if (collision.gameObject.tag == "double") { points.text = "Double Points"; gj.SetActive(true); points.color = new Color(0f, 1f, 0.071f); ChangeColor.Cchange("green"); doublePoints = true; StartCoroutine(DoublePointsDuration()); } else { if (!doublePoints) { points.text = "+1"; Score.score += 1; } else { points.text = "+2"; Score.score += 2; } gj.SetActive(true); points.color = new Color(0.86f, 0.65f, 0.4f, 1); //pointsp.SetBool("points", true); ChangeColor.Cchange("box"); } Debug.Log("Touched"); BeltMovement.move = false; BeltMovement.destroy = true; Destroy(collision.gameObject); // maybe destroy the object rp.RippleEffect(); ps.Play(); ps2.Play(); } }
public void TakeDame(int dam) { ripple.RippleEffect(); Instantiate(dameffect, transform.GetChild(0).transform.position, Quaternion.identity); boss1Health -= dam; }
public void TakeDamage(int damage) { ripple.RippleEffect(); health -= damage; }