protected override void OnHitEnemy(GameObject hitObject) { // Gets the component (of the target hit) that controls the health, UnitAttributes targetAttributes = hitObject.GetComponent <UnitAttributes> (); // and deal damage to it targetAttributes.ApplyAttack(projectileDamage, projectileBuffs); // projectile dies }
// Update is called once per frame void Update() { if (!ReInput.isReady) { return; } if (!initialized) { nekoyuPlayer = ReInput.players.GetPlayer(playerID); } if (BuffSkill.isBuffed == true && isBuffed == false) { isBuffed = true; } if (BuffSkill.isBuffed == false && isBuffed == true) { isBuffed = false; } if (transform.localScale.x > 0) { facingRight = true; } else { facingRight = false; } if (nekoyuPlayer.GetButton("Right Button") && currentDashCooldown <= 0f) { characterAnimator.Play("Dash", 0, 0f); isDashing = true; currentDashCooldown = dashCooldown; unitAttributes.ApplyAttack(0, transform.position, dashBuff); } if (isDashing && currentDashDuration > 0f) { startDash(); } if (currentDashDuration <= 0f) { boxcollider.isTrigger = false; currentDashDuration = dashDuration; isDashing = false; NekoyuInput.attacking = false; } if (currentDashCooldown > 0) { currentDashCooldown -= Time.deltaTime; } }
//destroys player on contact with enemy protected virtual void OnCollisionStay2D(Collision2D other) { GameObject hitObject = other.gameObject; if (Time.time > time + damageCooldownTime) { if (hitObject.layer == LayerMask.NameToLayer(ENEMY_LAYER)) { unitAttributes.ApplyAttack(damageTaken, new Vector2(0, 0)); time = Time.time; } } }
void DamageEnemyGameObject(GameObject go) { UnitAttributes attributes = go.GetComponent <UnitAttributes>(); attributes.ApplyAttack(damage, transform.position, Color.blue); }
public override void ApplyAttack(float damageDealt, Vector2 point, Color damageColor, params Buff[] attackBuffs) { bridgeguardAttributes.ApplyAttack(damageDealt * currentDamageTakenFactor, point, damageColor, attackBuffs); }