Exemplo n.º 1
0
        private void AttackInteractable(IInteractable interactable)
        {
            // if the attack was blocked, it can't hit anymore
            // TODO: we probably should do this on a per-source basis
            // and probably should track per-source if it hit / was blocked
            // so we never re-hit and re-block or whatever
            if (_brawler.CurrentAction.WasBlocked)
            {
                return;
            }

            IDamagable damagable = interactable.gameObject.GetComponent <IDamagable>();

            if (null == damagable)
            {
                return;
            }

            Actors.DamageData damageData = new Actors.DamageData {
                Source = Owner,
                SourceBrawlerActionHandler = Owner.Behavior as IBrawlerBehaviorActions,

                AttackData = _attackData,
                Bounds     = _collider.bounds,
                Direction  = _direction,
            };

            if (damagable.Damage(damageData))
            {
                AttackHitEvent?.Invoke(this, new AttackVolumeEventArgs {
                    HitTarget = damagable,
                });
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (_isGameActive)
        {
            if (Input.GetAxis("Fire1") != 0 && Time.time >= _newFireTime)
            {
                _newFireTime = Time.time + _fireDelay;
                Debug.Log("Fire!");
                Instantiate(_bulletPrefab, _bulletSpawn);

                Ray        ray = new Ray(_raycastPoint.position, _raycastPoint.forward);
                RaycastHit hitInfo;

                if (Physics.Raycast(ray, out hitInfo, _fireDistance))
                {
                    Debug.Log("We hit " + hitInfo.collider.name);
                    IDamagable damagable = hitInfo.collider.gameObject.GetComponent <IDamagable>();

                    if (damagable != null)
                    {
                        damagable.Damage(_damageAmount);
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
        void Update()
        {
            // check for left mouse clock
            if (Input.GetMouseButtonDown(0))
            {
                Ray        rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hitInfo;

                if (Physics.Raycast(rayOrigin, out hitInfo))
                {
                    // non-interface needs to check for Player and Enemy:
                    //if (hitInfo.collider.name == "Player")
                    //{
                    //    hitInfo.collider.GetComponent<Player>().Damage(100);
                    //}

                    //else if (hitInfo.collider.name == "Enemy")
                    //{
                    //    hitInfo.collider.GetComponent<Enemy>().Damage(100);
                    //}

                    // interface, just check for the interface
                    IDamagable obj = hitInfo.collider.GetComponent <IDamagable>();
                    if (obj != null)
                    {
                        obj.Damage(100);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void OnBulletImpact(Vector2 startPos, IDamagable damagable, ITargeter targeter)
 {
     if (damagable != null)
     {
         damagable.Damage(damage, targeter);
     }
 }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player" && isPlayer)
        {
            return;
        }
        if (col.tag == "Enemy" && !isPlayer)
        {
            return;
        }

        ExplosionManager exp = ObjectPool.Get <ExplosionManager>();

        exp.Initialize(transform.position, 4);

        if (damage == null)
        {
            return;
        }

        IDamagable target = col.GetComponent <IDamagable>();

        if (target != null)
        {
            target.Damage(damage);
        }

        Disable();
    }
Exemplo n.º 6
0
 private void OnTriggerEnter(Collider other)
 {
     damagableEntity.Damage(0f);
     if ((1 << other.gameObject.layer & (damagableLayerMask.value)) != 0)
     {
         other.transform.root.GetComponent <IDamagable>().Damage(500f);
     }
 }
Exemplo n.º 7
0
    void OnTriggerStay2D(Collider2D col)
    {
        IDamagable damagable = (IDamagable)col.gameObject.GetComponent(typeof(IDamagable));

        if (damagable != null)
        {
            damagable.Damage(damageAmount);
        }
    }
Exemplo n.º 8
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        IDamagable obj       = other.gameObject.GetComponent <IDamagable>();
        Player     playerObj = other.gameObject.GetComponent <Player>();

        if (obj != null && playerObj == null)
        {
            StartCoroutine(DamageEffectSequence(spriteRenderer, Color.red, 0.1f));

            Health -= 1;

            obj.Damage(-1);
        }
        else if (playerObj != null)
        {
            obj.Damage(-1);
        }
    }
Exemplo n.º 9
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        IDamagable <int> damagableObject = collision.gameObject.GetComponent <IDamagable <int> >();

        if (damagableObject != null)
        {
            damagableObject.Damage(damageToDeal);
        }
    }
Exemplo n.º 10
0
    private void OnCollisionEnter(Collision collision)
    {
        IDamagable damageable = collision.gameObject.GetComponent <IDamagable>();

        if (damageable != null)
        {
            damageable.Damage((int)(stats.BaseDamage * stats.DamageModifier()));
        }
    }
Exemplo n.º 11
0
    private void OnCollisionEnter2D(Collision2D collider)
    {
        IDamagable damagable = collider.gameObject.GetComponent <IDamagable>();

        if (damagable != null)
        {
            damagable.Damage((int)(transform.localScale.x * 10), null);
        }
    }
Exemplo n.º 12
0
    public virtual void ApplyDamage(GameObject target)
    {
        IDamagable damagable = target.GetComponent <IDamagable>();

        if (damagable != null)
        {
            damagable.Damage(listener.GetDamage(), listener);
        }
    }
Exemplo n.º 13
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        IDamagable damagable = other.GetComponent <IDamagable>();

        if (damagable != null)
        {
            damagable.Damage(1);
        }
    }
Exemplo n.º 14
0
    // Start is called before the first frame update
    private void OnTriggerStay2D(Collider2D collision)
    {
        IDamagable obj = collision.gameObject.GetComponent <IDamagable>();

        if (obj != null)
        {
            obj.Damage(-1);
        }
    }
Exemplo n.º 15
0
    private void OnCollisionStay2D(Collision2D collider)
    {
        IDamagable damagable = collider.gameObject.GetComponent <IDamagable>();

        if (damagable != null)
        {
            damagable.Damage(666, damageListener);
        }
    }
Exemplo n.º 16
0
    // Run when hitbox collides with another collider
    void OnTriggerEnter2D(Collider2D other)
    {
        IDamagable idamagable = other.GetComponent <IDamagable>();

        if (idamagable != null)
        {
            idamagable.Damage();
        }
    }
Exemplo n.º 17
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("hit" + other.name);
        IDamagable hit = other.GetComponent <IDamagable>();

        if (hit != null)
        {
            hit.Damage();
        }
    }
Exemplo n.º 18
0
    void OnTriggerEnter2D(Collider2D col)
    {
        IDamagable damagable = (IDamagable)col.gameObject.GetComponent(typeof(IDamagable));

        if (damagable != null)
        {
            damagable.Damage(damageAmount);
            player.ChangeHeat(-5);
        }
    }
Exemplo n.º 19
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        IDamagable hit = other.GetComponent <IDamagable>();

        if (hit != null)
        {
            hit.Damage();
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 20
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        IDamagable hit = other.GetComponent <IDamagable>();

        if (hit != null && _canDamage)
        {
            hit.Damage();
            _canDamage = false;
            StartCoroutine(ResetDamage());
        }
    }
Exemplo n.º 21
0
 private void OnParticleCollision(GameObject other)
 {
     if (other.CompareTag("Player"))
     {
         IDamagable <int> damagableObject = other.GetComponent <IDamagable <int> >();
         if (damagableObject != null)
         {
             damagableObject.Damage(damageToDeal);
         }
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Player p = collision.GetComponent <Player>();

        if (p.tag == "Player" && p.Health < p.maxHealth)
        {
            IDamagable p1 = collision.GetComponent <IDamagable>();
            p1.Damage(1);
            Destroy(gameObject);
        }
    }
Exemplo n.º 23
0
 // Check for collission with player
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         IDamagable idamagable = other.GetComponent <IDamagable>();
         if (idamagable != null)
         {
             idamagable.Damage();
             Destroy(gameObject);
         }
     }
 }
Exemplo n.º 24
0
    protected override void OnCantMove(GameObject blocker, MoveDirection direction)
    {
        base.OnCantMove(blocker, direction);

        //Try damaging
        IDamagable damagableBlocker = blocker.GetComponent <IDamagable>();

        if (damagableBlocker != null)
        {
            damagableBlocker.Damage();
        }
    }
Exemplo n.º 25
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         IDamagable hit = other.GetComponent <IDamagable>();
         if (hit != null)
         {
             hit.Damage();
             Destroy(this.gameObject);
         }
     }
 }
Exemplo n.º 26
0
    // Detect Player And Deal Damage
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            IDamagable Hit = collision.GetComponent <IDamagable>();

            if (Hit != null)
            {
                Hit.Damage();
                Destroy(this.gameObject);
            }
        }
    }
Exemplo n.º 27
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        IDamagable hitHealth = collision.gameObject.GetComponent <IDamagable>();

        if (hitHealth != null)
        {
            if (m_HealthComponent != null)
            {
                hitHealth.Damage(gameObject, m_HealthComponent.CurrentHealth, transform.position, MovementDirection);
                m_HealthComponent.Death(collision.gameObject, m_HealthComponent.MaxHealth, transform.position, -MovementDirection);
            }
        }
    }
Exemplo n.º 28
0
    public void Shoot(RaycastHit raycastHit)
    {
        bool isHitObjectInteractable = raycastHit.collider.gameObject.TryGetComponent(out _damagable);

        if (isHitObjectInteractable && raycastHit.collider.gameObject != _playerGameObject)
        {
            _damagable.Damage(_weapon.damagePerShot);
            return;
        }

        Vector3 highestPointOfCollider = raycastHit.point + raycastHit.normal * NORMAL_MULTYPLIER;

        SpawnBulletHole(raycastHit, highestPointOfCollider);
    }
Exemplo n.º 29
0
 /// <summary>
 /// Apply damage to player if self attackHitbox collides with it.
 /// </summary>
 /// <param name="origin">GameObject on which OnTriggerExit method was called.</param>
 /// <param name="other">Collider data of the OnTriggerExit method.</param>
 public void OnExtensionTriggerEnter(GameObject origin, Collider other)
 {
     if (origin == attackHitbox)
     {
         IDamagable damagable = other.GetComponent <IDamagable>();
         if (damagable != null)
         {
             if ((damagable.GetFaction() & oppositeFaction) != 0)
             {
                 damagable.Damage(stats.attackDamageMultiplier, lookingDirection, stats.attackForceMultiplier);
             }
         }
     }
 }
Exemplo n.º 30
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //if(player.isPunching) {
        Debug.Log(col.gameObject);
        IDamagable damagable = (IDamagable)col.gameObject.GetComponent(typeof(IDamagable));

        if (damagable != null)
        {
            GetComponent <AudioSource>().Play();
            damagable.Damage(damageAmount);
            player.ChangeHeat(-10);
        }
        //}
    }