private void OnCollisionEnter2D(Collision2D collision) { ICanTakeDamage _canTakeDamage = collision.collider.gameObject.GetComponent <ICanTakeDamage>(); if (_canTakeDamage != null) { _canTakeDamage.TakeDamage(); } }
/// <summary> /// called by melleeWeapon /// </summary> /// <param name="Target"></param> public void DealDamage(ICanTakeDamage Target) { if (isServer || test) { Debug.Log("yo2"); Target.TakeDamage(mainAttackDamage, this); } }
public void Attack() { Collider2D[] damage = Physics2D.OverlapCircleAll(attPos.position, attackRange, enemiesLayer); for (int i = 0; i < damage.Length; i++) { ICanTakeDamage objToTakeDamage = damage[i].GetComponent <ICanTakeDamage>(); if (objToTakeDamage != null) { objToTakeDamage.TakeDamage(); } } }
public AttackStage Attack(ICanTakeDamage canTakeDamage, float baseDamageAmount) { attackTimer += Time.deltaTime; if (!attacked && attackTimer < anticipationTimeInMs) { Debug.Log(string.Format("Anticipating: {0}", 0)); return(AttackStage.Anticipation); } else if (!attacked && attackTimer > anticipationTimeInMs) { canTakeDamage.TakeDamage(baseDamageAmount * damageMultiplier); attacked = true; return(AttackStage.Contact); } else if (attacked && attackTimer < recoveryTimeInMs + anticipationTimeInMs) { Debug.Log(string.Format("Recovering: {0}", 0)); return(AttackStage.Recovery); } return(AttackStage.Complete); }
public void Attack(ICanTakeDamage canTakeDamage) { canTakeDamage.TakeDamage(damageToDeal); }
protected override void OnCollideTakeDamage(Collider2D other, ICanTakeDamage takedamage) { takedamage.TakeDamage(Damage, Vector2.zero, gameObject); SoundManager.PlaySfx(soundHitEnemy, soundHitEnemyVolume); DestroyProjectile(); }