public void Damage() { if (!isLittleMario && littleMarioPrefab) { GameObject newMario = Instantiate(littleMarioPrefab, transform.position, Quaternion.identity); MarioInvensibleEffect invensibleEffect = newMario.GetComponent <MarioInvensibleEffect>(); if (invensibleEffect) { invensibleEffect.InvensibleEffect(); } Destroy(gameObject); } else if (GetComponent <MarioDeath>()) { GetComponent <MarioDeath>().Active(); } }
protected override void OnTrigger(GameObject other) { Vector2 otherPos = other.transform.position; Vector2 myPos = transform.position; if (other.GetComponent <StarEffect>().ItsStarEffect) { if (GetComponent <ScoreGiven>()) { GetComponent <ScoreGiven>().SetScore(); } Destroy(gameObject); } else if (Mathf.Abs(otherPos.x - myPos.x) < 0.8f && otherPos.y > myPos.y) { other.gameObject.GetComponent <MarioAttackEffect>().AttackEffect(); if (GetComponent <ScoreGiven>()) { GetComponent <ScoreGiven>().SetScore(); } DamageEnemy(); } else { MarioInvensibleEffect marioInvensibleEffect = other.gameObject. GetComponent <MarioInvensibleEffect>(); if (marioInvensibleEffect && !marioInvensibleEffect.IsInvensible) { other.gameObject.GetComponent <MarioDamage>().Damage(); } } }