Example #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IHealth health = collision.gameObject.GetComponent <IHealth>();

        if (health != null)
        {
            health.DealDamage(damage);
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        IHealth health = collider.gameObject.GetComponent <IHealth>();

        if (health != null)
        {
            health.DealDamage(damage);
        }
        gameObject.SetActive(false);
    }
    public override void OnTargetPlay(GameObject target)
    {
        IHealth          targetHealth     = target.GetComponent <IHealth>();
        IModifiersHolder targetModifiers  = target.GetComponent <IModifiersHolder>();
        IModifiersHolder damagerModifiers = GameObject.FindObjectOfType <PlayerEntity>().ModifiersHolder;

        Damage damage = DamageCalculator.DealDamage(_damage, damagerModifiers, targetHealth, targetModifiers);

        targetHealth.DealDamage(damage);
    }
Example #4
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        IHealth health = collider.gameObject.GetComponent <IHealth>();

        if (health != null)
        {
            health.DealDamage(damage);
            collider.gameObject.GetComponent <PlayerLightManager>().TakeOutLights(lightOutageDuration);
        }
    }
Example #5
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        IHealth health = collider.GetComponent <IHealth>();

        if (health != null)
        {
            health.DealDamage();
        }
        if (_destroyOnTrigger)
        {
            Destroy(gameObject);
        }
    }
Example #6
0
    public override bool ExecutePerTarget(GameObject target)
    {
        Entity entityTarget = target.GetComponent <Entity>();

        IHealth          targetHealth    = entityTarget.Health;
        IModifiersHolder targetModifiers = entityTarget.ModifiersHolder;
        IModifiersHolder selfModifiers   = _self.GetComponent <IModifiersHolder>();

        Damage damage = DamageCalculator.DealDamage(_damage, selfModifiers, targetHealth, targetModifiers);

        targetHealth.DealDamage(damage);
        return(true);
    }
    public void Explode()
    {
        explosionAudioSource.PlayOneShot(explosionSound);
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, explosionRadius);

        foreach (Collider2D col in colliders)
        {
            IHealth health = col.gameObject.GetComponent <IHealth>();
            if (health != null)
            {
                health.DealDamage(damage);
            }
        }
    }
Example #8
0
 void Update()
 {
     if ((LastFireTime + RateOfFire) <= Time.time && Input.GetButtonDown("Fire1"))
     {
         LastFireTime = Time.time;
         RaycastHit hit;
         Ray        ray = PlayerCamera.FPSCamera.ScreenPointToRay(new Vector3(PlayerCamera.FPSCamera.pixelWidth, 0, PlayerCamera.FPSCamera.pixelHeight));
         if (Physics.Raycast(PlayerCamera.FPSCamera.transform.position, PlayerCamera.FPSCamera.transform.forward, out hit, 100, HitMask))
         {
             if (hit.transform.tag == "Enemy")
             {
                 IHealth health = hit.transform.GetComponent <IHealth>();
                 Debug.Log("Hit Enemy");
                 health.DealDamage();
             }
         }
     }
 }