Example #1
0
 public void DealDamage(IDamageReceiver receiver)
 {
     if (receiver != null)
     {
         receiver.ReceiveDamage(int.MaxValue);
     }
 }
        public void InflictDamage(IDamageReceiver receiver)
        {
            float damage = GetDamage();

            receiver.ReceiveDamage(damage);
            eventOnDamageInflicted?.Invoke(damage);
        }
Example #3
0
 public void DealDamage(IDamageReceiver damageReceiver, DamagesParameters damagesParameters)
 {
     if (damageReceiver.GetDamageTag != attackTag || damageReceiver.GetDamageTag == AttackTag.Enemies || damageReceiver.GetDamageTag == AttackTag.Environment)
     {
         damageReceiver.ReceiveDamage(this, damagesParameters, null);
     }
 }
    public void DealDamage(IDamageReceiver damageReceiver, DamagesParameters damagesParameters)
    {
        damageReceiver.ReceiveDamage(this, damagesParameters, relatedProjectile.GetProjectileSpecialParameters);

        if (relatedProjectile.GetProjectileSpecialParameters.GetPiercingParameters.GetNumberOfPiercing > 0)
        {
            relatedProjectile.GetProjectileSpecialParameters.GetPiercingParameters.DecreamentPiercing();

            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f, specialSound);
            }
        }
        else if (relatedProjectile.GetProjectileSpecialParameters.GetSkeweringParameters.Skewering)
        {
            FeedbackObject woodProjection = GameManager.gameManager.PoolManager.GetFeedbackObject(FeedbackObjectPoolTag.WoodDestruction, PoolInteractionType.GetFromPool);
            if (woodProjection != null)
            {
                woodProjection.transform.position = transform.position;
                woodProjection.StartFeedback(2, 0.2f, specialSound);
            }
        }
        else
        {
            relatedProjectile.ExplodeOnContact();
        }
    }
Example #5
0
    private void OnHitPlayer()
    {
        IDamageReceiver playerDamage = m_player.GetComponent <IDamageReceiver>();

        playerDamage.ReceiveDamage(m_damage);
        Destroy(gameObject);
    }
Example #6
0
 public void DealDamage(IDamageReceiver receiver)
 {
     if (receiver != null)
     {
         int damage = Damage + Random.Range(-10, 20);
         Debug.Log(damage + " урона нанесено");
         receiver.ReceiveDamage(damage);
     }
 }
Example #7
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject != m_firer)
        {
            IDamageReceiver damageReceiver = collider.gameObject.GetComponent <IDamageReceiver>();
            if (damageReceiver != null)
            {
                if (!m_enemyBullet || collider.gameObject == GameMaster.GetPlayer())
                {
                    damageReceiver.ReceiveDamage(m_damage);
                }

                Destroy(gameObject);
            }
        }
    }
Example #8
0
    public void UpdateOutMapManagement()
    {
        if (activeOutMapZones.Count > 0)
        {
            if (remainingTimeBeforeNextDamages > 0)
            {
                remainingTimeBeforeNextDamages -= Time.deltaTime;
            }
            else if (remainingTimeBeforeNextDamages < 0)
            {
                if (GameManager.gameManager.Won)
                {
                    activeOutMapZones = new List <OutMapZone>();
                    remainingTimeBeforeNextDamages = 0;
                    return;
                }

                //playerLifeManager.Damage(damagesParameters.GetDamageAmount, damagesParameters.GetRecoveringTime, damagesParameters.GetRecoveringType);
                playerReceiver.ReceiveDamage(null, damagesParameters, null);
                remainingTimeBeforeNextDamages = timeBetweenTwoDamages;
            }
        }

        if (vignetteCounter != 0 || activeOutMapZones.Count > 0)
        {
            vignetteCounter += Time.deltaTime * dangerVignetteSpeed;

            foreach (Image dangerVignette in dangerVignettes)
            {
                Color vignetteColor = dangerVignette.color;
                vignetteColor.a      = vignetteCurve.Evaluate(vignetteCounter);
                dangerVignette.color = vignetteColor;
            }

            if (vignetteCounter % 2 < 0.03f)
            {
                if (activeOutMapZones.Count > 0)
                {
                    vignetteCounter -= 2;
                }
                else
                {
                    vignetteCounter = 0;
                }
            }
        }
    }
Example #9
0
        /// <summary>
        /// Deals damage to the receiver.
        /// </summary>
        /// <param name="receiver">Damage receiving entity.</param>
        public void DealDamage(IDamageReceiver receiver)
        {
            var calculations        = Calculations.GetInstance();
            var receiverKineticData = receiver.GetKineticData();

            float thisKineticEnergy     = calculations.CalcKineticEnergy(_rigidBody.velocity, _rigidBody.mass);
            float receiverKineticEnergy =
                calculations.CalcKineticEnergy(receiverKineticData.Velocity, receiverKineticData.Mass);
            float velocityAngleFactor = VectorManipulator.CalcAngleBetweenVectors(_rigidBody.velocity, receiverKineticData.Velocity);

            //Head on collision means 0°. Perfect amortization means 180°. -cosa describes this relation, we get cosa.
            velocityAngleFactor = -velocityAngleFactor;

            receiverKineticEnergy *= velocityAngleFactor;
            float totalEnergy = thisKineticEnergy + receiverKineticEnergy;

            receiver.ReceiveDamage(totalEnergy);
        }
Example #10
0
 /// <summary>
 /// Applies damage to the _damageReceiver.
 /// </summary>
 /// <param name="damage">Amount of damage to be received.</param>
 public void ReceiveDamage(float damage)
 {
     _damageReceiver.ReceiveDamage(damage);
 }
Example #11
0
    private void OnHitPlayer()
    {
        IDamageReceiver playerDamage = m_player.GetComponent <IDamageReceiver>();

        playerDamage.ReceiveDamage(m_playerImpactDamage);
    }
Example #12
0
 public void DealDamage(IDamageReceiver damageReceiver, DamagesParameters damagesParameters)
 {
     damageReceiver.ReceiveDamage(this, damagesParameters, null);
 }
Example #13
0
 public void DealDamage(IDamageReceiver receiver)
 {
     receiver.ReceiveDamage(this, new Damage(15));
 }