private void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.layer == 8 || coll.gameObject.layer == 11) { invincib += 20; if (invincib >= 70) { base.gameObject.layer = 20; } } if (coll.gameObject.CompareTag("arme")) { equil = Corps1.gameObject.GetComponent <Equilibre>(); equil.stun = equil.stun + coll.relativeVelocity.magnitude * 3f + 100f; equil = Corps2.gameObject.GetComponent <Equilibre>(); equil.stun = equil.stun + coll.relativeVelocity.magnitude * 3f + 100f; if (AiPart && coll.relativeVelocity.magnitude > ImpactPower && FollowPlayer1.enabled) { FollowPlayer1.enabled = false; corpsCode1.enabled = false; corpsCode2.enabled = false; PiedCode1.enabled = false; PiedCode2.enabled = false; JambeCode1.enabled = false; JambeCode2.enabled = false; Desactive = 100; if (JoueurVIe.Hp > 0f) { JoueurVIe.TimeRecord = JoueurVIe.TimeRecord + 1f + BonusScore; } } } if (coll.gameObject.layer != 8 || !(coll.gameObject.transform.name != "Slice Teleportation") || !AiPart || !FollowPlayer1.enabled) { return; } if (coll.transform.parent.gameObject.name == "Perso") { JoueurVIe.Hp -= 0.014f; } if (GameObject.Find("Perso 2") != null && coll.transform.parent.gameObject.name == "Perso 2") { JoueurVIe2.Hp -= 0.014f; } randomFrappe = UnityEngine.Random.Range(0, 4); if (randomFrappe != 2) { return; } ContactPoint2D[] contacts = coll.contacts; for (int i = 0; i < contacts.Length; i++) { ContactPoint2D contactPoint2D = contacts[i]; explsionActiveKnockBack[] array = Resources.FindObjectsOfTypeAll <explsionActiveKnockBack>(); for (int j = 0; j < array.Length; j++) { if (array[j].transform.name == "explosion (2)") { array[j].gameObject.SetActive(value: false); array[j].gameObject.SetActive(value: true); GameObject.Find("RedKnockback2").GetComponent <PointEffector2D>().forceMagnitude = 1000f; array[j].transform.position = contactPoint2D.point; } int num = UnityEngine.Random.Range(0, 3); if (num == 0) { source.PlayOneShot(CoupStickman1); } if (num == 1) { source.PlayOneShot(CoupStickman2); } if (num == 2) { source.PlayOneShot(CoupStickman3); } } } }
private void Start() { rb2D = GetComponent <Rigidbody2D>(); equil = GetComponent <Equilibre>(); }