Exemplo n.º 1
0
    public void CollidedWith(Collider collider)
    {
        Debug.Log("Player collided with " + collider.gameObject.name);
        Hurtbox           hurtbox           = collider.GetComponent <Hurtbox>();
        IHealthController hurtBoxController = hurtbox.GetComponentInParent <IHealthController>(); // the parent gameobject will implement the health and damage
        Damage            attackDamage      = new Damage(15);

        hurtBoxController?.ReceiveDamage(attackDamage);
    }
        public virtual void ReceiveDamage(IDamageData damageData)
        {
            if (useLog)
            {
                Debug.Log($"{Name} {nameof(ReceiveDamage)} {damageData}");
            }

            healthController.ReceiveDamage(damageData.Damage);

            if (healthController.CurrentHealth <= 0.0f)
            {
                Kill(new KillerInfo(damageData.DamageOwner, damageData.DamageSource));
            }
        }