private void OnCollisionEnter(Collision collision) { StickmanPart component = collision.gameObject.GetComponent <StickmanPart>(); if ((component != null) && (component.Stickman.CurrentHealth > 0)) { Vector3 point = collision.contacts[0].point; if (this._blowMultiplier > 0f) { Vector3 vector2 = component.rigidbody.position - point; component.StartForce((Vector2)((vector2.normalized * this._game.BlowForce) * this._blowMultiplier), point, this._game.BlowTime); } this._game.CreateHitParticles(collision.contacts[0].point, false); component.Stickman.Hit(this._damage); component.Blink(); if (component.Stickman.CurrentHealth <= 0) { this._game.PlayDeathSound(); } this._game.PlaySwordSound(); if (component.name.Contains("Head")) { component.Stickman.ReleaseWeapons(); } if (!this._game.IsOver) { this._game.SlowMo(component.Stickman.CurrentHealth <= 0); } } }
private void OnCollisionEnter2D_Legacy(Collision2D collision) { foreach (ContactPoint2D hit in collision.contacts) { Vector2 hitPoint = hit.point; } StickmanPart component = collision.gameObject.GetComponent <StickmanPart>(); if (((((component != null) && (component.Stickman != this.Stickman)) && ((this.Stickman.Hp > 0) && (component.Stickman.Hp > 0))) && (this.Stickman.IsPlayer != component.Stickman.IsPlayer)) && (this._rigidbody.velocity.sqrMagnitude >= component._rigidbody.velocity.sqrMagnitude)) { Vector3 point = collision.contacts[0].point; if (this.CanHit || component.CanHit) { //Vector3 vector4 = this._rigidbody.position - point; //this.StartForce((Vector2)(vector4.normalized * this._game.BlowForce), point, this._game.BlowTime); //Vector3 vector5 = component._rigidbody.position - point; //component.StartForce((Vector2)(vector5.normalized * this._game.BlowForce), point, this._game.BlowTime); } bool twice = false; if (this.CanHit && component.CanGetHit) { //this._game.CreateHitParticles(point, true); //component.Stickman.Hit(this.Stickman.Damage); component.Blink(); if (component.Stickman.Hp <= 0) { //this._game.PlayDeathSound(); twice = true; } else { //this._game.PlayHitSound(false); } string str = string.Empty; if (base.name.Contains("Head")) { str = "Butt"; } else if (base.name.Contains("Arm")) { str = "Punch"; } else if (base.name.Contains("Leg")) { str = "Kick"; } string str2 = string.Empty; if (component.name.Contains("Head")) { str2 = "Head"; } else if (component.name.Contains("Arm")) { str2 = "Arm"; } else if (component.name.Contains("Leg")) { str2 = "Leg"; } else if (component.name.Contains("Spine")) { str2 = "Body"; } if (base.name.Contains("Head") && component.name.Contains("Head")) { str2 = "Head"; str = "Bounce"; } //this._game.CreateText(str2 + " " + str, UnityEngine.Color.red, point, 0, 0f, -1f, 0f, 0f); if (str2 == "Head") { //component.Stickman.ReleaseWeapons(); } } if (this.CanGetHit && component.CanHit) { //this._game.CreateHitParticles(point, true); //this.Stickman.Hit(component.Stickman.Damage); this.Blink(); if (this.Stickman.Hp <= 0) { //this._game.PlayDeathSound(); twice = true; } else { //this._game.PlayHitSound(false); } string str3 = string.Empty; if (component.name.Contains("Head")) { str3 = "Butt"; } else if (component.name.Contains("Arm")) { str3 = "Punch"; } else if (component.name.Contains("Leg")) { str3 = "Kick"; } string str4 = string.Empty; if (base.name.Contains("Head")) { str4 = "Head"; } else if (base.name.Contains("Arm")) { str4 = "Arm"; } else if (base.name.Contains("Leg")) { str4 = "Leg"; } else if (base.name.Contains("Spine")) { str4 = "Body"; } if (base.name.Contains("Head") && component.name.Contains("Head")) { str4 = "Head"; str3 = "Bounce"; } //this._game.CreateText(str4 + " " + str3, UnityEngine.Color.red, point, 0, 0f, -1f, 0f, 0f); if (str4 == "Head") { //this.Stickman.ReleaseWeapons(); } } if ((this.CanHit && !this.CanGetHit) && (component.CanHit && !component.CanGetHit)) { //this._game.CreateBlockParticles(point); //this._game.PlayBlockSound(); } if (this.CanHit || component.CanHit) { //this._game.SlowMo(twice); //this._game.AddStickmanKey(this.Stickman); //this._game.AddStickmanKey(component.Stickman); } } }