private void OnCollisionEnter2D(Collision2D collision) { _player = collision.gameObject.GetComponent <PlayerStats>(); _anger = collision.gameObject.GetComponent <Anger>(); if (collision.gameObject.layer == 9) { _player.Damage(50); _player._canRegen = false; _anger.Damage(50); _anger._canRegen = false; } }
private void OnCollisionEnter2D(Collision2D collision) { _tree = collision.gameObject.GetComponent <Treead>(); _golire = collision.gameObject.GetComponent <Golire>(); _anger = collision.gameObject.GetComponent <Anger>(); _breeze = collision.gameObject.GetComponent <Breeze>(); if (collision.gameObject.layer == 13 || collision.gameObject.layer == 14) { if (collision.gameObject.name == "Treead" || collision.gameObject.name == "Treead(Clone)") { if (this.transform.position.x > _tree.transform.position.x) { _tree.transform.Translate(new Vector2(-2, 0)); } if (this.transform.position.x < _tree.transform.position.x) { _tree.transform.Translate(new Vector2(2, 0)); } _tree._burnTime = 0f; } if (collision.gameObject.name == "Golire" || collision.gameObject.name == "Golire(Clone)") { Debug.Log("You'r not burning anymore!"); _golire.extinguished = true; } if (collision.gameObject.name == "Breeze" || collision.gameObject.name == "Breeze(Clone)") { _breeze.Damage(30); } } if (collision.gameObject.layer == 14) { if (collision.gameObject.name == "Anger") { _anger.Damage(30); _anger._canRegen = false; } } if (collision.gameObject.layer == 12) { Destroy(collision.gameObject); } Destroy(this.gameObject); _windParticle.Play(); _windParticle.transform.parent = null; Destroy(_windParticle, 3.0f); }
private void OnCollisionEnter2D(Collision2D collision) { _tree = collision.gameObject.GetComponent <Treead>(); _golire = collision.gameObject.GetComponent <Golire>(); _breeze = collision.gameObject.GetComponent <Breeze>(); _anger = collision.gameObject.GetComponent <Anger>(); _player = collision.gameObject.GetComponent <PlayerStats>(); _shaker = collision.gameObject.GetComponent <Shake>(); if (collision.gameObject.layer == 13 || collision.gameObject.layer == 14) { if (collision.gameObject.name == "Treead" || collision.gameObject.name == "Treead(Clone)") { _tree.Damage(50); _tree._burnTime = 4f; _tree.afterBurn(); } if (collision.gameObject.name == "Golire" || collision.gameObject.name == "Golire(Clone)") { Debug.Log("Burn again!"); _golire.extinguished = false; } if (collision.gameObject.name == "Breeze" || collision.gameObject.name == "Breeze(Clone)") { _breeze.Damage(50); } } if (collision.gameObject.layer == 14) { if (collision.gameObject.name == "Anger") { _anger.Damage(50); _anger._canRegen = false; } } if (collision.gameObject.layer == 9) { _player.Damage(50); _player._canRegen = false; //_anger.Damage(50); //_anger._canRegen = false; Shake.canShake = true; } Destroy(this.gameObject); _fireParticle.Play(); _fireParticle.transform.parent = null; Destroy(_fireParticle, 2.0f); }
private void OnCollisionStay2D(Collision2D collision) { _tree = collision.gameObject.GetComponent <Treead>(); _golire = collision.gameObject.GetComponent <Golire>(); _anger = collision.gameObject.GetComponent <Anger>(); _breeze = collision.gameObject.GetComponent <Breeze>(); if (collision.gameObject.layer == 13) { if (collision.gameObject.name == "Treead") { _tree.Damage(10 * Time.deltaTime); } if (collision.gameObject.name == "Golire") { Debug.Log("Burn again!"); _golire.extinguished = false; } if (collision.gameObject.name == "Breeze") { _breeze.Damage(10 * Time.deltaTime); } } if (collision.gameObject.layer == 14) { if (collision.gameObject.name == "Anger") { _anger.Damage(10 * Time.deltaTime); _anger._canRegen = false; } } if (collision.gameObject.layer == 8) { Destroy(this.gameObject); } }