private void Shoot()
        {
            if (muzzleFlashFX)
            {
                muzzleFlashFX.Play();
            }

            RaycastHit hit            = hitInfo.GetHit(range, hitLayer);
            Vector3    shootDirection = hitInfo.Direction;

            if (hit.rigidbody)
            {
                float hitDistance = hit.distance;
                //float hitDistance = Vector3.Distance(transform.position, hit.point);
                float acceleration = hitDistance * distanceToAccelerationMult;
                hit.rigidbody.velocity += Mathf.Abs(range - hitDistance) * shootDirection;
                hit.rigidbody.velocity  = Vector3.ClampMagnitude(hit.rigidbody.velocity, objectMaxSpeed);
                Health targetHealth = hit.transform.GetComponent <Health>();

                if (targetHealth && damageDealer)
                {
                    DamageDealer.DealDamage(targetHealth, damage);
                }

                //AIMovement aiMovement = hit.transform.GetComponent<AIMovement>();
                //if (aiMovement)
                //{
                //    aiMovement.KnockBack(shootDirection, true);
                //}
            }
        }
    private void OnCustomEvent(string evt)
    {
        var offset = frameInfos[current];
        var size   = frameInfos[current + 1];

        if (faceDirectionComponent.FaceDirection == -1)
        {
            offset.x = -offset.x;
        }

        Collider2D[] hitCollider2Ds =
            Physics2D.OverlapBoxAll(Owner.transform.position + (Vector3)offset, size, LayerMask.GetMask("PlayerBody"));

        foreach (var hit in hitCollider2Ds)
        {
            if (hit != null)
            {
                _damageDealer.DealDamage(hit.gameObject, hit.transform.position);
            }
        }

        // DebugExtensions.DrawBox ( Owner.transform.position + (Vector3)offset, size, 0f, Color.red );

        current += 2;
    }
Esempio n. 3
0
 private void OnTriggerStay(Collider col)
 {
     if (shouldDealDamage)
     {
         dmgDealer.DealDamage(col.gameObject);
     }
 }
    void Fly_Tick()
    {
        if (Target == null)
        {
            currentState = State.Boom;
            return;
        }

        _characterController2D.Move(FlySpeed * CupheadTime.Delta[CupheadTime.Layer.Enemy] * ( Vector3 )Dir);
        if (_characterController2D.collisionState.hasCollision())
        {
            currentState = State.Boom;
        }

        Collider2D hitCollider2D = Physics2D.OverlapCircle(transform.position, 0.23f, LayerMask.GetMask("PlayerBody"));

        if (hitCollider2D != null)
        {
            _damageDealer.DealDamage(hitCollider2D.gameObject, hitCollider2D.transform.position);
        }

        _timer += CupheadTime.Delta[CupheadTime.Layer.Enemy];
        if (_flyTrackEnable && _timer >= _flyTrackWaitTimeRandomRange)
        {
            Dir             = (Target.position - transform.position).normalized;
            _timer          = 0f;
            _flyTrackEnable = false;
        }
        if (_timer >= FlyDestroyTime || Target == null)
        {
            currentState = State.Boom;
        }
    }
Esempio n. 5
0
    private void OnCollisionEnter(Collision other)
    {
        if (weaponState == WeaponState.Firing)
        {
            // Process punch hit
            CreatePhysicalImpact(other);
            PlayPunchHitSound();
            if (damageDealer)
            {
                damageDealer.DealDamage(other.gameObject, punchDamage, isCharged);
            }

            // State change
            AnimateReleaseCharge();
            TransitionToRearmingState();
        }
    }
    void Fly_Tick()
    {
        _characterController2D.Move(FlySpeed * CupheadTime.Delta[CupheadTime.Layer.Enemy] * (Vector3)Dir);

        if (_characterController2D.collisionState.hasCollision())
        {
            currentState = State.Boom;
        }

        Collider2D hitCollider2D = Physics2D.OverlapBox(transform.position + new Vector3(angle < 0f ? 0.44f : -0.44f, -0.27f), new Vector2(0.31f, 0.28f), 0f, LayerMask.GetMask("PlayerBody"));

        if (hitCollider2D != null)
        {
            _damageDealer.DealDamage(hitCollider2D.gameObject, hitCollider2D.transform.position);
        }

        // DebugExtensions.DrawBox ( transform.position + new Vector3 ( angle < 0f ? 0.44f : -0.44f, -0.27f ), new Vector2 ( 0.31f, 0.28f ), 0f, Color.red );
    }
    void OnAttackHit(GameObject hitObject, Vector3 hitPoint)
    {
        if (!hitObject.CompareTag("PlayerBody"))
        {
            return;
        }

        _damageDealer.DealDamage(hitObject, hitPoint);
    }
Esempio n. 8
0
    private void OnTriggerEnter(Collider other)
    {
        PlayParticleEffect();
        PlaySawHitSound();

        if (damageDealer)
        {
            damageDealer.DealDamage(other.gameObject, damageAmount, false);
        }
    }
Esempio n. 9
0
    private void OnTriggerExit(Collider other)
    {
        if (hazardState == HazardState.Ready)
        {
            return;
        }

        if (damageDealer)
        {
            damageDealer.DealDamage(other.gameObject, damageAmount, false);
        }
    }
Esempio n. 10
0
    void OnTriggerEnter(Collider other)
    {
        DamageableItem dmgTarg;

        if ((dmgTarg = other.GetComponent <DamageableItem> ()) != null)
        {
            DamageInfo dmg = new DamageInfo();
            dmg.baseDamage = baseDamage * (Mathf.Clamp01(col.radius - (other.transform.position - transform.position).magnitude) / col.radius);
            dmg.target     = dmgTarg;
            dd.DealDamage(dmg);
        }
    }
    void Landed_Enter()
    {
        transform.Find("pse_effect_10706_tuowei")?.gameObject.SetActive(false);
        _animator.gameObject.SetActive(true);
        _animator.Play("Boss_08_Atk04texiao");

        Collider2D hitCollider2D =
            Physics2D.OverlapBox(_animator.transform.position + new Vector3(-0.1f, -0.34f), new Vector2(1.7f, 3.17f), LayerMask.GetMask("PlayerBody"));

        if (hitCollider2D != null)
        {
            _damageDealer.DealDamage(hitCollider2D.gameObject, hitCollider2D.transform.position);
        }
    }
Esempio n. 12
0
        private void Attack(float damage)
        {
            RaycastHit hit = hitInfo.GetHit(attackRange);

            if (hit.rigidbody)
            {
                Health targetHealth = hit.transform.GetComponent <Health>();

                if (targetHealth && damageDealer)
                {
                    DamageDealer.DealDamage(targetHealth, damage);
                    Debug.Log("[" + controller.gameObject.name + "] Dealt [" + damage + "] Damage");
                }
            }
        }
    void OnAttackHit(GameObject hitObject, Vector3 hitPoint)
    {
        if (!hitObject.CompareTag("PlayerBody"))
        {
            return;
        }

        if (_damageDealer.DealDamage(hitObject, hitPoint))
        {
            if (BoomOnDamage)
            {
                currentState = State.Boom;
            }
        }
    }
Esempio n. 14
0
    void EndEffect(EndEffectData ed)
    {
        if (ed.targ == null)
        {
            return;
        }
        DamageInfo d = new DamageInfo();

        d.baseDamage = ed.magnitude;
        DamageableItem di = ed.targ.GetComponent <DamageableItem> ();

        if (di != null)
        {
            d.target = di;
            dmg.DealDamage(d);
        }
    }
Esempio n. 15
0
    private void OnCollisionEnter(Collision collision)
    {
        if (hazardState != HazardState.Firing)
        {
            return;
        }

        CreatePhysicalImpact(collision);
        PlayHammerHitSound();

        if (damageDealer)
        {
            damageDealer.DealDamage(collision.gameObject, damageAmount, false);
        }

        hazardState = HazardState.Rearming;
    }
Esempio n. 16
0
    void Mid_Tick()
    {
        _timer += CupheadTime.Delta[CupheadTime.Layer.Enemy];
        if (_timer >= Duration)
        {
            currentState = State.End;
        }

        _damageDealer.Update();

        Collider2D[] hitCollider2Ds = Physics2D.OverlapBoxAll(transform.position + new Vector3(-0.54f, 3.34f), new Vector2(2.88f, 8.8f), 0f, LayerMask.GetMask("PlayerBody"));

        foreach (var hit in hitCollider2Ds)
        {
            _damageDealer.DealDamage(hit.gameObject, hit.transform.position);
        }

        // DebugExtensions.DrawBox ( transform.position + new Vector3 ( -0.54f, 3.34f ), new Vector2 ( 2.88f, 8.8f ), 0f, Color.red );
    }