private bool EnemyDamage(Collider2D coll) { if (coll.gameObject.name.Contains("PL_ATT")) { PlayerController plCont = coll.gameObject.transform.parent.parent.parent.gameObject.GetComponent <PlayerController>(); if (!plCont.isDashing) { plCont.didAttackHitEnemy++; critical = plCont.processCriticalHit(); if (plCont.playerNo == 1) { ArenaScoreSystem.AddPlayer1Score(5 * (critical ? 2 : 1) * (plCont.hitComboCount == 0 ? 1 : plCont.hitComboCount)); } else if (plCont.playerNo == 2) { ArenaScoreSystem.AddPlayer2Score(5 * (critical ? 2 : 1) * (plCont.hitComboCount == 0 ? 1 : plCont.hitComboCount)); } if (plCont.weaponPossession.weaponID < 0) { hpDamage = plCont.weaponPossession.defaultDamage * (critical ? criticalDamageRatio : 1f); knockbackValue = plCont.weaponPossession.defaultKnockback * (critical ? criticalKnockbackRatio : 1f); } else { hpDamage = (plCont.weaponPossession.weapons[plCont.weaponPossession.weaponID].damage * (critical ? criticalDamageRatio : 1f)) / defenseFactor; knockbackValue = (plCont.weaponPossession.weapons[plCont.weaponPossession.weaponID].knockback * (critical ? criticalKnockbackRatio : 1f)) / defenseFactor; } if (breakAttackOnHit) { GetComponent <EnemyAI>().stopAttacking(); } isHit = true; OnHit.Invoke( ); hitAngle = Mathf.Atan2(coll.gameObject.transform.parent.parent.parent.position.y - gameObject.transform.position.y, coll.gameObject.transform.parent.parent.parent.position.x - gameObject.transform.position.x); return(true); } } return(false); }
private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.name.Contains("Player")) { if (Vector2.Distance(transform.position, collision.gameObject.transform.position) <= minCollectDistance) { if (type == ImpactType.HP) { collision.gameObject.GetComponent <HitCheck>().hp += value; } else if (type == ImpactType.Stamina) { collision.gameObject.GetComponent <PlayerController>().actionPoints += value; } if (collision.gameObject.name == "Player1") { ArenaScoreSystem.AddPlayer1Score(2); } else if (collision.gameObject.name == "Player2") { ArenaScoreSystem.AddPlayer2Score(2); } if (aud != null && TogglesValues.sound) { aud.PlayOneShot(impactSound); } Destroy(gameObject); } else { transform.position = Vector3.Lerp(transform.position, collision.gameObject.transform.position, magnetStrength); } } }