Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (!Target)
        {
            return;
        }

        _agent.SetDestination(Target.transform.position);
        Vector3 direction = Target.transform.position - transform.position;
        float   distance  = direction.magnitude;

        if (distance < _attackRange)
        {
            float time = 0;
            time += Time.deltaTime;
            _agent.SetDestination(-direction);

            if (time > _timeToAttack / 3 && distance < _meleeRange)
            {
                TargetHealth.TakeDamage(_meleedamage);
            }
            else if (time > _timeToAttack)
            {
                _bulletEmmiter.Fire(transform.forward);
            }
        }
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         HealthBehaviour playerHealthScript = collision.gameObject.GetComponent <HealthBehaviour>();
         playerHealthScript.TakeDamage(damageAmount);
     }
 }
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour health = collision.gameObject.GetComponent <HealthBehaviour>();

        if (health != null && health.name == _target.name)
        {
            health.TakeDamage(_damage);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        HealthBehaviour health = other.GetComponent <HealthBehaviour>();

        if (health != null && other.name != owner)
        {
            health.TakeDamage(_damage);
            Destroy(gameObject);
        }
    }
Exemple #5
0
    private void TryDealDamage(HealthBehaviour targetHealth)
    {
        if (targetHealth == null)
        {
            return;
        }
        bool condition = false;

        targetHealth.TakeDamage(arrowDamage, out condition);
    }
Exemple #6
0
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour health = collision.gameObject.GetComponent <HealthBehaviour>();

        if (health != null)
        {
            health.TakeDamage(20);
        }
        Destroy(gameObject, 1f);
    }
    private void OnTriggerEnter(Collider other)
    {
        //Grab the health behaviour attached to the object
        HealthBehaviour health = other.GetComponent <HealthBehaviour>();

        //If the health behaviour isn't null, deal damage
        if (health)
        {
            health.TakeDamage(Damage);
        }
    }
Exemple #8
0
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour hb = collision.gameObject.GetComponent <HealthBehaviour>();

        if (hb)
        {
            hb.TakeDamage(10);
        }

        Destroy(gameObject, 0.5f);
    }
    private void OnCollisionEnter(Collision collision)
    {
        //Get a reference to the attached health script
        HealthBehaviour health = collision.gameObject.GetComponent <HealthBehaviour>();

        //If the health isn't null, deal damage
        if (health)
        {
            health.TakeDamage(_damage);
        }
    }
Exemple #10
0
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour healthBehaviour = collision.gameObject.GetComponent <HealthBehaviour>();

        //çarpılan objenin sağlığı var mı yok mu?
        if (healthBehaviour != null)
        {
            healthBehaviour.TakeDamage(20);
        }
        Destroy(gameObject, 1);
    }
Exemple #11
0
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour hb = collision.gameObject.GetComponent <HealthBehaviour>();

        if (hb != null)
        {
            hb.TakeDamage(15);
        }
        //mermi bir yere carptıysa 1 sn sonra yok et.
        //1 sn çünkü fiziksel özellikler uygulanabilsin.
        Destroy(gameObject, 1);
    }
    private void OnCollisionEnter(Collision collision)//Carptıgı gameobejct
    {
        HealthBehaviour hb = collision.gameObject.GetComponent <HealthBehaviour>();

        //Carpılan objenin sağlığı varmı yokmu?

        if (hb)//hb null değilse
        {
            hb.TakeDamage(20);
        }

        Destroy(gameObject, 0.5f);
    }
Exemple #13
0
    private void ShieldRecharge()
    {
        if (_healthBehaviour.CurrentHealth < _healthBehaviour.MaxHealth)
        {
            _timerHealth += Time.deltaTime;

            if (_timerHealth >= _timeToRechargeShieldHealth)
            {
                _timerHealth -= _timeToRechargeShieldHealth;
                _healthBehaviour.TakeDamage(-1);
            }
        }
    }
Exemple #14
0
 //Checks to see what the bullet ran into. If it is not the owner and has a health script attached to it, then it damages it
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag(owner) == false)
     {
         HealthBehaviour healthScript = other.GetComponent <HealthBehaviour>();
         if (healthScript == null)
         {
             Destroy();
             return;
         }
         healthScript.TakeDamage(damageAmount);
         Destroy();
     }
 }
        private bool Hit(HealthBehaviour otherEntityHealth)
        {
            if (otherEntityHealth != null)
            {
                if (otherEntityHealth.Health > 0)
                {
                    var calculatedDamage = CalculateTotalDamage();
                    //Debug.Log(calculatedDamage);
                    otherEntityHealth.TakeDamage(calculatedDamage);
                    AudioManager.Play("Hit");
                    return(true);
                }
            }

            return(false);
        }
Exemple #16
0
        private bool Hit(HealthBehaviour otherEntityHealth)
        {
            if (otherEntityHealth != null)
            {
                if (otherEntityHealth.Health > 0)
                {
                    otherEntityHealth.TakeDamage(OwnerWeaponBehaviour.Damage + Item.Damage + (OwnerWeaponBehaviour.OwnerMobileProps.Ranged.CurrentValue / 10));
                    return(true);
                }
            }

            if (audioManager != null)
            {
                audioManager.Play("Hit");
            }



            return(false);
        }
Exemple #17
0
    private void OnCollisionEnter(Collision collision)
    {
        // If the other GameObject's layer is in _whatToDamage
        if (((1 << collision.gameObject.layer) & _whatToDamage) != 0)
        {
            // Get a reference to the other object's HealthBehaviour
            HealthBehaviour otherHealth = collision.gameObject.GetComponent <HealthBehaviour>();

            // If it has a HealthBehaviour, damage it
            if (otherHealth)
            {
                otherHealth.TakeDamage(_damage);
            }
            // If not, log a warning
            else if (_showWarningsInConsole)
            {
                Debug.LogWarning("Collided object " + collision.gameObject + " does not have a HealthBehaviour. Cannot damage it.");
            }
        }
    }
Exemple #18
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        HealthBehaviour          health    = other.gameObject.GetComponent <HealthBehaviour>();
        HighlightObjectBehaviour highlight = other.GetComponent <HighlightObjectBehaviour>();

        if (health != null && _canDamage)
        {
            health.TakeDamage(_damage);

            if (highlight != null)
            {
                highlight.Highlight = true;
            }
        }
        else
        {
            Debug.Log(other.gameObject + "cannot take damage");
        }

        _canDamage = false;
        Invoke("Kill", 0.02f);
    }
Exemple #19
0
 public void DealDamage(HealthBehaviour target)
 {
     target.TakeDamage(damageData.Damage);
 }
Exemple #20
0
 public void ResetPlayer()
 {
     _playerHealth.TakeDamage(-10);
     transform.position = Vector3.zero;
 }